Merge pull request #849 from kevlahnota/master

Add Game/Player Info
This commit is contained in:
Anthony Calosa
2016-08-12 09:18:32 +08:00
committed by GitHub
7 changed files with 138 additions and 36 deletions

View File

@@ -119077,8 +119077,7 @@ toughness=4
[/card]
[card]
name=Vesuva
auto=tap(noevent)
auto=may copy notatarget(land)
auto=may copy notatarget(land) and!( tap(noevent) )!
text=You may have Vesuva enter the battlefield tapped as a copy of any land on the battlefield.
type=Land
[/card]

View File

@@ -1949,6 +1949,7 @@ class AACopier: public ActivatedAbility
{
public:
MTGAbility * andAbility;
vector<MTGAbility *> currentAbilities;
AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL);
int resolve();
const string getMenuText();

View File

@@ -1462,7 +1462,8 @@ int AACopier::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
MTGCard* clone ;
MTGCard* clone;
AbilityFactory af(game);
if(_target->isToken || (_target->isACopier && _target->hasCopiedToken))
{//fix crash when copying token
clone = _target;
@@ -1470,24 +1471,95 @@ int AACopier::resolve()
}
else
clone = MTGCollection()->getCardById(_target->copiedID);
if(tokencopied)
{
///////////////////////////////////////////////////////////////////////
MTGCardInstance * myClone = NEW MTGCardInstance(clone, source->controller()->game);
source->copy(myClone);
//source->copy(myClone);
if(source->controller()->playMode != Player::MODE_TEST_SUITE)
{
source->setMTGId(myClone->getMTGId());
source->setId = myClone->setId;
source->setRarity(myClone->getRarity());
}
source->name = myClone->name;
source->setName(myClone->name);
source->getManaCost()->resetCosts();
if(myClone->getManaCost())
source->getManaCost()->copy(myClone->getManaCost());
source->colors = myClone->colors;
source->types = myClone->types;
source->text = myClone->text;
source->formattedText = myClone->formattedText;
source->basicAbilities = myClone->model->data->basicAbilities;
source->modbasicAbilities = myClone->modbasicAbilities;
for(unsigned int i = 0;i < source->cardsAbilities.size();i++)
{
MTGAbility * a = dynamic_cast<MTGAbility *>(source->cardsAbilities[i]);
if(a) game->removeObserver(a);
}
source->cardsAbilities.clear();
source->magicText = myClone->magicText;
af.getAbilities(&currentAbilities, NULL, source);
for (size_t i = 0; i < currentAbilities.size(); ++i)
{
MTGAbility * a = currentAbilities[i];
a->source = (MTGCardInstance *) source;
if (a)
{
if (a->oneShot)
{
a->resolve();
SAFE_DELETE(a);
}
else
{
a->addToGame();
MayAbility * dontAdd = dynamic_cast<MayAbility*>(a);
if(!dontAdd)
{
source->cardsAbilities.push_back(a);
}
}
}
}
//power
int powerMod = 0;
int toughMod = 0;
bool powerlessThanOriginal = false;
bool toughLessThanOriginal = false;
if(source->power < source->origpower)
{
powerMod = source->origpower - source->power;
powerlessThanOriginal = true;
}
else
{
powerMod =source->power - source->origpower;
}
//toughness
if(source->toughness <= source->origtoughness)
{
toughMod = source->origtoughness - source->toughness;
toughLessThanOriginal = true;
}
else
{
toughMod =source->toughness - source->origtoughness;
}
if(!source->isCDA)
{
source->power = powerlessThanOriginal?myClone->power - powerMod:myClone->power + powerMod;
source->life = toughLessThanOriginal?myClone->toughness - toughMod:myClone->toughness + toughMod;
source->toughness = toughLessThanOriginal?myClone->toughness - toughMod:myClone->toughness + toughMod;
source->origpower = myClone->origpower;
source->origtoughness = myClone->origtoughness;
}
else
{//pbonus & tbonus are already computed except damage taken...
source->life -= source->damageCount;
}
SAFE_DELETE(myClone);
}
else
{/*********************************************
* instead of using source->copy(myClone) use *
* AAFlip with forcedcopy to true *
*********************************************/
AAFlip * af = NEW AAFlip(game, game->mLayers->actionLayer()->getMaxId(), source, source, clone->data->name, false, true);
af->oneShot = 1;
af->canBeInterrupted = false;
af->resolve();
SAFE_DELETE(af);
}
///////////////////////////////////////////////////////////////////////
source->isACopier = true;
source->hasCopiedToken = tokencopied;
source->copiedID = _target->copiedID;
@@ -1532,6 +1604,7 @@ int AACopier::resolve()
andAbilityClone->addToGame();
}
}
source->mPropertiesChangedSinceLastUpdate = true;
return 1;
}
return 0;
@@ -6507,7 +6580,7 @@ AUpkeep::AUpkeep(GameObserver* observer, int _id, MTGCardInstance * card, MTGAbi
{
backupMana = NEW ManaCost();
backupMana->copy(this->getCost());
backupMana->addExtraCosts(this->getCost()->extraCosts);
//backupMana->addExtraCosts(this->getCost()->extraCosts);
}
}

View File

