From 0c124327deaaf6ef4f3adbfdc50a9828d301dede Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Wed, 10 Aug 2016 19:49:31 +0800 Subject: [PATCH 1/7] copy/flip limit if the copy/flip is activated, it means it's already in the battlefield, so "enters the battlefield" must not trigger... --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 3 +-- projects/mtg/include/AllAbilities.h | 6 ++++-- projects/mtg/include/MTGCardInstance.h | 1 + projects/mtg/src/AllAbilities.cpp | 17 ++++++++++++----- projects/mtg/src/GuiAvatars.cpp | 6 +++--- projects/mtg/src/MTGAbility.cpp | 5 +++-- projects/mtg/src/MTGCardInstance.cpp | 1 + 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index d874aff17..4930d6239 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -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] diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 37fe8f4e7..f497dca5f 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1949,7 +1949,8 @@ class AACopier: public ActivatedAbility { public: MTGAbility * andAbility; - AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); + bool activated; + AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL, bool activated = false); int resolve(); const string getMenuText(); AACopier * clone() const; @@ -4595,7 +4596,8 @@ public: string flipStats; bool isflipcard; bool forcedcopy; - AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats, bool isflipcard = false, bool forcedcopy = false); + bool activated; + AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats, bool isflipcard = false, bool forcedcopy = false, bool activated = false); int resolve(); int testDestroy(); const string getMenuText(); diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index cd18151a5..54d7e6502 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -89,6 +89,7 @@ public: bool turningOver; bool isMorphed; bool isFlipped; + bool activateCF; string MeldedFrom; bool isPhased; bool isCascaded; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 2cf3abab5..4036b1d45 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -1449,11 +1449,12 @@ AALibraryBottom * AALibraryBottom::clone() const } //AACopier -AACopier::AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost) : +AACopier::AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost, bool _activated) : ActivatedAbility(observer, _id, _source, _cost, 0) { target = _target; andAbility = NULL; + activated = _activated; } int AACopier::resolve() @@ -1462,6 +1463,7 @@ int AACopier::resolve() MTGCardInstance * _target = (MTGCardInstance *) target; if (_target) { + _target->activateCF = activated; MTGCard* clone ; if(_target->isToken || (_target->isACopier && _target->hasCopiedToken)) {//fix crash when copying token @@ -1482,7 +1484,7 @@ int AACopier::resolve() * 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); + AAFlip * af = NEW AAFlip(game, game->mLayers->actionLayer()->getMaxId(), source, source, clone->data->name, false, true, activated); af->oneShot = 1; af->canBeInterrupted = false; af->resolve(); @@ -1532,6 +1534,7 @@ int AACopier::resolve() andAbilityClone->addToGame(); } } + _target->activateCF = false; return 1; } return 0; @@ -1653,7 +1656,7 @@ AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, M if (target) { MTGCardInstance * _target = (MTGCardInstance *) target; - if(_target->isFlipped && _target->hasType(Subtypes::TYPE_PLANESWALKER))//is flipping pw + if(_target->isFlipped && (_target->activateCF || _target->hasType(Subtypes::TYPE_PLANESWALKER)))//is flipping && activated flip or activated copy or Planeswalker { this->forceDestroy = 1; return 0; @@ -3204,10 +3207,11 @@ AAMeld * AAMeld::clone() const } // flip a card -AAFlip::AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats, bool isflipcard, bool forcedcopy) : +AAFlip::AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats, bool isflipcard, bool forcedcopy, bool _activated) : InstantAbility(observer, id, card, _target),flipStats(flipStats),isflipcard(isflipcard),forcedcopy(forcedcopy) { target = _target; + activated = _activated; } int AAFlip::resolve() @@ -3239,6 +3243,7 @@ int AAFlip::resolve() AbilityFactory af(game); _target->isFlipped = true; + _target->activateCF = activated; GameObserver * game = _target->getObserver(); if(flipStats.size()) { @@ -3286,7 +3291,8 @@ int AAFlip::resolve() { if (a->oneShot) { - a->resolve(); + if(!activated) + a->resolve(); SAFE_DELETE(a); } else @@ -3368,6 +3374,7 @@ int AAFlip::testDestroy() //originally added as a safegaurd to insure the ability was removed //it's been so long and so much has changed that it appears to do nothing but cause a crash now _target->isFlipped = false; + _target->activateCF = false; return 1; } } diff --git a/projects/mtg/src/GuiAvatars.cpp b/projects/mtg/src/GuiAvatars.cpp index 4d2af134b..5645195e6 100644 --- a/projects/mtg/src/GuiAvatars.cpp +++ b/projects/mtg/src/GuiAvatars.cpp @@ -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; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index b3055061e..73334e2b0 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2547,6 +2547,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG MTGAbility * a = NEW AACopier(observer, id, card, target); a->oneShot = 1; a->canBeInterrupted = false; + ((AACopier*)a)->activated = activated; //andability if(storedAndAbility.size()) { @@ -3393,12 +3394,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG } if(card->getdoubleFaced() == "kamiflip") {//old flip cards kamigawa - MTGAbility * a = NEW AAFlip(observer, id, card, target,flipStats,true); + MTGAbility * a = NEW AAFlip(observer, id, card, target,flipStats,true,false,activated); return a; } else//regular transform { - MTGAbility * a = NEW AAFlip(observer, id, card, target,flipStats); + MTGAbility * a = NEW AAFlip(observer, id, card, target,flipStats,false,false,activated); return a; } } diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index cf5d094cc..8045208f5 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -195,6 +195,7 @@ void MTGCardInstance::initMTGCI() isMorphed = false; MeldedFrom = ""; isFlipped = false; + activateCF = false; isPhased = false; isCascaded = false; phasedTurn = -1; From a10e7ab279bb68dd99411143f6a4b2c3e56da9fb Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 11 Aug 2016 11:03:37 +0800 Subject: [PATCH 2/7] Revert "copy/flip limit" This reverts commit 0c124327deaaf6ef4f3adbfdc50a9828d301dede. --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 3 ++- projects/mtg/include/AllAbilities.h | 6 ++---- projects/mtg/include/MTGCardInstance.h | 1 - projects/mtg/src/AllAbilities.cpp | 17 +++++------------ projects/mtg/src/GuiAvatars.cpp | 6 +++--- projects/mtg/src/MTGAbility.cpp | 5 ++--- projects/mtg/src/MTGCardInstance.cpp | 1 - 7 files changed, 14 insertions(+), 25 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 4930d6239..d874aff17 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -119077,7 +119077,8 @@ toughness=4 [/card] [card] name=Vesuva -auto=may copy notatarget(land) and!( tap(noevent) )! +auto=tap(noevent) +auto=may copy notatarget(land) text=You may have Vesuva enter the battlefield tapped as a copy of any land on the battlefield. type=Land [/card] diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index f497dca5f..37fe8f4e7 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1949,8 +1949,7 @@ class AACopier: public ActivatedAbility { public: MTGAbility * andAbility; - bool activated; - AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL, bool activated = false); + AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); int resolve(); const string getMenuText(); AACopier * clone() const; @@ -4596,8 +4595,7 @@ public: string flipStats; bool isflipcard; bool forcedcopy; - bool activated; - AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats, bool isflipcard = false, bool forcedcopy = false, bool activated = false); + AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats, bool isflipcard = false, bool forcedcopy = false); int resolve(); int testDestroy(); const string getMenuText(); diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 54d7e6502..cd18151a5 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -89,7 +89,6 @@ public: bool turningOver; bool isMorphed; bool isFlipped; - bool activateCF; string MeldedFrom; bool isPhased; bool isCascaded; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 4036b1d45..2cf3abab5 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -1449,12 +1449,11 @@ AALibraryBottom * AALibraryBottom::clone() const } //AACopier -AACopier::AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost, bool _activated) : +AACopier::AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost) : ActivatedAbility(observer, _id, _source, _cost, 0) { target = _target; andAbility = NULL; - activated = _activated; } int AACopier::resolve() @@ -1463,7 +1462,6 @@ int AACopier::resolve() MTGCardInstance * _target = (MTGCardInstance *) target; if (_target) { - _target->activateCF = activated; MTGCard* clone ; if(_target->isToken || (_target->isACopier && _target->hasCopiedToken)) {//fix crash when copying token @@ -1484,7 +1482,7 @@ int AACopier::resolve() * 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, activated); + AAFlip * af = NEW AAFlip(game, game->mLayers->actionLayer()->getMaxId(), source, source, clone->data->name, false, true); af->oneShot = 1; af->canBeInterrupted = false; af->resolve(); @@ -1534,7 +1532,6 @@ int AACopier::resolve() andAbilityClone->addToGame(); } } - _target->activateCF = false; return 1; } return 0; @@ -1656,7 +1653,7 @@ AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, M if (target) { MTGCardInstance * _target = (MTGCardInstance *) target; - if(_target->isFlipped && (_target->activateCF || _target->hasType(Subtypes::TYPE_PLANESWALKER)))//is flipping && activated flip or activated copy or Planeswalker + if(_target->isFlipped && _target->hasType(Subtypes::TYPE_PLANESWALKER))//is flipping pw { this->forceDestroy = 1; return 0; @@ -3207,11 +3204,10 @@ AAMeld * AAMeld::clone() const } // flip a card -AAFlip::AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats, bool isflipcard, bool forcedcopy, bool _activated) : +AAFlip::AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats, bool isflipcard, bool forcedcopy) : InstantAbility(observer, id, card, _target),flipStats(flipStats),isflipcard(isflipcard),forcedcopy(forcedcopy) { target = _target; - activated = _activated; } int AAFlip::resolve() @@ -3243,7 +3239,6 @@ int AAFlip::resolve() AbilityFactory af(game); _target->isFlipped = true; - _target->activateCF = activated; GameObserver * game = _target->getObserver(); if(flipStats.size()) { @@ -3291,8 +3286,7 @@ int AAFlip::resolve() { if (a->oneShot) { - if(!activated) - a->resolve(); + a->resolve(); SAFE_DELETE(a); } else @@ -3374,7 +3368,6 @@ int AAFlip::testDestroy() //originally added as a safegaurd to insure the ability was removed //it's been so long and so much has changed that it appears to do nothing but cause a crash now _target->isFlipped = false; - _target->activateCF = false; return 1; } } diff --git a/projects/mtg/src/GuiAvatars.cpp b/projects/mtg/src/GuiAvatars.cpp index 5645195e6..4d2af134b 100644 --- a/projects/mtg/src/GuiAvatars.cpp +++ b/projects/mtg/src/GuiAvatars.cpp @@ -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 - 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)); + 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)); //myexile - Add(selfExile = NEW GuiExile(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 34, false, mpDuelLayers->getRenderedPlayer(), this)); + Add(selfExile = NEW GuiExile(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 30, false, mpDuelLayers->getRenderedPlayer(), this)); Add(opponent = NEW GuiAvatar(0, 0, false, mpDuelLayers->getRenderedPlayerOpponent(), GuiAvatar::TOP_LEFT, this)); opponent->zoom = 0.9f; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 73334e2b0..b3055061e 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2547,7 +2547,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG MTGAbility * a = NEW AACopier(observer, id, card, target); a->oneShot = 1; a->canBeInterrupted = false; - ((AACopier*)a)->activated = activated; //andability if(storedAndAbility.size()) { @@ -3394,12 +3393,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG } if(card->getdoubleFaced() == "kamiflip") {//old flip cards kamigawa - MTGAbility * a = NEW AAFlip(observer, id, card, target,flipStats,true,false,activated); + MTGAbility * a = NEW AAFlip(observer, id, card, target,flipStats,true); return a; } else//regular transform { - MTGAbility * a = NEW AAFlip(observer, id, card, target,flipStats,false,false,activated); + MTGAbility * a = NEW AAFlip(observer, id, card, target,flipStats); return a; } } diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 8045208f5..cf5d094cc 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -195,7 +195,6 @@ void MTGCardInstance::initMTGCI() isMorphed = false; MeldedFrom = ""; isFlipped = false; - activateCF = false; isPhased = false; isCascaded = false; phasedTurn = -1; From adad723110e19ac2d9ac1165bc7939a3ac06bcc7 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 11 Aug 2016 14:26:41 +0800 Subject: [PATCH 3/7] game mode info --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 3 +- projects/mtg/src/GameStateDuel.cpp | 37 +++++++++++++++++++- projects/mtg/src/GuiAvatars.cpp | 6 ++-- projects/mtg/src/MTGAbility.cpp | 13 ++----- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index d874aff17..4930d6239 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -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] diff --git a/projects/mtg/src/GameStateDuel.cpp b/projects/mtg/src/GameStateDuel.cpp index 69221161c..5ab78aeb8 100644 --- a/projects/mtg/src/GameStateDuel.cpp +++ b/projects/mtg/src/GameStateDuel.cpp @@ -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); } } } diff --git a/projects/mtg/src/GuiAvatars.cpp b/projects/mtg/src/GuiAvatars.cpp index 4d2af134b..5645195e6 100644 --- a/projects/mtg/src/GuiAvatars.cpp +++ b/projects/mtg/src/GuiAvatars.cpp @@ -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; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index b3055061e..5b0ac20fd 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -3391,16 +3391,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG /*vectorFlipStats = 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 From 51016f925830e22398065d3c9036430d0de5da8d Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 11 Aug 2016 18:52:18 +0800 Subject: [PATCH 4/7] revised AACopier --- projects/mtg/include/AllAbilities.h | 1 + projects/mtg/src/AllAbilities.cpp | 104 +++++++++++++++++++++++----- projects/mtg/src/CardGui.cpp | 1 + 3 files changed, 89 insertions(+), 17 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 37fe8f4e7..a01b899e8 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1949,6 +1949,7 @@ class AACopier: public ActivatedAbility { public: MTGAbility * andAbility; + vector currentAbilities; AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); int resolve(); const string getMenuText(); diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 2cf3abab5..4aa778761 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -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,92 @@ 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); + 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(source->cardsAbilities[i]); + + if(a) game->removeObserver(a); + } + source->cardsAbilities.clear(); + source->magicText = myClone->magicText; + af.getAbilities(¤tAbilities, 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(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 +1601,7 @@ int AACopier::resolve() andAbilityClone->addToGame(); } } + source->mPropertiesChangedSinceLastUpdate = true; return 1; } return 0; diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index e842988f0..91570066e 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -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); From 7e14b2fc5a912fb6ee6d402fe9bd424af609d6fd Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 11 Aug 2016 21:05:00 +0800 Subject: [PATCH 5/7] exception testsuite the current implementation was clone must be recognized by id in the scripted test. --- projects/mtg/src/AllAbilities.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 4aa778761..9d28f2a6e 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -1474,9 +1474,12 @@ int AACopier::resolve() /////////////////////////////////////////////////////////////////////// MTGCardInstance * myClone = NEW MTGCardInstance(clone, source->controller()->game); //source->copy(myClone); - source->setMTGId(myClone->getMTGId()); - source->setId = myClone->setId; - source->setRarity(myClone->getRarity()); + 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(); From a378e3a72d0ee65c5c3b87b03eab593eafb58fc0 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 12 Aug 2016 07:43:39 +0800 Subject: [PATCH 6/7] fix extracosts on cumulative upcost since Manacost::copy copies, extracost, if this is enabled, extracost is doubled. tested with Aboroth --- projects/mtg/src/AllAbilities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 9d28f2a6e..97c772451 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -6580,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); } } From 2e525dfdcc4a7a67734c434b3dd05697b60fbc89 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 12 Aug 2016 07:44:59 +0800 Subject: [PATCH 7/7] exclude card that copied a token. I added a new search for tokens just below this --- projects/mtg/src/CardGui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index 91570066e..cb8cf5954 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -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); @@ -1143,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(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);