From cdf94b281f384d4c465e561ed126ec527ac61156 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 26 Oct 2015 19:14:50 +0800 Subject: [PATCH] exile zone enabled exile zones for both players --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 2 +- projects/mtg/include/AllAbilities.h | 57 ++++++++++---------- projects/mtg/src/AIPlayerBaka.cpp | 12 ++--- projects/mtg/src/AllAbilities.cpp | 24 +++++++-- projects/mtg/src/GameObserver.cpp | 11 ++-- projects/mtg/src/GuiAvatars.cpp | 32 +++++++---- projects/mtg/src/GuiStatic.cpp | 16 +++++- projects/mtg/src/MTGAbility.cpp | 15 +++--- projects/mtg/src/Rules.cpp | 16 +++--- projects/mtg/src/TestSuiteAI.cpp | 21 ++++---- 10 files changed, 125 insertions(+), 81 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 4489f959d..eaed73793 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -68670,7 +68670,7 @@ type=Sorcery [card] name=Obzedat, Ghost Council auto=ability$!choice life:-2 target(opponent) && life:2 controller!$ controller -auto=@each my end:may name(exile) all(this) transforms((,newability[moveto(exile)],newability[phaseactionmulti[my upkeep once] moveto(ownerbattlefield) && all(this) haste])) +auto=@each my end:may name(exile) all(this) transforms((,newability[moveto(exile)],newability[phaseactionmulti[my upkeep once checkex] moveto(ownerbattlefield) && all(this) haste])) text=When Obzedat, Ghost Council enters the battlefield, target opponent loses 2 life and you gain 2 life. -- At the beginning of your end step, you may exile Obzedat. If you do, return it to the battlefield under its owner's control at the beginning of your next upkeep. It gains haste. mana={1}{W}{W}{B}{B} type=Legendary Creature diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index cbc9fb7fd..2f6d40e6c 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -207,8 +207,8 @@ private: for (int i = 0; i < 2; i++) { Player * dp = card->getObserver()->players[i]; - MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library, dp->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = dzones[k]; if (dtc->targetsZone(zone, card)&&dp == card->controller()) @@ -227,8 +227,8 @@ private: for (int i = 0; i < 2; i++) { Player * dp = card->getObserver()->players[i]; - MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library, dp->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = dzones[k]; if (dtc->targetsZone(zone, card)&&dp == card->controller()) @@ -247,8 +247,8 @@ private: for (int i = 0; i < 2; i++) { Player * dp = card->getObserver()->players[i]; - MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library, dp->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = dzones[k]; if (dtc->targetsZone(zone, card)&&dp == card->controller()) @@ -267,8 +267,8 @@ private: for (int i = 0; i < 2; i++) { Player * dp = card->getObserver()->players[i]; - MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library, dp->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = dzones[k]; if (dtc->targetsZone(zone, card)&&dp == card->controller()) @@ -287,8 +287,8 @@ private: for (int i = 0; i < 2; i++) { Player * dp = card->getObserver()->players[i]; - MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library, dp->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = dzones[k]; if (dtc->targetsZone(zone, card)&&dp == card->controller()) @@ -307,8 +307,8 @@ private: for (int i = 0; i < 2; i++) { Player * dp = card->getObserver()->players[i]; - MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library, dp->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = dzones[k]; if (dtc->targetsZone(zone, card)&&dp == card->controller()) @@ -327,8 +327,8 @@ private: for (int i = 0; i < 2; i++) { Player * dp = card->getObserver()->players[i]; - MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library, dp->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = dzones[k]; if (dtc->targetsZone(zone, card)&&dp == card->controller()) @@ -347,8 +347,8 @@ private: for (int i = 0; i < 2; i++) { Player * dp = card->getObserver()->players[i]; - MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library, dp->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = dzones[k]; if (dtc->targetsZone(zone, card)&&dp == card->controller()) @@ -367,8 +367,8 @@ private: for (int i = 0; i < 2; i++) { Player * dp = card->getObserver()->players[i]; - MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library, dp->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = dzones[k]; if (dtc->targetsZone(zone, card)&&dp == card->controller()) @@ -387,8 +387,8 @@ private: for (int i = 0; i < 2; i++) { Player * dp = card->getObserver()->players[i]; - MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * dzones[] = { dp->game->inPlay, dp->game->graveyard, dp->game->hand, dp->game->library, dp->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = dzones[k]; if (dtc->targetsZone(zone, card)&&dp == card->controller()) @@ -424,8 +424,8 @@ private: for (int i = 0; i < 2; i++) { Player * p = card->getObserver()->players[i]; - MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = zones[k]; if (tc->targetsZone(zone, card)) @@ -516,8 +516,8 @@ private: for (int i = 0; i < 2; i++) { Player * p = card->getObserver()->players[i]; - MTGGameZone * zones[] = { p->game->battlefield, p->game->graveyard, p->game->hand, p->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * zones[] = { p->game->battlefield, p->game->graveyard, p->game->hand, p->game->library, p->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = zones[k]; if(tc->targetsZone(zone,target)) @@ -2916,8 +2916,8 @@ public: for (int i = 0; i < 2; i++) { Player * p = game->players[i]; - MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = zones[k]; Value = zone->countByCanTarget(tc); @@ -4913,10 +4913,11 @@ public: bool myturn; bool opponentturn; bool once; + bool checkexile; Player * abilityOwner; APhaseAction(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions = 0, int _phase = - MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = true,bool opponentturn = true,bool once = false); + MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = true,bool opponentturn = true,bool once = false, bool checkexile = false); void Update(float dt); int resolve(); const string getMenuText(); @@ -4931,7 +4932,7 @@ public: string sAbility; APhaseAction * ability; APhaseActionGeneric(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions = 0, int _phase = - MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = false,bool opponentturn = false,bool once = false); + MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = false,bool opponentturn = false,bool once = false,bool checkexile = false); int resolve(); const string getMenuText(); APhaseActionGeneric * clone() const; diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index b126eb040..d75616eaf 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -650,8 +650,8 @@ MTGCardInstance * AIPlayerBaka::chooseCard(TargetChooser * tc, MTGCardInstance * } for(int players = 0; players < 2;++players) { - MTGGameZone * zones[] = { playerZones->hand, playerZones->library, playerZones->inPlay, playerZones->graveyard,playerZones->stack }; - for (int j = 0; j < 5; j++) + MTGGameZone * zones[] = { playerZones->hand, playerZones->library, playerZones->inPlay, playerZones->graveyard,playerZones->stack,playerZones->exile }; + for (int j = 0; j < 6; j++) { MTGGameZone * zone = zones[j]; for (int k = 0; k < zone->nb_cards; k++) @@ -1214,7 +1214,7 @@ int AIPlayerBaka::createAbilityTargets(MTGAbility * a, MTGCardInstance * c, Rank for (int i = 0; i < 2; i++) { Player * p = observer->players[i]; - MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay,p->game->stack }; + MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay,p->game->stack,p->game->exile }; if(a->getActionTc()->canTarget((Targetable*)p)) { if(a->getActionTc()->maxtargets == 1) @@ -1225,7 +1225,7 @@ int AIPlayerBaka::createAbilityTargets(MTGAbility * a, MTGCardInstance * c, Rank else potentialTargets.push_back(p); } - for (int j = 0; j < 5; j++) + for (int j = 0; j < 6; j++) { MTGGameZone * zone = playerZones[j]; for (int k = 0; k < zone->nb_cards; k++) @@ -1553,8 +1553,8 @@ int AIPlayerBaka::chooseTarget(TargetChooser * _tc, Player * forceTarget,MTGCard } } MTGPlayerCards * playerZones = target->game; - MTGGameZone * zones[] = { playerZones->hand, playerZones->library, playerZones->inPlay, playerZones->graveyard,playerZones->stack }; - for (int j = 0; j < 5; j++) + MTGGameZone * zones[] = { playerZones->hand, playerZones->library, playerZones->inPlay, playerZones->graveyard,playerZones->stack,playerZones->exile }; + for (int j = 0; j < 6; j++) { MTGGameZone * zone = zones[j]; for (int k = 0; k < zone->nb_cards; k++) diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index aad2664fb..1a48ccc74 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -5092,8 +5092,8 @@ AUpkeep::~AUpkeep() } //A Phase based Action -APhaseAction::APhaseAction(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance *, string sAbility, int, int _phase,bool forcedestroy,bool next,bool myturn,bool opponentturn,bool once) : -MTGAbility(observer, _id, card),sAbility(sAbility), phase(_phase),forcedestroy(forcedestroy),next(next),myturn(myturn),opponentturn(opponentturn),once(once) +APhaseAction::APhaseAction(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance *, string sAbility, int, int _phase,bool forcedestroy,bool next,bool myturn,bool opponentturn,bool once, bool checkexile) : +MTGAbility(observer, _id, card),sAbility(sAbility), phase(_phase),forcedestroy(forcedestroy),next(next),myturn(myturn),opponentturn(opponentturn),once(once),checkexile(checkexile) { abilityId = _id; abilityOwner = card->controller(); @@ -5110,6 +5110,14 @@ MTGAbility(observer, _id, card),sAbility(sAbility), phase(_phase),forcedestroy(f void APhaseAction::Update(float dt) { + if(checkexile) + { + if(((MTGCardInstance *)target)->next->getCurrentZone() != ((MTGCardInstance *)target)->owner->game->exile) + { + this->forceDestroy = 1; + return; + } + } if (newPhase != currentPhase) { if((myturn && game->currentPlayer == source->controller())|| @@ -5186,11 +5194,11 @@ APhaseAction::~APhaseAction() } // the main ability -APhaseActionGeneric::APhaseActionGeneric(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions, int _phase,bool forcedestroy,bool next,bool myturn,bool opponentturn,bool once) : +APhaseActionGeneric::APhaseActionGeneric(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions, int _phase,bool forcedestroy,bool next,bool myturn,bool opponentturn,bool once, bool checkexile) : InstantAbility(observer, _id, card, target) { MTGCardInstance * _target = target; - ability = NEW APhaseAction(game, _id, card,_target, sAbility, restrictions, _phase,forcedestroy,next,myturn,opponentturn,once); + ability = NEW APhaseAction(game, _id, card,_target, sAbility, restrictions, _phase,forcedestroy,next,myturn,opponentturn,once,checkexile); } int APhaseActionGeneric::resolve() @@ -5236,7 +5244,7 @@ void ABlink::Update(float dt) resolveBlink(); } - if ((blinkueot && currentPhase == MTG_PHASE_ENDOFTURN) || (blinkForSource && !source->isInPlay(game))) + if ((blinkueot && currentPhase == MTG_PHASE_ENDOFTURN) || (blinkForSource && !source->isInPlay(game)) && Blinked->blinked) { if (Blinked == NULL) MTGAbility::Update(dt); @@ -5272,6 +5280,7 @@ void ABlink::resolveBlink() return; } _target = _target->next; + _target->blinked = true; Blinked = _target; if(!blinkueot && !blinkForSource) { @@ -5282,6 +5291,11 @@ void ABlink::resolveBlink() void ABlink::returnCardIntoPlay(MTGCardInstance* _target) { MTGCardInstance * Blinker = NULL; + if(!_target->blinked) + { + this->forceDestroy = 1; + return; + } if (!blinkhand) Blinker = _target->controller()->game->putInZone( _target, diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 3aba8dd97..933ec20cf 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -518,12 +518,13 @@ bool GameObserver::operator==(const GameObserver& aGame) { error++; } - MTGGameZone * aZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay }; + MTGGameZone * aZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->exile }; MTGGameZone * thisZones[] = { players[i]->game->graveyard, players[i]->game->library, players[i]->game->hand, - players[i]->game->inPlay }; - for (int j = 0; j < 4; j++) + players[i]->game->inPlay, + players[i]->game->exile }; + for (int j = 0; j < 5; j++) { MTGGameZone * zone = aZones[j]; if (zone->nb_cards != thisZones[j]->nb_cards) @@ -595,8 +596,8 @@ void GameObserver::gameStateBasedEffects() ///////////////////////////////////// for (int d = 0; d < 2; d++) { - MTGGameZone * dzones[] = { players[d]->game->inPlay, players[d]->game->graveyard, players[d]->game->hand, players[d]->game->library }; - for (int k = 0; k < 4; k++) + MTGGameZone * dzones[] = { players[d]->game->inPlay, players[d]->game->graveyard, players[d]->game->hand, players[d]->game->library, players[d]->game->exile }; + for (int k = 0; k < 5; k++) { MTGGameZone * zone = dzones[k]; if (mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) diff --git a/projects/mtg/src/GuiAvatars.cpp b/projects/mtg/src/GuiAvatars.cpp index 6b5e922a7..7db23774d 100644 --- a/projects/mtg/src/GuiAvatars.cpp +++ b/projects/mtg/src/GuiAvatars.cpp @@ -14,16 +14,21 @@ GuiAvatars::GuiAvatars(DuelLayers* duelLayers) : 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(selfExile = NEW GuiExile(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 + 20, SCREEN_HEIGHT - GuiAvatar::Height, false, mpDuelLayers->getRenderedPlayer(), this)); + //myexile + Add(selfExile = NEW GuiExile(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 + 10, SCREEN_HEIGHT - GuiAvatar::Height, false, mpDuelLayers->getRenderedPlayer(), this)); Add(opponent = NEW GuiAvatar(0, 0, false, mpDuelLayers->getRenderedPlayerOpponent(), GuiAvatar::TOP_LEFT, this)); opponent->zoom = 0.9f; - //opponenthandveiw button - Add(opponentHand = NEW GuiOpponentHand(-30 + GuiAvatar::Width * 1.2 - GuiGameZone::Width / 2, 35 + GuiGameZone::Height - 10, + //opponentExile + Add(opponentExile = NEW GuiExile(-30 + GuiAvatar::Width * 1.2 - GuiGameZone::Width / 2, 35 + GuiGameZone::Height - 10, false, mpDuelLayers->getRenderedPlayerOpponent(), this)); - //opponenthandveiwends - Add(opponentGraveyard = NEW GuiGraveyard(5 + GuiAvatar::Width * 1.4 - GuiGameZone::Width / 2, 5, false, + //opponentHand + Add(opponentHand = NEW GuiOpponentHand(5 + GuiAvatar::Width * 1.4 - GuiGameZone::Width / 2, 5, false, mpDuelLayers->getRenderedPlayerOpponent(), this)); + //opponentGraveyard + Add(opponentGraveyard = NEW GuiGraveyard(-15 + GuiAvatar::Width * 1.4 - GuiGameZone::Width / 2, 35 + GuiGameZone::Height - 10, false, + mpDuelLayers->getRenderedPlayerOpponent(), this)); + //opponentLibrary Add(opponentLibrary = NEW GuiLibrary(5 + GuiAvatar::Width * 1.4 - GuiGameZone::Width / 2, 5 + GuiGameZone::Height + 5, false, mpDuelLayers->getRenderedPlayerOpponent(), this)); @@ -33,9 +38,10 @@ GuiAvatars::GuiAvatars(DuelLayers* duelLayers) : observer->getCardSelector()->Add(selfLibrary); observer->getCardSelector()->Add(opponent); observer->getCardSelector()->Add(opponentGraveyard); + observer->getCardSelector()->Add(opponentExile); observer->getCardSelector()->Add(opponentLibrary); observer->getCardSelector()->Add(opponentHand); - selfGraveyard->alpha = selfExile->alpha = selfLibrary->alpha = opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0; + selfGraveyard->alpha = selfExile->alpha = opponentExile->alpha = selfLibrary->alpha = opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0; } float GuiAvatars::LeftBoundarySelf() @@ -52,9 +58,9 @@ void GuiAvatars::Activate(PlayGuiObject* c) c->zoom = 1.2f; c->mHasFocus = true; - if ((opponentGraveyard == c) || (opponentLibrary == c) || (opponent == c) || (opponentHand == c)) + if ((opponentGraveyard == c) || (opponentExile == c) || (opponentLibrary == c) || (opponent == c) || (opponentHand == c)) { - opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 128.0f; + opponentGraveyard->alpha = opponentExile->alpha = opponentLibrary->alpha = opponentHand->alpha = 128.0f; active = opponent; opponent->zoom = 1.2f; } @@ -71,9 +77,9 @@ void GuiAvatars::Deactivate(PlayGuiObject* c) { c->zoom = 1.0; c->mHasFocus = false; - if ((opponentGraveyard == c) || (opponentLibrary == c) || (opponentHand == c) || (opponent == c)) + if ((opponentGraveyard == c) || (opponentExile == c) || (opponentLibrary == c) || (opponentHand == c) || (opponent == c)) { - opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0; + opponentGraveyard->alpha = opponentExile->alpha = opponentLibrary->alpha = opponentHand->alpha = 0; opponent->zoom = 0.9f; active = NULL; } @@ -87,7 +93,7 @@ void GuiAvatars::Deactivate(PlayGuiObject* c) int GuiAvatars::receiveEventPlus(WEvent* e) { - return selfGraveyard->receiveEventPlus(e) | selfExile->receiveEventPlus(e) | opponentGraveyard->receiveEventPlus(e) | opponentHand->receiveEventPlus(e); + return selfGraveyard->receiveEventPlus(e) | selfExile->receiveEventPlus(e) | opponentExile->receiveEventPlus(e) | opponentGraveyard->receiveEventPlus(e) | opponentHand->receiveEventPlus(e); } int GuiAvatars::receiveEventMinus(WEvent* e) @@ -95,6 +101,7 @@ int GuiAvatars::receiveEventMinus(WEvent* e) selfGraveyard->receiveEventMinus(e); selfExile->receiveEventMinus(e); opponentGraveyard->receiveEventMinus(e); + opponentExile->receiveEventMinus(e); opponentHand->receiveEventMinus(e); return 1; } @@ -111,6 +118,8 @@ bool GuiAvatars::CheckUserInput(JButton key) return true; if (opponentGraveyard->CheckUserInput(key)) return true; + if (opponentExile->CheckUserInput(key)) + return true; if (opponentHand->CheckUserInput(key)) return true; if (selfLibrary->CheckUserInput(key)) @@ -128,6 +137,7 @@ void GuiAvatars::Update(float dt) selfExile->Update(dt); opponentHand->Update(dt); opponentGraveyard->Update(dt); + opponentExile->Update(dt); selfLibrary->Update(dt); opponentLibrary->Update(dt); } diff --git a/projects/mtg/src/GuiStatic.cpp b/projects/mtg/src/GuiStatic.cpp index c7eb7e795..04506ead0 100644 --- a/projects/mtg/src/GuiStatic.cpp +++ b/projects/mtg/src/GuiStatic.cpp @@ -164,7 +164,10 @@ void GuiGameZone::Render() JQuadPtr quad = WResourceManager::Instance()->GetQuad(kGenericCardThumbnailID); float scale = defaultHeight / quad->mHeight; quad->SetColor(ARGB((int)(actA),255,255,255)); - + if(type == GUI_EXILE) + { + quad->SetColor(ARGB((int)(actA),150,150,150)); + } JRenderer::GetInstance()->RenderQuad(quad.get(), actX, actY, 0.0, scale * actZ, scale * actZ); float x0 = actX; @@ -182,7 +185,16 @@ void GuiGameZone::Render() mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); char buffer[11]; int mAlpha = (int) (actA); - sprintf(buffer, "%i", zone->nb_cards); + /*if(type == GUI_GRAVEYARD) + sprintf(buffer, "%i\ng", zone->nb_cards); + else if(type == GUI_LIBRARY) + sprintf(buffer, "%i\nl", zone->nb_cards); + else if(type == GUI_OPPONENTHAND) + sprintf(buffer, "%i\nh", zone->nb_cards); + else if(type == GUI_EXILE) + sprintf(buffer, "%i\ne", zone->nb_cards); + else*/ + sprintf(buffer, "%i", zone->nb_cards); mFont->SetColor(ARGB(mAlpha,0,0,0)); mFont->DrawString(buffer, x0 + 1, actY + 1); if (actA > 120) diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 92007d42a..af7a2b667 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -558,8 +558,8 @@ int AbilityFactory::countCards(TargetChooser * tc, Player * player, int option) { if (player && player != observer->players[i]) continue; - MTGGameZone * zones[] = { observer->players[i]->game->inPlay, observer->players[i]->game->graveyard, observer->players[i]->game->hand }; - for (int k = 0; k < 3; k++) + MTGGameZone * zones[] = { observer->players[i]->game->inPlay, observer->players[i]->game->graveyard, observer->players[i]->game->hand, observer->players[i]->game->exile }; + for (int k = 0; k < 4; k++) { for (int j = zones[k]->nb_cards - 1; j >= 0; j--) { @@ -3412,6 +3412,7 @@ MTGAbility * AbilityFactory::parsePhaseActionAbility(string s,MTGCardInstance * bool opponentturn = (s1.find("my") == string::npos); bool myturn = (s1.find("opponent") == string::npos); bool sourceinPlay = (s1.find("sourceinplay") != string::npos); + bool checkexile = (s1.find("checkex") != string::npos); bool next = (s1.find("next") == string::npos); //Why is this one the opposite of the two others? That's completely inconsistent bool once = (s1.find("once") != string::npos); @@ -3420,7 +3421,7 @@ MTGAbility * AbilityFactory::parsePhaseActionAbility(string s,MTGCardInstance * _target = spell->getNextCardTarget(); if(!_target) _target = target; - return NEW APhaseActionGeneric(observer, id, card,_target, trim(splitActions[2]), restrictions, phase,sourceinPlay,next,myturn,opponentturn,once); + return NEW APhaseActionGeneric(observer, id, card,_target, trim(splitActions[2]), restrictions, phase,sourceinPlay,next,myturn,opponentturn,once,checkexile); } MTGAbility * AbilityFactory::parseChooseActionAbility(string s,MTGCardInstance * card,Spell *,MTGCardInstance * target, int, int id) @@ -5257,8 +5258,8 @@ void ListMaintainerAbility::updateTargets() for (int i = 0; i < 2; i++) { Player * p = game->players[i]; - MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack }; - for (int k = 0; k < 5; k++) + MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile }; + for (int k = 0; k < 6; k++) { MTGGameZone * zone = zones[k]; if (canTarget(zone)) @@ -5329,8 +5330,8 @@ void ListMaintainerAbility::checkTargets() for (int i = 0; i < 2; i++) { Player * p = game->players[i]; - MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack }; - for (int k = 0; k < 5; k++) + MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile }; + for (int k = 0; k < 6; k++) { MTGGameZone * zone = zones[k]; if (canTarget(zone)) diff --git a/projects/mtg/src/Rules.cpp b/projects/mtg/src/Rules.cpp index adf7ff8a3..e5f095454 100644 --- a/projects/mtg/src/Rules.cpp +++ b/projects/mtg/src/Rules.cpp @@ -79,8 +79,8 @@ MTGCardInstance * Rules::getCardByMTGId(GameObserver* g, int mtgid) for (int i = 0; i < 2; i++) { Player * p = g->players[i]; - MTGGameZone * zones[] = { p->game->library, p->game->hand, p->game->inPlay, p->game->graveyard }; - for (int j = 0; j < 4; j++) + MTGGameZone * zones[] = { p->game->library, p->game->hand, p->game->inPlay, p->game->graveyard, p->game->exile }; + for (int j = 0; j < 5; j++) { MTGGameZone * zone = zones[j]; for (int k = 0; k < zone->nb_cards; k++) @@ -340,9 +340,10 @@ MTGDeck * Rules::buildDeck(int playerId) MTGGameZone * loadedPlayerZones[] = { initState.playerData[playerId].player->game->graveyard, initState.playerData[playerId].player->game->library, initState.playerData[playerId].player->game->hand, - initState.playerData[playerId].player->game->inPlay }; + initState.playerData[playerId].player->game->inPlay, + initState.playerData[playerId].player->game->exile }; - for (int j = 0; j < 4; j++) + for (int j = 0; j < 5; j++) { for (size_t k = 0; k < loadedPlayerZones[j]->cards.size(); k++) { @@ -412,12 +413,13 @@ void Rules::initGame(GameObserver *g, bool currentPlayerSet) { p->mAvatarName = initState.playerData[i].player->mAvatarName; } - MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay }; + MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->exile }; MTGGameZone * loadedPlayerZones[] = { initState.playerData[i].player->game->graveyard, initState.playerData[i].player->game->library, initState.playerData[i].player->game->hand, - initState.playerData[i].player->game->inPlay }; - for (int j = 0; j < 4; j++) + initState.playerData[i].player->game->inPlay, + initState.playerData[i].player->game->exile }; + for (int j = 0; j < 5; j++) { MTGGameZone * zone = playerZones[j]; for (size_t k = 0; k < loadedPlayerZones[j]->cards.size(); k++) diff --git a/projects/mtg/src/TestSuiteAI.cpp b/projects/mtg/src/TestSuiteAI.cpp index bb7e236ce..beab3ded7 100644 --- a/projects/mtg/src/TestSuiteAI.cpp +++ b/projects/mtg/src/TestSuiteAI.cpp @@ -46,8 +46,8 @@ MTGCardInstance * TestSuiteAI::getCard(string action) for (int i = 0; i < 2; i++) { Player * p = observer->players[i]; - MTGGameZone * zones[] = { p->game->library, p->game->hand, p->game->inPlay, p->game->graveyard }; - for (int j = 0; j < 4; j++) + MTGGameZone * zones[] = { p->game->library, p->game->hand, p->game->inPlay, p->game->graveyard, p->game->exile }; + for (int j = 0; j < 5; j++) { MTGGameZone * zone = zones[j]; for (int k = 0; k < zone->nb_cards; k++) @@ -394,12 +394,13 @@ void TestSuiteGame::assertGame() error++; } - MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay }; + MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->exile }; MTGGameZone * endstateZones[] = { endState.players[i]->game->graveyard, endState.players[i]->game->library, endState.players[i]->game->hand, - endState.players[i]->game->inPlay }; - for (int j = 0; j < 4; j++) + endState.players[i]->game->inPlay, + endState.players[i]->game->exile }; + for (int j = 0; j < 5; j++) { MTGGameZone * zone = playerZones[j]; if (zone->nb_cards != endstateZones[j]->nb_cards) @@ -853,12 +854,13 @@ void TestSuiteGame::initGame() stringstream stream; stream << initState.players[i]->getRandomGenerator()->saveLoadedRandValues(stream); p->getRandomGenerator()->loadRandValues(stream.str()); - MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay }; + MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->exile }; MTGGameZone * loadedPlayerZones[] = { initState.players[i]->game->graveyard, initState.players[i]->game->library, initState.players[i]->game->hand, - initState.players[i]->game->inPlay }; - for (int j = 0; j < 4; j++) + initState.players[i]->game->inPlay, + initState.players[i]->game->exile }; + for (int j = 0; j < 5; j++) { MTGGameZone * zone = playerZones[j]; for (size_t k = 0; k < loadedPlayerZones[j]->cards.size(); k++) @@ -910,9 +912,10 @@ MTGPlayerCards * TestSuiteGame::buildDeck(Player* player, int playerId) MTGGameZone * loadedPlayerZones[] = { initState.players[playerId]->game->graveyard, initState.players[playerId]->game->library, initState.players[playerId]->game->hand, + initState.players[playerId]->game->exile, initState.players[playerId]->game->inPlay }; - for (int j = 0; j < 4; j++) + for (int j = 0; j < 5; j++) { for (size_t k = 0; k < loadedPlayerZones[j]->cards.size(); k++) {