@@ -147,7 +147,7 @@ void CardGui::Render()
bool alternate = true;
JQuadPtr quad = game? game->getResourceManager()->RetrieveCard(card, CACHE_THUMB):WResourceManager::Instance()->RetrieveCard(card, CACHE_THUMB);
if(card && !card->isToken && card->name != card->model->data->name)
if(card && !card->hasCopiedToken && !card->isToken && card->name != card->model->data->name)
{
MTGCard * fcard = MTGCollection()->getCardByName(card->name);
quad = game->getResourceManager()->RetrieveCard(fcard, CACHE_THUMB);
@@ -444,6 +444,7 @@ void CardGui::Render()
else if(card->chooseacolor == 5)
buff += "\n-White";
}
if(buff != "")//enable indicator at all modes
{
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
@@ -1142,7 +1143,7 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb, bool noborder
JQuadPtr quad = thumb ? WResourceManager::Instance()->RetrieveCard(card, RETRIEVE_THUMB)
: WResourceManager::Instance()->RetrieveCard(card);
MTGCardInstance * kcard = dynamic_cast<MTGCardInstance*>(card);
if(kcard && !kcard->isToken && kcard->name != kcard->model->data->name)
if(kcard && !kcard->hasCopiedToken && !kcard->isToken && kcard->name != kcard->model->data->name)
{
MTGCard * fcard = MTGCollection()->getCardByName(kcard->name);
quad = WResourceManager::Instance()->RetrieveCard(fcard);

View File

@@ -1196,24 +1196,59 @@ void GameStateDuel::Render()
case DUEL_STATE_BACK_TO_MAIN_MENU:
if (game)
{
string gtype = "";
if(game->gameType() == GAME_TYPE_CLASSIC)
gtype = "Classic";
else if(game->gameType() == GAME_TYPE_MOMIR)
gtype = "Momir";
else if(game->gameType() == GAME_TYPE_RANDOM1 || game->gameType() == GAME_TYPE_RANDOM2)
gtype = "Random";
else if(game->gameType() == GAME_TYPE_STORY)
gtype = "Story";
else if(game->gameType() == GAME_TYPE_DEMO)
gtype = "Demo";
else if(game->gameType() == GAME_TYPE_STONEHEWER)
gtype = "Stone Hewer";
else if(game->gameType() == GAME_TYPE_HERMIT)
gtype = "Hermit Druid";
else
gtype = "Blitzkrieg";
r->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(100,0,0,0));
char buffer[4096];
sprintf(buffer, _("Turn:%i").c_str(), game->turn);
mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(buffer, SCREEN_WIDTH / 2, 0, JGETEXT_CENTER);
mFont->DrawString(gtype, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 15, JGETEXT_CENTER);
}
if (menu)
{
menu->Render();
// display the player deck names in their respective corners
string p0playmode = "";
if(game->players[0]->playMode == Player::MODE_TEST_SUITE)
p0playmode = "AI Testsuite";
else if(game->players[0]->playMode == Player::MODE_HUMAN)
p0playmode = "Human";
else
p0playmode = "AI";
string playerDeckName = game->players[0]->deckName;
float playerDeckNamePixelLength = mFont->GetStringWidth(playerDeckName.c_str());
float playerModePixelLength = mFont->GetStringWidth(p0playmode.c_str());
mFont->DrawString( playerDeckName, SCREEN_WIDTH_F - playerDeckNamePixelLength, SCREEN_HEIGHT_F - 50);
mFont->DrawString( p0playmode, SCREEN_WIDTH_F - playerModePixelLength, SCREEN_HEIGHT_F - 60);
if(game->players.size()>1)
{
string p1playmode = "";
if(game->players[1]->playMode == Player::MODE_TEST_SUITE)
p1playmode = "AI Testsuite";
else if(game->players[1]->playMode == Player::MODE_HUMAN)
p1playmode = "Human";
else
p1playmode = "AI";
string opponentDeckName = game->players[1]->deckName;
mFont->DrawString( opponentDeckName, 0, 50);
mFont->DrawString( opponentDeckName, 0, 40);
mFont->DrawString( p1playmode, 0, 50);
}
}
}

View File

@@ -12,10 +12,10 @@ GuiAvatars::GuiAvatars(DuelLayers* duelLayers) :
{
Add(self = NEW GuiAvatar(SCREEN_WIDTH, SCREEN_HEIGHT, false, mpDuelLayers->getRenderedPlayer(), GuiAvatar::BOTTOM_RIGHT, this));
self->zoom = 0.9f;
Add(selfGraveyard = NEW GuiGraveyard(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 1, false, mpDuelLayers->getRenderedPlayer(), this));
Add(selfLibrary = NEW GuiLibrary(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 5 + GuiGameZone::Height + 5, false, mpDuelLayers->getRenderedPlayer(), this));
Add(selfGraveyard = NEW GuiGraveyard(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 7, false, mpDuelLayers->getRenderedPlayer(), this));
Add(selfLibrary = NEW GuiLibrary(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 10 + GuiGameZone::Height + 5, false, mpDuelLayers->getRenderedPlayer(), this));
//myexile
Add(selfExile = NEW GuiExile(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 30, false, mpDuelLayers->getRenderedPlayer(), this));
Add(selfExile = NEW GuiExile(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 34, false, mpDuelLayers->getRenderedPlayer(), this));
Add(opponent = NEW GuiAvatar(0, 0, false, mpDuelLayers->getRenderedPlayerOpponent(), GuiAvatar::TOP_LEFT, this));
opponent->zoom = 0.9f;

View File

@@ -3391,16 +3391,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
/*vector<string>FlipStats = split(splitFlipStat[1],'%');*/
flipStats = splitFlipStat[1];
}
if(card->getdoubleFaced() == "kamiflip")
{//old flip cards kamigawa
MTGAbility * a = NEW AAFlip(observer, id, card, target,flipStats,true);
return a;
}
else//regular transform
{
MTGAbility * a = NEW AAFlip(observer, id, card, target,flipStats);
return a;
}
bool transmode = card->getdoubleFaced() == "kamiflip"?true:false;
MTGAbility * a = NEW AAFlip(observer, id, card, target,flipStats,transmode);
return a;
}
//Change Power/Toughness