From a376e8110b0fd5fcb2e281b69a4f2f021cc3a224 Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew@gmail.com" Date: Mon, 20 Jul 2009 03:35:26 +0000 Subject: [PATCH] Erwan -added "this" as valid target (still needs some work) see cathodion - Added mythic rares in boosters --- projects/mtg/bin/Res/sets/MRD/_cards.dat | 12 ++++++++++++ projects/mtg/bin/Res/test/_tests.txt | 1 + projects/mtg/bin/Res/test/cathodion.txt | 21 +++++++++++++++++++++ projects/mtg/include/TargetChooser.h | 19 ++++++++++--------- projects/mtg/src/MTGAbility.cpp | 3 ++- projects/mtg/src/MTGDeck.cpp | 5 ++++- projects/mtg/src/ShopItem.cpp | 6 ++++-- projects/mtg/src/TargetChooser.cpp | 18 ++++++++++++------ 8 files changed, 66 insertions(+), 19 deletions(-) create mode 100644 projects/mtg/bin/Res/test/cathodion.txt diff --git a/projects/mtg/bin/Res/sets/MRD/_cards.dat b/projects/mtg/bin/Res/sets/MRD/_cards.dat index aee35cea1..8ec426934 100644 --- a/projects/mtg/bin/Res/sets/MRD/_cards.dat +++ b/projects/mtg/bin/Res/sets/MRD/_cards.dat @@ -91,6 +91,18 @@ toughness=3 subtype=Gnome [/card] [card] +text=When Cathodion is put into a graveyard from play, add {3} to your mana pool. +auto=@movedTo(this|graveyard):Add{3} +id=48195 +name=Cathodion +rarity=U +type=Artifact Creature +mana={3} +power=3 +subtype=Construct +toughness=3 +[/card] +[card] text=Cloudpost comes into play tapped. {T}: Add {1} to your mana pool for each Locus in play. auto=tap auto={T}:foreach(Locus)add:{1} diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 0fae06841..6e112ea26 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -47,6 +47,7 @@ bottle_gnomes.txt boggart_arsonists.txt brass_man.txt castle.txt +cathodion.txt celestial_purge.txt circle_of_protection.txt clone.txt diff --git a/projects/mtg/bin/Res/test/cathodion.txt b/projects/mtg/bin/Res/test/cathodion.txt new file mode 100644 index 000000000..d35c6bd15 --- /dev/null +++ b/projects/mtg/bin/Res/test/cathodion.txt @@ -0,0 +1,21 @@ +#Testing Cathodion: +# text=When Cathodion is put into a graveyard from play, add {3} to your mana pool. +[INIT] +FIRSTMAIN +[PLAYER1] +hand:lightning bolt +manapool:{R} +[PLAYER2] +inplay:cathodion +[DO] +lightning bolt +cathodion +[ASSERT] +FIRSTMAIN +[PLAYER1] +graveyard:lightning bolt +manapool:{0} +[PLAYER2] +graveyard:cathodion +manapool:{3} +[END] \ No newline at end of file diff --git a/projects/mtg/include/TargetChooser.h b/projects/mtg/include/TargetChooser.h index 6d388f215..e2cd76a74 100644 --- a/projects/mtg/include/TargetChooser.h +++ b/projects/mtg/include/TargetChooser.h @@ -53,15 +53,6 @@ class TargetChooserFactory{ }; -class CardTargetChooser:public TargetChooser { - -protected: - MTGCardInstance * validTarget; -public: - CardTargetChooser(MTGCardInstance * _card, MTGCardInstance * source); - virtual int canTarget(Targetable * target ); -}; - class TargetZoneChooser:public TargetChooser{ public: @@ -74,6 +65,16 @@ class TargetZoneChooser:public TargetChooser{ virtual int canTarget(Targetable * _card); }; +class CardTargetChooser:public TargetZoneChooser { + +protected: + MTGCardInstance * validTarget; +public: + CardTargetChooser(MTGCardInstance * _card, MTGCardInstance * source,int * _zones = NULL, int _nbzones = 0); + virtual int canTarget(Targetable * target ); +}; + + class CreatureTargetChooser:public TargetZoneChooser{ public: int maxpower; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index b1fd3b22b..b6e4032fd 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2408,7 +2408,8 @@ int GenericTriggeredAbility::resolve(){ } int GenericTriggeredAbility::testDestroy(){ - if (destroyCondition) return destroyCondition->testDestroy(); + if (!TriggeredAbility::testDestroy()) return 0; + if (destroyCondition) return (destroyCondition->testDestroy()); return t->testDestroy(); } diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index ea025bbbb..0f794926e 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -465,7 +465,10 @@ int MTGDeck::addRandomCards(int howmany, int setId, int rarity, const char * _su } } } - if (subtotal == 0) return 0; + if (subtotal == 0){ + if (rarity == Constants::RARITY_M) return addRandomCards(howmany, setId, Constants::RARITY_R, _subtype, colors, nbcolors); + return 0; + } for (int i = 0; i < howmany; i++){ int id = (rand() % subtotal); add(subcollection[id]); diff --git a/projects/mtg/src/ShopItem.cpp b/projects/mtg/src/ShopItem.cpp index 24c36ee01..1c60168f9 100644 --- a/projects/mtg/src/ShopItem.cpp +++ b/projects/mtg/src/ShopItem.cpp @@ -253,8 +253,10 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){ display = NEW CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5); MTGDeck * tempDeck = NEW MTGDeck(NULL,playerdata->collection->database); - - tempDeck->addRandomCards(1, setIds[showPriceDialog],Constants::RARITY_R); + int rare_or_mythic = Constants::RARITY_R; + int rnd = rand() % 8; + if (rnd == 0) rare_or_mythic = Constants::RARITY_M; + tempDeck->addRandomCards(1, setIds[showPriceDialog],rare_or_mythic); tempDeck->addRandomCards(3, setIds[showPriceDialog],Constants::RARITY_U); tempDeck->addRandomCards(11, setIds[showPriceDialog],Constants::RARITY_C); playerdata->collection->add(tempDeck); diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index d40c359e0..efaeaee80 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -183,7 +183,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta typeName = typeName.substr(0,found); } //X targets allowed ? - if (typeName.at(typeName.length()-1) == 's' && !Subtypes::subtypesList->find(typeName)){ + if (typeName.at(typeName.length()-1) == 's' && !Subtypes::subtypesList->find(typeName) && typeName.compare("this")!=0){ typeName = typeName.substr(0,typeName.length()-1); maxtargets = -1; } @@ -200,6 +200,8 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta if (!tc){ if (typeName.compare("*")==0){ return NEW TargetZoneChooser(zones, nbzones,card, maxtargets); + }else if (typeName.compare("this")==0){ + return NEW CardTargetChooser(card,card,zones, nbzones); }else{ tc = NEW TypeTargetChooser(typeName.c_str(), zones, nbzones, card,maxtargets); } @@ -334,15 +336,19 @@ int TargetChooser::targetListSet(){ /** a specific Card **/ -CardTargetChooser::CardTargetChooser(MTGCardInstance * _card, MTGCardInstance * source):TargetChooser(source){ +CardTargetChooser::CardTargetChooser(MTGCardInstance * _card, MTGCardInstance * source,int * _zones, int _nbzones):TargetZoneChooser(_zones,_nbzones,source){ validTarget = _card; } int CardTargetChooser::canTarget(Targetable * target ){ - if (!TargetChooser::canTarget(target)) return 0; - if (target->typeAsTarget() == TARGET_CARD){ - MTGCardInstance * card = (MTGCardInstance *) target; - if (card == validTarget) return 1; + if (!target) return 0; + if (target->typeAsTarget() != TARGET_CARD) return 0; + if (!nbzones && !TargetChooser::canTarget(target)) return 0; + if (nbzones && !TargetZoneChooser::canTarget(target)) return 0; + MTGCardInstance * card = (MTGCardInstance *) target; + while(card){ + if(card == validTarget) return 1; + card = card->previous; } return 0; }