From a497ef49c8bb82320af39dcef05684bc0d4955d1 Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Thu, 15 Mar 2012 06:18:08 +0000 Subject: [PATCH] added support for doubling cube, recoded the curses to follow the rules better, with the exception of 1 which can not quite be supported Curse of Oblivion moved back to unsupported. added support for targeting a zone by targeting a player... any time you have targeted a player, you can access items in thier zones by using targetedpersonsZONE targetedpersonsbattlefield for example... added "targetedplayer" as a targetchooser and who. added "mycurses" targetchooser. added "targetedcurses" word variable. --- projects/mtg/include/AllAbilities.h | 63 +++------------------------- projects/mtg/include/MTGAbility.h | 3 +- projects/mtg/include/MTGGameZones.h | 6 +++ projects/mtg/include/Player.h | 1 + projects/mtg/include/TargetChooser.h | 22 +++++++++- projects/mtg/src/GameObserver.cpp | 7 ++++ projects/mtg/src/MTGAbility.cpp | 36 +++++++++++----- projects/mtg/src/MTGGameZones.cpp | 57 +++++++++++++++++-------- projects/mtg/src/TargetChooser.cpp | 37 +++++++++++++++- 9 files changed, 144 insertions(+), 88 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 317f81a49..c19867861 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -251,6 +251,11 @@ private: intValue = card->previous->previous->sunburst; } } + else if (s == "targetedcurses") + { + if(card->playerTarget) + intValue = card->playerTarget->curses.size(); + } else if (s == "lifetotal") { intValue = target->controller()->life; @@ -5100,64 +5105,6 @@ public: AARandomDiscarder * clone() const; }; -//Minion of Leshrac -class AMinionofLeshrac: public TargetAbility -{ -public: - int paidThisTurn; - AMinionofLeshrac(GameObserver* observer, int _id, MTGCardInstance * source) : - TargetAbility(observer, _id, source, NEW TypeTargetChooser(game, "creature"), 0, 1) - { - paidThisTurn = 1; - } - - void Update(float dt) - { - if (newPhase != currentPhase && source->controller() == game->currentPlayer) - { - if (newPhase == MTG_PHASE_UNTAP) - { - paidThisTurn = 0; - } - else if (newPhase == MTG_PHASE_UPKEEP + 1 && !paidThisTurn) - { - game->mLayers->stackLayer()->addDamage(source, source->controller(), 5); - source->tap(); - } - } - TargetAbility::Update(dt); - } - - int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL) - { - if (currentPhase != MTG_PHASE_UPKEEP || paidThisTurn) return 0; - return TargetAbility::isReactingToClick(card, mana); - } - - int resolve() - { - MTGCardInstance * card = tc->getNextCardTarget(); - if (card && card != source && card->controller() == source->controller()) - { - card->controller()->game->putInGraveyard(card); - paidThisTurn = 1; - return 1; - } - return 0; - } - - virtual ostream& toString(ostream& out) const - { - out << "AMinionofLeshrac ::: paidThisTurn : " << paidThisTurn << " ("; - return TargetAbility::toString(out) << ")"; - } - - AMinionofLeshrac * clone() const - { - return NEW AMinionofLeshrac(*this); - } -}; - //Rampage ability class ARampageAbility: public MTGAbility { diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 33c91539b..7f32ae897 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -516,7 +516,8 @@ public: string menutext; ManaCost * output; int tap; - AManaProducer(GameObserver* observer, int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); + string Producing; + AManaProducer(GameObserver* observer, int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost = NULL, int who = TargetChooser::UNSET,string producing = ""); int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL); int resolve(); int reactToClick(MTGCardInstance* _card); diff --git a/projects/mtg/include/MTGGameZones.h b/projects/mtg/include/MTGGameZones.h index 6780990a2..e4d69fb09 100644 --- a/projects/mtg/include/MTGGameZones.h +++ b/projects/mtg/include/MTGGameZones.h @@ -30,6 +30,7 @@ class MTGGameZone { TARGET_CONTROLLER_GRAVEYARD = 14, GRAVEYARD = 15, OWNER_GRAVEYARD = 16, + TARGETED_PLAYER_GRAVEYARD = 17, MY_BATTLEFIELD = 21, OPPONENT_BATTLEFIELD = 22, @@ -37,6 +38,7 @@ class MTGGameZone { TARGET_CONTROLLER_BATTLEFIELD = 24, BATTLEFIELD = 25, OWNER_BATTLEFIELD = 26, + TARGETED_PLAYER_BATTLEFIELD = 27, MY_HAND = 31, OPPONENT_HAND = 32, @@ -44,6 +46,7 @@ class MTGGameZone { TARGET_CONTROLLER_HAND = 34, HAND = 35, OWNER_HAND = 36, + TARGETED_PLAYER_HAND = 37, MY_EXILE = 41, OPPONENT_EXILE = 42, @@ -51,6 +54,7 @@ class MTGGameZone { TARGET_CONTROLLER_EXILE = 44, EXILE = 45, OWNER_EXILE = 46, + TARGETED_PLAYER_EXILE = 47, MY_LIBRARY = 51, OPPONENT_LIBRARY = 52, @@ -58,6 +62,7 @@ class MTGGameZone { TARGET_CONTROLLER_LIBRARY = 54, LIBRARY = 55, OWNER_LIBRARY = 56, + TARGETED_PLAYER_LIBRARY = 57, MY_STACK = 61, OPPONENT_STACK = 62, @@ -65,6 +70,7 @@ class MTGGameZone { TARGET_CONTROLLER_STACK = 64, STACK = 65, OWNER_STACK = 66, + TARGETED_PLAYER_STACK = 67, }; diff --git a/projects/mtg/include/Player.h b/projects/mtg/include/Player.h index cd5f520a6..a76f1add4 100644 --- a/projects/mtg/include/Player.h +++ b/projects/mtg/include/Player.h @@ -41,6 +41,7 @@ public: int offerInterruptOnPhase; int skippingTurn; int extraTurn; + vectorcurses; Player(GameObserver *observer, string deckFile, string deckFileSmall, MTGDeck * deck = NULL); virtual ~Player(); virtual void setObserver(GameObserver*g); diff --git a/projects/mtg/include/TargetChooser.h b/projects/mtg/include/TargetChooser.h index 12e8ab214..f0579f4bb 100644 --- a/projects/mtg/include/TargetChooser.h +++ b/projects/mtg/include/TargetChooser.h @@ -32,7 +32,8 @@ public: OPPONENT = -1, CONTROLLER = 1, TARGET_CONTROLLER = 2, - OWNER = 3 + OWNER = 3, + TARGETED_PLAYER = 4 }; bool other; bool withoutProtections; @@ -259,6 +260,25 @@ public: virtual bool equals(TargetChooser * tc); }; +class myCursesChooser: public TypeTargetChooser +{ +public: + bool withoutProtections; + myCursesChooser(GameObserver *observer, int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false) : + TypeTargetChooser(observer, "*",_zones, _nbzones, card, _maxtargets, other, targetMin) + { + } + ; + myCursesChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false,bool targetMin = false) : + TypeTargetChooser(observer, "*", card, _maxtargets, other,targetMin) + { + } + ; + virtual bool canTarget(Targetable * target, bool withoutProtections = false); + virtual myCursesChooser * clone() const; + virtual bool equals(TargetChooser * tc); +}; + class ParentChildChooser: public TypeTargetChooser { public: diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 730168e45..81d66f141 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -614,6 +614,7 @@ void GameObserver::gameStateBasedEffects() for (int i = 0; i < 2; i++) { MTGGameZone * zone = players[i]->game->inPlay; + players[i]->curses.clear(); for (int j = zone->nb_cards - 1; j >= 0; j--) { MTGCardInstance * card = zone->cards[j]; @@ -634,6 +635,10 @@ void GameObserver::gameStateBasedEffects() { card->target->enchanted = true; } + if (card->playerTarget && card->hasType("curse")) + { + card->playerTarget->curses.push_back(card); + } /////////////////////////// //reset extracost shadows// /////////////////////////// @@ -1263,6 +1268,8 @@ int GameObserver::cardClick(MTGCardInstance * card, Targetable * object, bool lo else { result = targetChooser->toggleTarget(clickedPlayer); + if(card) + card->playerTarget = clickedPlayer; } if (result == TARGET_OK_FULL) card = cardWaitingForTargets; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 5b6db92f7..1619e4cca 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -748,6 +748,8 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string magicText, int who = -1; if (s.find(" targetcontroller") != string::npos) who = -2; + if (s.find(" targetedplayer") != string::npos) + who = -3; //Next Time... found = s.find("next"); @@ -1747,6 +1749,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG who = TargetChooser::OPPONENT; if (s.find(" targetcontroller") != string::npos) who = TargetChooser::TARGET_CONTROLLER; + if (s.find(" targetedplayer") != string::npos) + who = TargetChooser::TARGETED_PLAYER; if (s.find(" owner") != string::npos) who = TargetChooser::OWNER; @@ -2512,7 +2516,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG { ManaCost * output = ManaCost::parseManaCost(s.substr(found),NULL,card); Targetable * t = spell ? spell->getNextTarget() : NULL; - MTGAbility * a = NEW AManaProducer(observer, id, card, t, output, NULL, who); + MTGAbility * a = NEW AManaProducer(observer, id, card, t, output, NULL, who,s.substr(found)); a->oneShot = 1; if(newName.size()) ((AManaProducer*)a)->menutext = newName; @@ -3649,13 +3653,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell) } break; } - //Addons ICE-AGE Cards - - case 2474: //Minion of Leshrac - { - observer->addObserver(NEW AMinionofLeshrac(observer, _id, card)); - break; - } case 2732: //Kjeldoran Frostbeast { @@ -4402,6 +4399,11 @@ int TargetAbility::resolve() //do nothing if the target controller responded by phasing out the target. if (dynamic_cast(t) && ((MTGCardInstance*)t)->isPhased) return 0; + Player * targetedPlyr = dynamic_cast(t); + if (targetedPlyr) + { + source->playerTarget = targetedPlyr; + } if (ability->oneShot) { while(t) @@ -4774,6 +4776,13 @@ TriggerAtPhase::TriggerAtPhase(GameObserver* observer, int id, MTGCardInstance * result = 1; } break; + case -3: + if (source->playerTarget) + { + if (game->currentPlayer == source->playerTarget) + result = 1; + } + break; default: result = 1; break; @@ -4965,14 +4974,14 @@ GenericTriggeredAbility* GenericTriggeredAbility::clone() const */ AManaProducer::AManaProducer(GameObserver* observer, int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost, - int who) : + int who,string producing) : ActivatedAbilityTP(observer, id, card, t, _cost, who) { aType = MTGAbility::MANA_PRODUCER; setCost(_cost); output = _output; - + Producing = producing; menutext = ""; } @@ -5028,6 +5037,9 @@ int AManaProducer::reactToClick(MTGCardInstance * _card) { WResourceManager::Instance()->PlaySample("mana.wav"); } + if(Producing.size()) + if(Producing.find("manapool") != string::npos)//unique card doubling cube. + output->copy(source->controller()->getManaPool()); return ActivatedAbility::activateAbility(); } @@ -5089,6 +5101,8 @@ Targetable * AbilityTP::getTarget() return source->controller()->opponent(); case TargetChooser::OWNER: return source->owner; + case TargetChooser::TARGETED_PLAYER: + return source->playerTarget; default: return target; } @@ -5114,6 +5128,8 @@ Targetable * ActivatedAbilityTP::getTarget() return source->controller()->opponent(); case TargetChooser::OWNER: return source->owner; + case TargetChooser::TARGETED_PLAYER: + return source->playerTarget; default: return target; } diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 20b770a6d..5823d00c8 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -881,7 +881,6 @@ MTGGameZone * MTGGameZone::intToZone(GameObserver *g, int zoneId, MTGCardInstanc MTGGameZone * result = intToZone(zoneId, p, p2); if (result) return result; - switch (zoneId) { case TARGET_OWNER_GRAVEYARD: @@ -890,11 +889,19 @@ MTGGameZone * MTGGameZone::intToZone(GameObserver *g, int zoneId, MTGCardInstanc return target->owner->game->graveyard; case OWNER_GRAVEYARD: return target->owner->game->graveyard; + case TARGETED_PLAYER_GRAVEYARD: + if(source->playerTarget) + return source->playerTarget->game->graveyard; + else return source->controller()->game->graveyard; case TARGET_OWNER_BATTLEFIELD: return target->owner->game->inPlay; case OWNER_BATTLEFIELD: return target->owner->game->inPlay; + case TARGETED_PLAYER_BATTLEFIELD: + if(source->playerTarget) + return source->playerTarget->game->inPlay; + else return source->controller()->game->inPlay; case TARGET_OWNER_HAND: return target->owner->game->hand; @@ -902,6 +909,10 @@ MTGGameZone * MTGGameZone::intToZone(GameObserver *g, int zoneId, MTGCardInstanc return target->owner->game->hand; case OWNER_HAND: return target->owner->game->hand; + case TARGETED_PLAYER_HAND: + if(source->playerTarget) + return source->playerTarget->game->hand; + else return source->controller()->game->hand; case TARGET_OWNER_EXILE: return target->owner->game->removedFromGame; @@ -909,16 +920,28 @@ MTGGameZone * MTGGameZone::intToZone(GameObserver *g, int zoneId, MTGCardInstanc return target->owner->game->removedFromGame; case OWNER_EXILE: return target->owner->game->removedFromGame; + case TARGETED_PLAYER_EXILE: + if(source->playerTarget) + return source->playerTarget->game->removedFromGame; + else return source->controller()->game->removedFromGame; case TARGET_OWNER_LIBRARY: return target->owner->game->library; case OWNER_LIBRARY: return target->owner->game->library; + case TARGETED_PLAYER_LIBRARY: + if(source->playerTarget) + return source->playerTarget->game->library; + else return source->controller()->game->library; case TARGET_OWNER_STACK: return target->owner->game->stack; case OWNER_STACK: return target->owner->game->stack; + case TARGETED_PLAYER_STACK: + if(source->playerTarget) + return source->playerTarget->game->stack; + else return source->controller()->game->stack; default: return NULL; } @@ -928,44 +951,44 @@ MTGGameZone * MTGGameZone::intToZone(GameObserver *g, int zoneId, MTGCardInstanc int MTGGameZone::zoneStringToId(string zoneName) { const char * strings[] = { "mygraveyard", "opponentgraveyard", "targetownergraveyard", "targetcontrollergraveyard", - "ownergraveyard", "graveyard", + "ownergraveyard", "graveyard","targetedpersonsgraveyard", - "myinplay", "opponentinplay", "targetownerinplay", "targetcontrollerinplay", "ownerinplay", "inplay", + "myinplay", "opponentinplay", "targetownerinplay", "targetcontrollerinplay", "ownerinplay", "inplay","targetedpersonsinplay", "mybattlefield", "opponentbattlefield", "targetownerbattlefield", "targetcontrollerbattlefield", - "ownerbattlefield", "battlefield", + "ownerbattlefield", "battlefield","targetedpersonsbattlefield", - "myhand", "opponenthand", "targetownerhand", "targetcontrollerhand", "ownerhand", "hand", + "myhand", "opponenthand", "targetownerhand", "targetcontrollerhand", "ownerhand", "hand","targetedpersonshand", - "mylibrary", "opponentlibrary", "targetownerlibrary", "targetcontrollerlibrary", "ownerlibrary", "library", + "mylibrary", "opponentlibrary", "targetownerlibrary", "targetcontrollerlibrary", "ownerlibrary", "library","targetedpersonslibrary", "myremovedfromgame", "opponentremovedfromgame", "targetownerremovedfromgame", - "targetcontrollerremovedfromgame", "ownerremovedfromgame", "removedfromgame", + "targetcontrollerremovedfromgame", "ownerremovedfromgame", "removedfromgame","targetedpersonsremovefromgame", - "myexile", "opponentexile", "targetownerexile", "targetcontrollerexile", "ownerexile", "exile", + "myexile", "opponentexile", "targetownerexile", "targetcontrollerexile", "ownerexile", "exile","targetedpersonsexile", - "mystack", "opponentstack", "targetownerstack", "targetcontrollerstack", "ownerstack", "stack", + "mystack", "opponentstack", "targetownerstack", "targetcontrollerstack", "ownerstack", "stack","targetedpersonsstack", }; int values[] = { MY_GRAVEYARD, OPPONENT_GRAVEYARD, TARGET_OWNER_GRAVEYARD, TARGET_CONTROLLER_GRAVEYARD, OWNER_GRAVEYARD, - GRAVEYARD, + GRAVEYARD,TARGETED_PLAYER_GRAVEYARD, MY_BATTLEFIELD, OPPONENT_BATTLEFIELD, TARGET_OWNER_BATTLEFIELD, TARGET_CONTROLLER_BATTLEFIELD, - OWNER_BATTLEFIELD, BATTLEFIELD, + OWNER_BATTLEFIELD, BATTLEFIELD,TARGETED_PLAYER_BATTLEFIELD, MY_BATTLEFIELD, OPPONENT_BATTLEFIELD, TARGET_OWNER_BATTLEFIELD, TARGET_CONTROLLER_BATTLEFIELD, - OWNER_BATTLEFIELD, BATTLEFIELD, + OWNER_BATTLEFIELD, BATTLEFIELD,TARGETED_PLAYER_BATTLEFIELD, - MY_HAND, OPPONENT_HAND, TARGET_OWNER_HAND, TARGET_CONTROLLER_HAND, OWNER_HAND, HAND, + MY_HAND, OPPONENT_HAND, TARGET_OWNER_HAND, TARGET_CONTROLLER_HAND, OWNER_HAND, HAND,TARGETED_PLAYER_HAND, - MY_LIBRARY, OPPONENT_LIBRARY, TARGET_OWNER_LIBRARY, TARGET_CONTROLLER_LIBRARY, OWNER_LIBRARY, LIBRARY, + MY_LIBRARY, OPPONENT_LIBRARY, TARGET_OWNER_LIBRARY, TARGET_CONTROLLER_LIBRARY, OWNER_LIBRARY, LIBRARY,TARGETED_PLAYER_LIBRARY, - MY_EXILE, OPPONENT_EXILE, TARGET_OWNER_EXILE, TARGET_CONTROLLER_EXILE, OWNER_EXILE, EXILE, + MY_EXILE, OPPONENT_EXILE, TARGET_OWNER_EXILE, TARGET_CONTROLLER_EXILE, OWNER_EXILE, EXILE,TARGETED_PLAYER_EXILE, - MY_EXILE, OPPONENT_EXILE, TARGET_OWNER_EXILE, TARGET_CONTROLLER_EXILE, OWNER_EXILE, EXILE, + MY_EXILE, OPPONENT_EXILE, TARGET_OWNER_EXILE, TARGET_CONTROLLER_EXILE, OWNER_EXILE, EXILE,TARGETED_PLAYER_EXILE, - MY_STACK, OPPONENT_STACK, TARGET_OWNER_STACK, TARGET_CONTROLLER_STACK, OWNER_STACK, STACK, }; + MY_STACK, OPPONENT_STACK, TARGET_OWNER_STACK, TARGET_CONTROLLER_STACK, OWNER_STACK, STACK,TARGETED_PLAYER_STACK }; int max = sizeof(values) / sizeof *(values); diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index 455be856a..8226f9700 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -82,11 +82,18 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta return NEW PlayerTargetChooser(observer, card, maxtargets); //Any player } + found = s.find("mycurses"); + if (found != string::npos) + { + int maxtargets = TargetChooser::UNLITMITED_TARGETS; + return NEW myCursesChooser(observer, card, maxtargets); + } + found = s.find("proliferation"); if (found != string::npos) { int maxtargets = TargetChooser::UNLITMITED_TARGETS; - return NEW ProliferateChooser(observer, card, maxtargets); //Any player + return NEW ProliferateChooser(observer, card, maxtargets); } string s1; @@ -1472,6 +1479,34 @@ bool TriggerTargetChooser::equals(TargetChooser * tc) return TargetChooser::equals(tc); } +/*my curses */ +bool myCursesChooser::canTarget(Targetable * target,bool withoutProtections) +{ + for(unsigned int i = 0;i < source->controller()->curses.size();++i) + { + MTGCardInstance * compare = source->controller()->curses[i]; + if(compare == dynamic_cast(target)) + return true; + } + return false; +} + +myCursesChooser* myCursesChooser::clone() const +{ + myCursesChooser * a = NEW myCursesChooser(*this); + return a; +} + +bool myCursesChooser::equals(TargetChooser * tc) +{ + + myCursesChooser * dtc = dynamic_cast (tc); + if (!dtc) + return false; + + return TypeTargetChooser::equals(tc); +} + /*Proliferate Target */ bool ProliferateChooser::canTarget(Targetable * target,bool withoutProtections) {