From 7303c7c2538b3f5731a0c7f9a364464d14e18dbd Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 2 Nov 2015 00:15:58 +0800 Subject: [PATCH 01/22] chooseacolor indicator on some cards alias = 0000 plus chooseacolor ability... --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 25 ++++++++++++++++++-- projects/mtg/src/CardGui.cpp | 16 +++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 5f633d64b..bfe4741ba 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -16540,6 +16540,7 @@ toughness=2 [/card] [card] name=Cho-Manno's Blessing +alias=0000 abilities=auraward target=creature abilities=flash @@ -18133,6 +18134,7 @@ type=Artifact [/card] [card] name=Coldsteel Heart +alias=0000 auto=tap auto=chooseacolor {T}:add{chosencolor} chooseend text=Coldsteel Heart enters the battlefield tapped. -- As Coldsteel Heart enters the battlefield, choose a color. -- {T}: Add one mana of the chosen color to your mana pool. @@ -21040,6 +21042,7 @@ subtype=Aura Curse [/card] [card] name=Curse of Wizardry +alias=0000 auto=chooseacolor transforms((,newability[@movedto(*[chosencolor]|mystack):life:-1 controller],newability[@movedto(*[chosencolor]|opponentstack):life:-1 opponent])) chooseend text=As Curse of Wizardry enters the battlefield, choose a color. -- Whenever a player casts a spell of the chosen color, that player loses 1 life. mana={2}{B}{B} @@ -35093,6 +35096,7 @@ toughness=2 [/card] [card] name=Flickering Ward +alias=0000 abilities=auraward target=creature auto=chooseacolor teach(creature) protection from(*[chosencolor]) chooseend @@ -35171,6 +35175,7 @@ toughness=2 [/card] [card] name=Floating Shield +alias=0000 abilities=auraward target=creature auto=chooseacolor teach(creature) protection from(*[chosencolor]) chooseend @@ -43565,6 +43570,7 @@ toughness=3 [/card] [card] name=Hall of Triumph +alias=0000 auto=activatechooseacolor transforms((,newability[lord(creature[chosencolor]|mybattlefield) 1/1])) forever activatechooseend text=As Hall of Triumph enters the battlefield, choose a color. -- Creatures you control of the chosen color get +1/+1. mana={3} @@ -49384,6 +49390,7 @@ type=Sorcery [/card] [card] name=Iona, Shield of Emeria +alias=0000 abilities=flying auto=chooseacolor maxCast(*[chosencolor])0 opponent chooseend text=Flying -- As Iona, Shield of Emeria enters the battlefield, choose a color. -- Your opponents can't cast spells of the chosen color. @@ -50520,6 +50527,7 @@ toughness=3 [/card] [card] name=Jihad +alias=0000 auto=chooseacolor transforms((,newability[aslongas(*[chosencolor]|opponentbattlefield) lord(creature[white]|mybattlefield) 2/1],newability[aslongas(*[chosencolor]|opponentbattlefield) sacrifice <1])) chooseend text=As Jihad enters the battlefield, choose a color and an opponent. -- White creatures get +2/+1 as long as the chosen player controls a nontoken permanent of the chosen color. -- When the chosen player controls no nontoken permanents of the chosen color, sacrifice Jihad. mana={W}{W}{W} @@ -54796,7 +54804,7 @@ toughness=2 [/card] [card] name=Kytheon's Irregulars -auto=auto={W}{W}:tap target(creature) +auto={W}{W}:tap target(creature) auto=this(cantargetcard(*[-renown]) transforms((,newability[@combatdamaged(player) from(this):counter(1/1) && becomes(renown) forever])) text=Renown 1 (When this creature deals combat damage to a player, if it isn't renowned, put a +1/+1 counter on it and it becomes renowned.) -- {W}{W}: Tap target creature. mana={2}{W}{W} @@ -58209,6 +58217,7 @@ type=Instant [/card] [card] name=Lurebound Scarecrow +alias=0000 auto=chooseacolor aslongas(*[chosencolor]|myBattlefield) sacrifice <1 chooseend text=As Lurebound Scarecrow enters the battlefield, choose a color. -- When you control no permanents of the chosen color, sacrifice Lurebound Scarecrow. mana={3} @@ -70832,6 +70841,7 @@ subtype=Equipment [/card] [card] name=Paradise Plume +alias=0000 auto=chooseacolor transforms((,newability[{T}:add{chosencolor}],newability[@movedto(*[chosencolor]|stack):life:1 controller])) forever chooseend text=As Paradise Plume enters the battlefield, choose a color. -- Whenever a player casts a spell of the chosen color, you may gain 1 life. -- {T}: Add one mana of the chosen color to your mana pool. mana={4} @@ -71623,6 +71633,7 @@ type=Artifact [/card] [card] name=Pentarch Paladin +alias=0000 abilities=flanking auto=chooseacolor {W}{W}{T}:destroy target(*[chosencolor]) chooseend text=Flanking (Whenever a creature without flanking blocks this creature, the blocking creature gets -1/-1 until end of turn.) -- As Pentarch Paladin enters the battlefield, choose a color. -- {W}{W}, {T}: Destroy target permanent of the chosen color. @@ -71634,6 +71645,7 @@ toughness=3 [/card] [card] name=Pentarch Ward +alias=0000 abilities=auraward target=creature auto=chooseacolor teach(creature) protection from(*[chosencolor]) chooseend @@ -74770,7 +74782,8 @@ toughness=4 [/card] [card] name=Prism Ring -auto=auto=activatechooseacolor transforms((,newability[@movedto(*[chosencolor]|mystack):life:1 controller])) forever activatechooseend +alias=0000 +auto=activatechooseacolor transforms((,newability[@movedto(*[chosencolor]|mystack):life:1 controller])) forever activatechooseend text=As Prism Ring enters the battlefield, choose a color. -- Whenever you cast a spell of the chosen color, you gain 1 life. mana={1} type=Artifact @@ -75240,6 +75253,7 @@ toughness=2 [/card] [card] name=Psychic Allergy +alias=0000 auto=upcost[{S(island|mybattlefield)}{S(island|mybattlefield)}] sacrifice auto=chooseacolor transforms((,newability[@each opponent upkeep:damage:type:*[-token&chosencolor]:opponentbattlefield opponent])) chooseend text=As Psychic Allergy enters the battlefield, choose a color. -- At the beginning of each opponent's upkeep, Psychic Allergy deals X damage to that player, where X is the number of nontoken permanents of the chosen color he or she controls. -- At the beginning of your upkeep, destroy Psychic Allergy unless you sacrifice two Islands. @@ -76335,6 +76349,7 @@ toughness=1 [/card] [card] name=Quirion Elves +alias=0000 auto={T}:Add{G} auto=chooseacolor {T}:add{chosencolor} chooseend text=As Quirion Elves enters the battlefield, choose a color. -- {T}: Add {G} to your mana pool. -- {T}: Add one mana of the chosen color to your mana pool. @@ -87769,6 +87784,7 @@ toughness=2 [/card] [card] name=Shifting Sky +alias=0000 auto=chooseacolor lord(*[-land]) becomes(,chosencolor) chooseend text=As Shifting Sky enters the battlefield, choose a color. -- All nonland permanents are the chosen color. mana={2}{U} @@ -89053,6 +89069,7 @@ toughness=1 [/card] [card] name=Silhana Starfletcher +alias=0000 abilities=reach auto=activatechooseacolor {T}:add{chosencolor} activatechooseend text=Reach (This creature can block creatures with flying.) -- As Silhana Starfletcher enters the battlefield, choose a color. -- {T}: Add one mana of the chosen color to your mana pool. @@ -91990,6 +92007,7 @@ toughness=3 [/card] [card] name=Sol Grail +alias=0000 auto=chooseacolor transforms((,newability[{T}:add{chosencolor}])) forever chooseend text=As Sol Grail enters the battlefield, choose a color. -- {T}: Add one mana of the chosen color to your mana pool. mana={3} @@ -100081,6 +100099,7 @@ type=Legendary Land [/card] [card] name=Teferi's Moat +alias=0000 auto=chooseacolor lord(creature[chosencolor&-flying]|opponentBattlefield) cantattack chooseend text=As Teferi's Moat enters the battlefield, choose a color. -- Creatures of the chosen color without flying can't attack you. mana={3}{W}{U} @@ -109849,6 +109868,7 @@ toughness=2 [/card] [card] name=Voice of All +alias=0000 abilities=flying auto=chooseacolor transforms((,newability[protection from(*[chosencolor])],newability[0/0])) forever chooseend text=Flying (This creature can't be blocked except by creatures with flying or reach.) -- As Voice of All enters the battlefield, choose a color. -- Voice of All has protection from the chosen color. (It can't be blocked, targeted, dealt damage, or enchanted by anything of the chosen color.) @@ -111655,6 +111675,7 @@ toughness=1 [/card] [card] name=Ward Sliver +alias=0000 auto=chooseacolor transforms((,newability[lord(sliver) protection from(*[chosencolor])])) forever chooseend text=As Ward Sliver enters the battlefield, choose a color. -- All Slivers have protection from the chosen color. mana={4}{W} diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index a9454f183..00fec3c32 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -364,8 +364,20 @@ void CardGui::Render() if(card->isToken && card->isACopier) buff = "CT"; if(!card->isToken && card->isACopier) - buff = "C"; - + buff = "C"; + if(card->alias == 0000) + { + if(card->chooseacolor == 1) + buff += "\n-Green"; + else if(card->chooseacolor == 2) + buff += "\n-Blue"; + else if(card->chooseacolor == 3) + buff += "\n-Red"; + else if(card->chooseacolor == 4) + buff += "\n-Black"; + else if(card->chooseacolor == 5) + buff += "\n-White"; + } if(!alternate && buff != "" && game->gameType() == GAME_TYPE_CLASSIC)//it seems that other game modes makes cards as tokens!!! hmmm... { mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); From 7ffab1a8212e1cd835d0d5a1debbf402dbb35838 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 2 Nov 2015 12:21:35 +0800 Subject: [PATCH 02/22] moved activated copy cards to borderline the default function of copy function triggers abilities as it comes onto the battlefield, but these cards are already inplay with their copy abilities and the enters the battlefield abilities of the copied cards must not trigger. --- .../bin/Res/sets/primitives/borderline.txt | 47 +++++++++++++++++++ projects/mtg/bin/Res/sets/primitives/mtg.txt | 47 ------------------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/borderline.txt b/projects/mtg/bin/Res/sets/primitives/borderline.txt index 017a69c27..9d8f5a066 100644 --- a/projects/mtg/bin/Res/sets/primitives/borderline.txt +++ b/projects/mtg/bin/Res/sets/primitives/borderline.txt @@ -69,6 +69,16 @@ mana={B} type=Sorcery [/card] [card] +name=Cemetery Puca +text=Whenever a creature is put into a graveyard from the battlefield, you may pay {1}. If you do, Cemetery Puca becomes a copy of that creature and gains this ability. +auto=@movedto(creature|graveyard) from(battlefield):all(trigger[from]) pay[[{1}]] copy +mana={1}{UB}{UB} +type=Creature +subtype=Shapeshifter +power=1 +toughness=2 +[/card] +[card] name=Cinder Seer auto={2}{r}{t}:target(creature,Player) damage:type:*[red]:myhand text={2}{R}, {T}: Reveal any number of red cards in your hand. Cinder Seer deals X damage to target creature or player, where X is the number of cards revealed this way. @@ -89,6 +99,16 @@ mana={1}{B}{G} type=Instant [/card] [card] +name=Cryptoplasm +auto=@each my upkeep:may copy target(other creature|battlefield) +text=At the beginning of your upkeep, you may have Cryptoplasm become a copy of another target creature. If you do, Cryptoplasm gains this ability. +mana={1}{U}{U} +type=Creature +subtype=Shapeshifter +power=2 +toughness=2 +[/card] +[card] name=Dark Withering abilities=madness autoexile=restriction{discarded} pay({B}) name(pay B to cast) activate name(pay B to cast) castcard(normal)?name(put in graveyard) moveto(ownergraveyard) @@ -99,6 +119,16 @@ mana={4}{B}{B} type=Instant [/card] [card] +name=Dimir Doppelganger +auto={1}{U}{B}:target(creature|graveyard) moveto(exile) and!(copy)! +text={1}{U}{B}: Exile target creature card from a graveyard. Dimir Doppelganger becomes a copy of that card and gains this ability. +mana={1}{U}{B} +type=Creature +subtype=Shapeshifter +power=0 +toughness=2 +[/card] +[card] name=Distortion Strike target=creature auto=1/0 @@ -462,6 +492,23 @@ type=Sorcery text=You gain 2 life. Then if you have more life than an opponent, draw a card. Rebound (If you cast this spell from your hand, exile it as it resolves. At the beginning of your next upkeep, you may cast this card from exile without paying its mana cost.) [/card] [card] +name=Thespian's Stage +auto={T}:Add{1} +auto={2}{T}:copy target(land|battlefield) +text={T}: Add {1} to your mana pool. -- {2}, {T}: Thespian's Stage becomes a copy of target land and gains this ability. +type=Land +[/card] +[card] +name=Unstable Shapeshifter +auto=@movedto(other creature|battlefield):all(trigger[from]) copy +text=Whenever another creature enters the battlefield, Unstable Shapeshifter becomes a copy of that creature and gains this ability. +mana={3}{U} +type=Creature +subtype=Shapeshifter +power=0 +toughness=1 +[/card] +[card] name=Virulent Swipe target=creature auto=2/0 diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index bfe4741ba..2cd71814f 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -15219,16 +15219,6 @@ power=0 toughness=5 [/card] [card] -name=Cemetery Puca -text=Whenever a creature is put into a graveyard from the battlefield, you may pay {1}. If you do, Cemetery Puca becomes a copy of that creature and gains this ability. -auto=@movedto(creature|graveyard) from(battlefield):all(trigger[from]) pay[[{1}]] copy -mana={1}{UB}{UB} -type=Creature -subtype=Shapeshifter -power=1 -toughness=2 -[/card] -[card] name=Cemetery Reaper auto=lord(other zombie|myBattlefield) 1/1 auto={2}{B}{T}:moveTo(Exile) target(creature|graveyard) && token(Zombie,Creature Zombie,2/2,black) @@ -20677,16 +20667,6 @@ power=0 toughness=0 [/card] [card] -name=Cryptoplasm -auto=@each my upkeep:may copy target(other creature|battlefield) -text=At the beginning of your upkeep, you may have Cryptoplasm become a copy of another target creature. If you do, Cryptoplasm gains this ability. -mana={1}{U}{U} -type=Creature -subtype=Shapeshifter -power=2 -toughness=2 -[/card] -[card] name=Cryptwailing auto={1}{E(creature|mygraveyard)}{E(creature|mygraveyard)}:target(player) ability$!name(discard) target(*|myhand) reject!$ targetedplayer asSorcery text={1}, Exile two creature cards from your graveyard: Target player discards a card. Activate this ability only any time you could cast a sorcery. @@ -24759,16 +24739,6 @@ power=2 toughness=2 [/card] [card] -name=Dimir Doppelganger -auto={1}{U}{B}:target(creature|graveyard) moveto(exile) and!(copy)! -text={1}{U}{B}: Exile target creature card from a graveyard. Dimir Doppelganger becomes a copy of that card and gains this ability. -mana={1}{U}{B} -type=Creature -subtype=Shapeshifter -power=0 -toughness=2 -[/card] -[card] name=Dimir Guildgate auto=tap auto={T}:add{U} @@ -101395,13 +101365,6 @@ mana={1}{G}{G} type=Sorcery [/card] [card] -name=Thespian's Stage -auto={T}:Add{1} -auto={2}{T}:copy target(land|battlefield) -text={T}: Add {1} to your mana pool. -- {2}, {T}: Thespian's Stage becomes a copy of target land and gains this ability. -type=Land -[/card] -[card] name=Thicket Basilisk auto=@combat(blocking,blocked) source(this) from(creature[-wall]):all(trigger[from]) phaseaction[combatends once] destroy text=Whenever Thicket Basilisk blocks or becomes blocked by a non-Wall creature, destroy that creature at end of combat. @@ -106654,16 +106617,6 @@ type=Enchantment subtype=Aura [/card] [card] -name=Unstable Shapeshifter -auto=@movedto(other creature|battlefield):all(trigger[from]) copy -text=Whenever another creature enters the battlefield, Unstable Shapeshifter becomes a copy of that creature and gains this ability. -mana={3}{U} -type=Creature -subtype=Shapeshifter -power=0 -toughness=1 -[/card] -[card] name=Unstoppable Ash abilities=trample auto=aslongas(other treefolk|mybattlefield) choice notatarget(other treefolk|mybattlefield) (blink)forsrc oneshot From 60ba4e3eebd67b1d1da35243edf9d23c0089a8dd Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Wed, 4 Nov 2015 06:41:59 +0800 Subject: [PATCH 03/22] altercost should affect retrace, flashback, buyback costs --- projects/mtg/include/GameObserver.h | 2 - projects/mtg/include/MTGAbility.h | 1 + projects/mtg/include/MTGCardInstance.h | 20 +++- projects/mtg/include/MTGDefinitions.h | 3 +- projects/mtg/include/MTGRules.h | 2 + projects/mtg/include/ManaCost.h | 3 +- projects/mtg/src/ActionStack.cpp | 2 +- projects/mtg/src/GameObserver.cpp | 125 +++++++++---------------- projects/mtg/src/MTGCardInstance.cpp | 2 - projects/mtg/src/MTGDefinitions.cpp | 3 +- projects/mtg/src/MTGRules.cpp | 6 +- 11 files changed, 73 insertions(+), 96 deletions(-) diff --git a/projects/mtg/include/GameObserver.h b/projects/mtg/include/GameObserver.h index 3771a3c27..25fcf745b 100644 --- a/projects/mtg/include/GameObserver.h +++ b/projects/mtg/include/GameObserver.h @@ -122,8 +122,6 @@ class GameObserver{ void gameStateBasedEffects(); void enchantmentStatus(); void Affinity(); - void ComputeTrinisphere(); - void RemoveTrinisphere(MTGCardInstance * card); void addObserver(MTGAbility * observer); bool removeObserver(ActionElement * observer); void startGame(GameType, Rules * rules); diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index b9ecfa8cf..876bb97e2 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -213,6 +213,7 @@ public: COUNTERS = 30, PUT_INTO_PLAY_WITH_KICKER = 31, STANDARD_FIZZLER = 32, + CASTINGRAVEYARD_COST = 33, }; }; diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 56c887459..9eb7a64da 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -253,9 +253,25 @@ public: int cardistargetted; bool isTargetter(); int cardistargetter; - int tmodifier; - int tmodifierb; int myconvertedcost; + ManaCost * computeNewCost(MTGCardInstance * card,ManaCost * oldCost) + { + if(card->isLand()) + return oldCost; + + if(!card) + return NULL; + //i don't know why this method doesn't affect cards in hand, but is working on other zones....// + //pay zero costs// + //kicker???...// + //morph cost todo// + //trinisphere must be here below// + if(card->has(Constants::TRINISPHERE)) + for(int jj = oldCost->getConvertedCost(); jj < 3; jj++) + oldCost->add(Constants::MTG_COLOR_ARTIFACT, 1); + + return oldCost; + }; void eventattacked(); void eventattackedAlone(); diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index cc45e19b2..a3df629bc 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -236,7 +236,8 @@ class Constants OPPGCREATUREEXILER = 118, PAYZERO = 119, TRINISPHERE = 120, - NB_BASIC_ABILITIES = 121, + CANPLAYFROMEXILE = 121, + NB_BASIC_ABILITIES = 122, RARITY_S = 'S', //Special Rarity diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index bd31cfc83..13be1c5b3 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -76,6 +76,8 @@ public: MTGPutInPlayRule(GameObserver* observer, int _id); const string getMenuText() { + if(game && game->gameType() == GAME_TYPE_MOMIR) + return "Play Land"; return "Cast Card Normally"; } virtual MTGPutInPlayRule * clone() const; diff --git a/projects/mtg/include/ManaCost.h b/projects/mtg/include/ManaCost.h index 9faea5806..bdc3868ab 100644 --- a/projects/mtg/include/ManaCost.h +++ b/projects/mtg/include/ManaCost.h @@ -47,7 +47,8 @@ public: MANA_PAID_WITH_FLASHBACK = 5, MANA_PAID_WITH_RETRACE = 6, MANA_PAID_WITH_MORPH = 7, - MANA_PAID_WITH_SUSPEND = 8 + MANA_PAID_WITH_SUSPEND = 8, + MANA_PAID_WITH_OTHERCOST = 9 }; ExtraCosts * extraCosts; diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index 5fd4c6f3c..88de3027b 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -301,7 +301,7 @@ bool Spell::FullfilledAlternateCost(const int &costType) hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_RETRACE); break; case ManaCost::MANA_PAID_WITH_SUSPEND: - hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_RETRACE); + hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_SUSPEND); break; } diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index a84429bd1..03bf15211 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -885,9 +885,6 @@ void GameObserver::gameStateBasedEffects() // plus modify costs // ///////////////////////////// Affinity(); - //trinisphere? buggy... - //ComputeTrinisphere(); - //end trinisphere ///////////////////////////////////// // Check colored statuses on cards // ///////////////////////////////////// @@ -979,10 +976,14 @@ void GameObserver::Affinity() //only do any of the following if a card with the stated ability is in your hand. ManaCost * original = NEW ManaCost(); ManaCost * alternate = NEW ManaCost(); + ManaCost * buyback = NEW ManaCost(); + ManaCost * flashback = NEW ManaCost(); + ManaCost * retrace = NEW ManaCost(); original->copy(card->model->data->getManaCost()); alternate->copy(card->model->data->getManaCost()->getAlternative()); - if (card->has(Constants::PAYZERO)) - original = ManaCost::parseManaCost("{0}",NULL,card);//can't figure out 2 or more alternative... + buyback->copy(card->model->data->getManaCost()->getBuyback()); + flashback->copy(card->model->data->getManaCost()->getFlashback()); + retrace->copy(card->model->data->getManaCost()->getRetrace()); //have to run alter cost before affinity or the 2 cancel each other out. if(card->getIncreasedManaCost()->getConvertedCost()||card->getReducedManaCost()->getConvertedCost()) { @@ -995,10 +996,22 @@ void GameObserver::Affinity() { alternate->add(kc,card->getIncreasedManaCost()->getCost(kc)); } + if (card->getManaCost()->getBuyback()) + { + buyback->add(kc,card->getIncreasedManaCost()->getCost(kc)); + } + if (card->getManaCost()->getFlashback()) + { + flashback->add(kc,card->getIncreasedManaCost()->getCost(kc)); + } + if (card->getManaCost()->getRetrace()) + { + retrace->add(kc,card->getIncreasedManaCost()->getCost(kc)); + } } } if(card->getReducedManaCost()->getConvertedCost()) - { + { original->remove(card->getReducedManaCost()); for(int kc = Constants::MTG_COLOR_ARTIFACT; kc < Constants::NB_Colors;kc++) { @@ -1006,12 +1019,30 @@ void GameObserver::Affinity() { alternate->remove(kc,card->getReducedManaCost()->getCost(kc)); } + if (card->getManaCost()->getBuyback()) + { + buyback->remove(kc,card->getIncreasedManaCost()->getCost(kc)); + } + if (card->getManaCost()->getFlashback()) + { + flashback->remove(kc,card->getIncreasedManaCost()->getCost(kc)); + } + if (card->getManaCost()->getRetrace()) + { + retrace->remove(kc,card->getIncreasedManaCost()->getCost(kc)); + } } } if(card->getManaCost()) card->getManaCost()->copy(original); if(card->getManaCost()->getAlternative()) - card->getManaCost()->setAlternative(alternate); + card->getManaCost()->setAlternative(alternate); + if(card->getManaCost()->getBuyback()) + card->getManaCost()->setBuyback(buyback); + if(card->getManaCost()->getFlashback()) + card->getManaCost()->setFlashback(flashback); + if(card->getManaCost()->getRetrace()) + card->getManaCost()->setRetrace(retrace); if(card->getManaCost()->extraCosts) { for(unsigned int i = 0; i < card->getManaCost()->extraCosts->costs.size();i++) @@ -1068,7 +1099,8 @@ void GameObserver::Affinity() card->has(Constants::AFFINITYISLAND)|| card->has(Constants::AFFINITYMOUNTAIN)|| card->has(Constants::AFFINITYPLAINS)|| - card->has(Constants::AFFINITYSWAMP)){ + card->has(Constants::AFFINITYSWAMP)) + { if (card->has(Constants::AFFINITYARTIFACTS)) { type = "artifact"; @@ -1123,86 +1155,13 @@ void GameObserver::Affinity() if(card->getManaCost()->getCost(color) > 0) card->getManaCost()->remove(color,1); } - - } - SAFE_DELETE(original); + } + //SAFE_DELETE(original); }//end } } } -void GameObserver::ComputeTrinisphere() -{ - for (int td = 0; td < 2; td++) - { - MTGGameZone * dzones[] = { players[td]->game->graveyard, players[td]->game->hand, players[td]->game->library, players[td]->game->exile }; - for (int tk = 0; tk < 4; tk++) - { - MTGGameZone * zone = dzones[tk]; - for (int ct = zone->nb_cards - 1; ct >= 0; ct--) - { - if(zone->cards[ct]->has(Constants::TRINISPHERE)) - { - if(zone->cards[ct]->getManaCost()->getConvertedCost() == 2) - { - zone->cards[ct]->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 1); - zone->cards[ct]->tmodifier = 1; - } - else if(zone->cards[ct]->getManaCost()->getConvertedCost() == 1) - { - zone->cards[ct]->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 2); - zone->cards[ct]->tmodifier = 2; - } - else if(zone->cards[ct]->getManaCost()->getConvertedCost() < 1) - { - zone->cards[ct]->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 3); - zone->cards[ct]->tmodifier = 3; - } - if(zone->cards[ct]->getManaCost()->getAlternative()) - { - ManaCost * currentAlternate = NEW ManaCost(); - currentAlternate->copy(zone->cards[ct]->getManaCost()->getAlternative()); - if(zone->cards[ct]->getManaCost()->getAlternative()->getConvertedCost() == 2) - zone->cards[ct]->tmodifierb = 1; - else if(zone->cards[ct]->getManaCost()->getAlternative()->getConvertedCost() == 1) - zone->cards[ct]->tmodifierb = 2; - else if(zone->cards[ct]->getManaCost()->getAlternative()->getConvertedCost() < 1) - zone->cards[ct]->tmodifierb = 3; - currentAlternate->add(Constants::MTG_COLOR_ARTIFACT, zone->cards[ct]->tmodifierb); - zone->cards[ct]->getManaCost()->setAlternative(currentAlternate); - } - } - else - RemoveTrinisphere(zone->cards[ct]); - if(zone->cards[ct]->getManaCost()->extraCosts) - { - for(unsigned int i = 0; i < zone->cards[ct]->getManaCost()->extraCosts->costs.size();i++) - { - zone->cards[ct]->getManaCost()->extraCosts->costs[i]->setSource(zone->cards[ct]); - } - } - } - } - } -} -void GameObserver::RemoveTrinisphere(MTGCardInstance * card) -{ - if(card->has(Constants::TRINISPHERE)) - return; - if(card->tmodifier) - { - card->getManaCost()->remove(Constants::MTG_COLOR_ARTIFACT, card->tmodifier); - card->tmodifier = 0; - } - if(card->getManaCost()->getAlternative() && card->tmodifierb) - { - ManaCost * newalternate = NEW ManaCost(); - newalternate->copy(card->getManaCost()->getAlternative()); - newalternate->remove(Constants::MTG_COLOR_ARTIFACT, card->tmodifierb); - card->getManaCost()->setAlternative(newalternate); - card->tmodifierb = 0; - } -} void GameObserver::Render() { if(mLayers) diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 02d5086fa..a70ef93b6 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -65,8 +65,6 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to LKItoughness = toughness; cardistargetted = 0; cardistargetter = 0; - tmodifier = 0; - tmodifierb = 0; myconvertedcost = getManaCost()->getConvertedCost(); } diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index a2530cdb4..dbeaca32d 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -149,7 +149,8 @@ const char* Constants::MTGBasicAbilities[] = { "mygcreatureexiler", "oppgcreatureexiler", "payzero", - "trinisphere" + "trinisphere", + "canplayfromexile" }; map Constants::MTGBasicAbilitiesMap; diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 458e63789..f1b14a941 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -1132,7 +1132,7 @@ MTGMorphCostRule * MTGMorphCostRule::clone() const MTGPlayFromGraveyardRule::MTGPlayFromGraveyardRule(GameObserver* observer, int _id) : MTGAlternativeCostRule(observer, _id) { - aType = MTGAbility::PUT_INTO_PLAY; + aType = MTGAbility::CASTINGRAVEYARD_COST; } int MTGPlayFromGraveyardRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) @@ -1155,9 +1155,9 @@ int MTGPlayFromGraveyardRule::reactToClick(MTGCardInstance * card) ManaCost * cost = card->getManaCost(); - card->paymenttype = MTGAbility::PUT_INTO_PLAY; + card->paymenttype = MTGAbility::CASTINGRAVEYARD_COST; - return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID); + return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID_WITH_OTHERCOST); } ostream& MTGPlayFromGraveyardRule::toString(ostream& out) const From 4f54e30e0ea97a77afac729132941b509bb8783d Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 5 Nov 2015 07:16:49 +0800 Subject: [PATCH 04/22] Libraryeater and Canplayfromexile extend canplayfromgraveyard with canplayfromexile libraryeater for undead alchemist --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 26 ++++++++++++++-- .../bin/Res/sets/primitives/unsupported.txt | 31 +++---------------- projects/mtg/include/MTGAbility.h | 2 +- projects/mtg/include/MTGDefinitions.h | 3 +- projects/mtg/include/MTGRules.h | 2 +- projects/mtg/src/Damage.cpp | 28 +++++++++++++++++ projects/mtg/src/MTGDefinitions.cpp | 3 +- projects/mtg/src/MTGRules.cpp | 8 ++--- 8 files changed, 67 insertions(+), 36 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 2cd71814f..257c81f05 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -99087,11 +99087,10 @@ text=Syphon Soul deals 2 damage to each other player. You gain life equal to the mana={2}{B} type=Sorcery [/card] -#workaround szadek. [card] name=Szadek, Lord of Secrets +alias=89092 abilities=flying -auto=@combatdamaged(player) from(this):deplete:thatmuch opponent && life:thatmuch opponent && counter(1/1,thatmuch) text=Flying -- If Szadek, Lord of Secrets would deal combat damage to a player, instead put that many +1/+1 counters on Szadek and that player puts that many cards from the top of his or her library into his or her graveyard. mana={3}{U}{U}{B}{B} type=Legendary Creature @@ -100972,6 +100971,18 @@ mana={3}{p(U)} type=Sorcery [/card] [card] +name=Thada Adel, Acquisitor +abilities=islandwalk +auto=@combatdamagefoeof(player) from(this):name(exile artifact) notatarget(artifact|opponentlibrary) moveto(myexile) and!( transforms((,newability[canplayfromexile],newability[phaseactionmulti[endofturn once] moveto(ownerexile) all(this|exile)])) ueot)! +auto=@combatdamageof(player) from(this):name(exile artifact) notatarget(artifact|mylibrary) moveto(myexile) and!( transforms((,newability[canplayfromexile],newability[phaseactionmulti[endofturn once] moveto(ownerexile) all(this|exile)])) ueot)! +text=Islandwalk -- Whenever Thada Adel, Acquisitor deals combat damage to a player, search that player's library for an artifact card and exile it. Then that player shuffles his or her library. Until end of turn, you may play that card. +mana={1}{U}{U} +type=Legendary Creature +subtype=Merfolk Rogue +power=2 +toughness=2 +[/card] +[card] name=Thalakos Deceiver abilities=shadow auto=@combat(notblocked) source(this):may moveTo(myBattlefield) target(creature|opponentBattlefield) && sacrifice all(this) @@ -106105,6 +106116,17 @@ type=Enchantment subtype=Aura [/card] [card] +name=Undead Alchemist +auto=lord(zombie|mybattlefield) libraryeater +auto=@movedTo(creature|opponentgraveyard) from(opponentlibrary):all(trigger[to]) moveto(exile) and!(token(Zombie,Creature Zombie,2/2,black) controller)! +text=If a Zombie you control would deal combat damage to a player, instead that player puts that many cards from the top of his or her library into his or her graveyard. -- Whenever a creature card is put into an opponent's graveyard from his or her library, exile that card and put a 2/2 black Zombie creature token onto the battlefield. +mana={3}{U} +type=Creature +subtype=Zombie +power=4 +toughness=2 +[/card] +[card] name=Undead Executioner auto=@movedto(this|graveyard) from(battlefield):may target(creature) -2/-2 ueot text=When Undead Executioner dies, you may have target creature get -2/-2 until end of turn. diff --git a/projects/mtg/bin/Res/sets/primitives/unsupported.txt b/projects/mtg/bin/Res/sets/primitives/unsupported.txt index 77ec526d5..6338488fa 100644 --- a/projects/mtg/bin/Res/sets/primitives/unsupported.txt +++ b/projects/mtg/bin/Res/sets/primitives/unsupported.txt @@ -13490,6 +13490,7 @@ subtype=Elemental power=3 toughness=2 [/card] +#seems possible [card] name=Roiling Horror text=Roiling Horror's power and toughness are each equal to your life total minus the life total of an opponent with the most life. -- Suspend X - {X}{B}{B}{B}. X can't be 0. (Rather than cast this card from your hand, you may pay {X}{B}{B}{B} and exile it with X time counters on it. At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost. It has haste.) -- Whenever a time counter is removed from Roiling Horror while it's exiled, target player loses 1 life and you gain 1 life. @@ -13939,6 +13940,7 @@ subtype=Giant Warrior power=4 toughness=5 [/card] +#modded ingest [card] name=Scalpelexis text=Flying (This creature can't be blocked except by creatures with flying or reach.) -- Whenever Scalpelexis deals combat damage to a player, that player exiles the top four cards of his or her library. If two or more of those cards have the same name, repeat this process. @@ -14093,6 +14095,7 @@ text=Look at the top X cards of target opponent's library. Exile one of those ca mana={X}{U}{B} type=Sorcery [/card] +#moverandom? [card] name=Search for Survivors text=Reorder your graveyard at random. An opponent chooses a card at random in your graveyard. If it's a creature card, put it onto the battlefield. Otherwise, exile it. @@ -14480,6 +14483,7 @@ mana={3}{U} type=Instant subtype=Arcane [/card] +#phaseactionmulti? [card] name=Shifty Doppelganger text={3}{U}, Exile Shifty Doppelganger: You may put a creature card from your hand onto the battlefield. If you do, that creature gains haste until end of turn. At the beginning of the next end step, sacrifice that creature. If you do, return Shifty Doppelganger to the battlefield. @@ -14944,6 +14948,7 @@ type=Enchantment subtype=Aura text=Enchant creature Enchanted creature gets +1/+1 and has "Whenever this creature deals damage to an opponent, you may draw a card." Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) [/card] +#manaflashback rule [card] name=Snapcaster Mage abilities=flash @@ -16224,12 +16229,6 @@ type=Sorcery text=Put a 1/1 colorless Expansion-Symbol creature token into play for each different expansion symbol among permanents you control. [/card] [card] -name=Syncopate -text=Counter target spell unless its controller pays {X}. If that spell is countered this way, exile it instead of putting it into its owner's graveyard. -mana={X}{U} -type=Instant -[/card] -[card] name=Synod Artificer text={X}, {T}: Tap X target noncreature artifacts. -- {X}, {T}: Untap X target noncreature artifacts. mana={2}{U} @@ -16490,15 +16489,6 @@ type=Planeswalker subtype=Tezzeret [/card] [card] -name=Thada Adel, Acquisitor -text=Islandwalk -- Whenever Thada Adel, Acquisitor deals combat damage to a player, search that player's library for an artifact card and exile it. Then that player shuffles his or her library. Until end of turn, you may play that card. -mana={1}{U}{U} -type=Legendary Creature -subtype=Merfolk Rogue -power=2 -toughness=2 -[/card] -[card] name=Thalakos Dreamsower text=Shadow (This creature can block or be blocked by only creatures with shadow.) -- You may choose not to untap Thalakos Dreamsower during your untap step. -- Whenever Thalakos Dreamsower deals damage to an opponent, tap target creature. That creature doesn't untap during its controller's untap step for as long as Thalakos Dreamsower remains tapped. mana={2}{U} @@ -17284,17 +17274,6 @@ mana={2}{U} type=Sorcery [/card] [card] -name=Undead Alchemist -auto=@combatdamaged(player) from(zombie|mybattlefield):deplete:thatmuch opponent && life:thatmuch opponent -auto=@movedTo(creature|opponentgraveyard) from(opponentlibrary):token(Zombie,Creature Zombie,2/2,black) -text=If a Zombie you control would deal combat damage to a player, instead that player puts that many cards from the top of his or her library into his or her graveyard. -- Whenever a creature card is put into an opponent's graveyard from his or her library, exile that card and put a 2/2 black Zombie creature token onto the battlefield. -mana={3}{U} -type=Creature -subtype=Zombie -power=4 -toughness=2 -[/card] -[card] name=Undercity Informer text={1}, Sacrifice a creature: Target player reveals cards from the top of his or her library until he or she reveals a land card, then puts those cards into his or her graveyard. mana={2}{B} diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 876bb97e2..af8cbbeee 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -213,7 +213,7 @@ public: COUNTERS = 30, PUT_INTO_PLAY_WITH_KICKER = 31, STANDARD_FIZZLER = 32, - CASTINGRAVEYARD_COST = 33, + CASTINGRAVEEXILE_COST = 33, }; }; diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index a3df629bc..c201679e4 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -237,7 +237,8 @@ class Constants PAYZERO = 119, TRINISPHERE = 120, CANPLAYFROMEXILE = 121, - NB_BASIC_ABILITIES = 122, + LIBRARYEATER = 122, + NB_BASIC_ABILITIES = 123, RARITY_S = 'S', //Special Rarity diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index 13be1c5b3..f99bdb7d4 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -184,7 +184,7 @@ public: MTGPlayFromGraveyardRule(GameObserver* observer, int _id); const string getMenuText() { - return "Cast Card From Graveyard"; + return "Cast Card From This Zone"; } virtual MTGPlayFromGraveyardRule * clone() const; }; diff --git a/projects/mtg/src/Damage.cpp b/projects/mtg/src/Damage.cpp index 3f6a329c9..3b677ff18 100644 --- a/projects/mtg/src/Damage.cpp +++ b/projects/mtg/src/Damage.cpp @@ -126,7 +126,35 @@ int Damage::resolve() } _target->doDamageTest = 1; } + if (target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER) + { + if(source->has(Constants::LIBRARYEATER) && typeOfDamage == 1) + { + for (int j = damage; j > 0; j--) + { + if(((Player*)target)->game->library->nb_cards) + ((Player*)target)->game->putInZone(((Player*)target)->game->library->cards[((Player*)target)->game->library->nb_cards - 1], ((Player*)target)->game->library, ((Player*)target)->game->graveyard); + } + damage = 0; + } + if(source->alias == 89092 && typeOfDamage == 1)//Szadek Lord of Secrets + { + for (int j = damage; j > 0; j--) + { + if(((Player*)target)->game->library->nb_cards) + ((Player*)target)->game->putInZone(((Player*)target)->game->library->cards[((Player*)target)->game->library->nb_cards - 1], ((Player*)target)->game->library, ((Player*)target)->game->graveyard); + source->counters->addCounter(1, 1); + } + damage = 0; + } + if (!damage) + { + state = RESOLVED_NOK; + delete (e); + return 0; + } + } int a = damage; if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE && (source->has(Constants::WITHER) || source->has( diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index dbeaca32d..a1645eb0a 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -150,7 +150,8 @@ const char* Constants::MTGBasicAbilities[] = { "oppgcreatureexiler", "payzero", "trinisphere", - "canplayfromexile" + "canplayfromexile", + "libraryeater" }; map Constants::MTGBasicAbilitiesMap; diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index f1b14a941..bb62985fd 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -1132,7 +1132,7 @@ MTGMorphCostRule * MTGMorphCostRule::clone() const MTGPlayFromGraveyardRule::MTGPlayFromGraveyardRule(GameObserver* observer, int _id) : MTGAlternativeCostRule(observer, _id) { - aType = MTGAbility::CASTINGRAVEYARD_COST; + aType = MTGAbility::CASTINGRAVEEXILE_COST; } int MTGPlayFromGraveyardRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) @@ -1140,9 +1140,9 @@ int MTGPlayFromGraveyardRule::isReactingToClick(MTGCardInstance * card, ManaCost Player * player = game->currentlyActing(); ManaCost * cost = card->getManaCost(); - if (!player->game->graveyard->hasCard(card)) + if (!player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card)) return 0; - if (!card->has(Constants::CANPLAYFROMGRAVEYARD)) + if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card))) return 0; return MTGAlternativeCostRule::isReactingToClick(card, mana, cost); @@ -1155,7 +1155,7 @@ int MTGPlayFromGraveyardRule::reactToClick(MTGCardInstance * card) ManaCost * cost = card->getManaCost(); - card->paymenttype = MTGAbility::CASTINGRAVEYARD_COST; + card->paymenttype = MTGAbility::CASTINGRAVEEXILE_COST; return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID_WITH_OTHERCOST); } From 536a0e429a887afbdbb22b0d8e63fdafedfb152d Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 5 Nov 2015 07:17:58 +0800 Subject: [PATCH 05/22] AI considers playing from exile and graveyard --- projects/mtg/src/AIPlayerBaka.cpp | 304 ++++++++++++++++++++++++++++++ projects/mtg/src/GameObserver.cpp | 2 +- projects/mtg/src/MTGAbility.cpp | 3 - 3 files changed, 305 insertions(+), 4 deletions(-) diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index d75616eaf..4c54c565d 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -627,6 +627,14 @@ int OrderedAIAction::getEfficiency() { efficiency += 65; } + else if (dynamic_cast(a)) + { + efficiency += 55; + } + else if (dynamic_cast(a)) + { + efficiency += 45; + } SAFE_DELETE(transAbility); return efficiency; } @@ -1726,6 +1734,302 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty cd.setType(type); card = NULL; gotPayments = vector(); + //canplayfromgraveyard + while ((card = cd.nextmatch(game->graveyard, card))&& card->has(Constants::CANPLAYFROMGRAVEYARD)) + { + if (!CanHandleCost(card->getManaCost(),card)) + continue; + + if (card->hasType(Subtypes::TYPE_LAND)) + { + if (game->playRestrictions->canPutIntoZone(card, game->inPlay) == PlayRestriction::CANT_PLAY) + continue; + } + else + { + if (game->playRestrictions->canPutIntoZone(card, game->stack) == PlayRestriction::CANT_PLAY) + continue; + } + + if (card->hasType(Subtypes::TYPE_LEGENDARY) && game->inPlay->findByName(card->name)) + continue; + + if (card->hasType(Subtypes::TYPE_PLANESWALKER) && card->types.size() > 0 && game->inPlay->hasTypeSpecificInt(Subtypes::TYPE_PLANESWALKER,card->types[1])) + continue; + + if(hints && hints->HintSaysItsForCombo(observer,card)) + { + if(hints->canWeCombo(observer,card,this)) + { + AbilityFactory af(observer); + int canPlay = af.parseCastRestrictions(card,card->controller(),card->getRestrictions()); + if(!canPlay) + continue; + nextCardToPlay = card; + gotPayments.clear(); + if((!pMana->canAfford(nextCardToPlay->getManaCost()) || nextCardToPlay->getManaCost()->getKicker())) + gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost()); + return activateCombo(); + } + else + { + nextCardToPlay = NULL; + continue; + } + } + int currentCost = card->getManaCost()->getConvertedCost(); + int hasX = card->getManaCost()->hasX(); + gotPayments.clear(); + if((!pMana->canAfford(card->getManaCost()) || card->getManaCost()->getKicker())) + gotPayments = canPayMana(card,card->getManaCost()); + //for preformence reason we only look for specific mana if the payment couldn't be made with pmana. + if ((currentCost > maxCost || hasX) && (gotPayments.size() || pMana->canAfford(card->getManaCost()))) + { + TargetChooserFactory tcf(observer); + TargetChooser * tc = tcf.createTargetChooser(card); + int shouldPlayPercentage = 0; + if (tc) + { + int hasTarget = chooseTarget(tc,NULL,NULL,true); + if( + (tc->maxtargets > hasTarget && tc->maxtargets > 1 && !tc->targetMin && tc->maxtargets != TargetChooser::UNLITMITED_TARGETS) ||//target=<3>creature + (tc->maxtargets == TargetChooser::UNLITMITED_TARGETS && hasTarget < 1)//target=creatures + ) + hasTarget = 0; + if (!hasTarget)//single target covered here. + { + SAFE_DELETE(tc); + continue; + } + shouldPlayPercentage = 90; + if(tc->targetMin && hasTarget < tc->maxtargets) + shouldPlayPercentage = 0; + if(tc->maxtargets > 1 && tc->maxtargets != TargetChooser::UNLITMITED_TARGETS && hasTarget <= tc->maxtargets) + { + int maxA = hasTarget-tc->maxtargets; + shouldPlayPercentage += (10*maxA);//reduce the chances of playing multitarget if we are not above max targets. + } + if(tc->maxtargets == TargetChooser::UNLITMITED_TARGETS) + { + shouldPlayPercentage = 40 + (10*hasTarget); + int totalCost = pMana->getConvertedCost()-currentCost; + int totalTargets = hasTarget+hasTarget; + if(hasX && totalCost <= totalTargets)// {x} spell with unlimited targeting tend to divide damage, we want atleast 1 damage per target before casting. + { + shouldPlayPercentage = 0; + } + } + SAFE_DELETE(tc); + } + else + { + int shouldPlay = effectBadOrGood(card); + if (shouldPlay == BAKA_EFFECT_GOOD) + { + shouldPlayPercentage = 90; + } + else if (BAKA_EFFECT_DONTKNOW == shouldPlay) + { + //previously shouldPlayPercentage = 80;, I found this a little to high + //for cards which AI had no idea how to use. + shouldPlayPercentage = 60; + } + else if (card->isLand()) + { + shouldPlayPercentage = 90; + } + else + { + // shouldPlay == baka_effect_bad giving it a 1 for odd ball lottery chance. + shouldPlayPercentage = 1; + } + + } + //Reduce the chances of playing a spell with X cost if available mana is low + if (hasX) + { + int xDiff = pMana->getConvertedCost() - currentCost; + if (xDiff < 0) + xDiff = 0; + shouldPlayPercentage = shouldPlayPercentage - static_cast ((shouldPlayPercentage * 1.9f) / (1 + xDiff)); + } + if(card->getManaCost() && card->getManaCost()->getKicker() && card->getManaCost()->getKicker()->isMulti) + { + shouldPlayPercentage = 10* size_t(gotPayments.size())/int(1+(card->getManaCost()->getConvertedCost()+card->getManaCost()->getKicker()->getConvertedCost())); + if(shouldPlayPercentage <= 10) + shouldPlayPercentage = shouldPlayPercentage/3; + } + DebugTrace("Should I play " << (card ? card->name : "Nothing" ) << "?" << endl + <<"shouldPlayPercentage = "<< shouldPlayPercentage); + if(card->getRestrictions().size()) + { + AbilityFactory af(observer); + int canPlay = af.parseCastRestrictions(card,card->controller(),card->getRestrictions()); + if(!canPlay) + continue; + } + int randomChance = randomGenerator.random(); + int chance = randomChance % 100; + if (chance > shouldPlayPercentage) + continue; + if(shouldPlayPercentage <= 10) + { + DebugTrace("shouldPlayPercentage was less than 10 this was a lottery roll on RNG"); + } + nextCardToPlay = card; + maxCost = currentCost; + if (hasX) + maxCost = pMana->getConvertedCost(); + } + } + //canplayfromexile + while ((card = cd.nextmatch(game->exile, card))&& card->has(Constants::CANPLAYFROMEXILE)) + { + if (!CanHandleCost(card->getManaCost(),card)) + continue; + + if (card->hasType(Subtypes::TYPE_LAND)) + { + if (game->playRestrictions->canPutIntoZone(card, game->inPlay) == PlayRestriction::CANT_PLAY) + continue; + } + else + { + if (game->playRestrictions->canPutIntoZone(card, game->stack) == PlayRestriction::CANT_PLAY) + continue; + } + + if (card->hasType(Subtypes::TYPE_LEGENDARY) && game->inPlay->findByName(card->name)) + continue; + + if (card->hasType(Subtypes::TYPE_PLANESWALKER) && card->types.size() > 0 && game->inPlay->hasTypeSpecificInt(Subtypes::TYPE_PLANESWALKER,card->types[1])) + continue; + + if(hints && hints->HintSaysItsForCombo(observer,card)) + { + if(hints->canWeCombo(observer,card,this)) + { + AbilityFactory af(observer); + int canPlay = af.parseCastRestrictions(card,card->controller(),card->getRestrictions()); + if(!canPlay) + continue; + nextCardToPlay = card; + gotPayments.clear(); + if((!pMana->canAfford(nextCardToPlay->getManaCost()) || nextCardToPlay->getManaCost()->getKicker())) + gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost()); + return activateCombo(); + } + else + { + nextCardToPlay = NULL; + continue; + } + } + int currentCost = card->getManaCost()->getConvertedCost(); + int hasX = card->getManaCost()->hasX(); + gotPayments.clear(); + if((!pMana->canAfford(card->getManaCost()) || card->getManaCost()->getKicker())) + gotPayments = canPayMana(card,card->getManaCost()); + //for preformence reason we only look for specific mana if the payment couldn't be made with pmana. + if ((currentCost > maxCost || hasX) && (gotPayments.size() || pMana->canAfford(card->getManaCost()))) + { + TargetChooserFactory tcf(observer); + TargetChooser * tc = tcf.createTargetChooser(card); + int shouldPlayPercentage = 0; + if (tc) + { + int hasTarget = chooseTarget(tc,NULL,NULL,true); + if( + (tc->maxtargets > hasTarget && tc->maxtargets > 1 && !tc->targetMin && tc->maxtargets != TargetChooser::UNLITMITED_TARGETS) ||//target=<3>creature + (tc->maxtargets == TargetChooser::UNLITMITED_TARGETS && hasTarget < 1)//target=creatures + ) + hasTarget = 0; + if (!hasTarget)//single target covered here. + { + SAFE_DELETE(tc); + continue; + } + shouldPlayPercentage = 90; + if(tc->targetMin && hasTarget < tc->maxtargets) + shouldPlayPercentage = 0; + if(tc->maxtargets > 1 && tc->maxtargets != TargetChooser::UNLITMITED_TARGETS && hasTarget <= tc->maxtargets) + { + int maxA = hasTarget-tc->maxtargets; + shouldPlayPercentage += (10*maxA);//reduce the chances of playing multitarget if we are not above max targets. + } + if(tc->maxtargets == TargetChooser::UNLITMITED_TARGETS) + { + shouldPlayPercentage = 40 + (10*hasTarget); + int totalCost = pMana->getConvertedCost()-currentCost; + int totalTargets = hasTarget+hasTarget; + if(hasX && totalCost <= totalTargets)// {x} spell with unlimited targeting tend to divide damage, we want atleast 1 damage per target before casting. + { + shouldPlayPercentage = 0; + } + } + SAFE_DELETE(tc); + } + else + { + int shouldPlay = effectBadOrGood(card); + if (shouldPlay == BAKA_EFFECT_GOOD) + { + shouldPlayPercentage = 90; + } + else if (BAKA_EFFECT_DONTKNOW == shouldPlay) + { + //previously shouldPlayPercentage = 80;, I found this a little to high + //for cards which AI had no idea how to use. + shouldPlayPercentage = 60; + } + else if (card->isLand()) + { + shouldPlayPercentage = 90; + } + else + { + // shouldPlay == baka_effect_bad giving it a 1 for odd ball lottery chance. + shouldPlayPercentage = 1; + } + + } + //Reduce the chances of playing a spell with X cost if available mana is low + if (hasX) + { + int xDiff = pMana->getConvertedCost() - currentCost; + if (xDiff < 0) + xDiff = 0; + shouldPlayPercentage = shouldPlayPercentage - static_cast ((shouldPlayPercentage * 1.9f) / (1 + xDiff)); + } + if(card->getManaCost() && card->getManaCost()->getKicker() && card->getManaCost()->getKicker()->isMulti) + { + shouldPlayPercentage = 10* size_t(gotPayments.size())/int(1+(card->getManaCost()->getConvertedCost()+card->getManaCost()->getKicker()->getConvertedCost())); + if(shouldPlayPercentage <= 10) + shouldPlayPercentage = shouldPlayPercentage/3; + } + DebugTrace("Should I play " << (card ? card->name : "Nothing" ) << "?" << endl + <<"shouldPlayPercentage = "<< shouldPlayPercentage); + if(card->getRestrictions().size()) + { + AbilityFactory af(observer); + int canPlay = af.parseCastRestrictions(card,card->controller(),card->getRestrictions()); + if(!canPlay) + continue; + } + int randomChance = randomGenerator.random(); + int chance = randomChance % 100; + if (chance > shouldPlayPercentage) + continue; + if(shouldPlayPercentage <= 10) + { + DebugTrace("shouldPlayPercentage was less than 10 this was a lottery roll on RNG"); + } + nextCardToPlay = card; + maxCost = currentCost; + if (hasX) + maxCost = pMana->getConvertedCost(); + } + } while ((card = cd.nextmatch(game->hand, card))) { if (!CanHandleCost(card->getManaCost(),card)) diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 03bf15211..2731b2429 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -1156,7 +1156,7 @@ void GameObserver::Affinity() card->getManaCost()->remove(color,1); } } - //SAFE_DELETE(original); + SAFE_DELETE(original); }//end } } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 44c40898d..6b157fb32 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -3689,9 +3689,6 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ badAbilities[(int)Constants::WEAK] = true; badAbilities[(int)Constants::NOLIFEGAIN] = true; badAbilities[(int)Constants::NOLIFEGAINOPPONENT] = true; - badAbilities[(int)Constants::CANTLOSE] = false; - badAbilities[(int)Constants::CANTLIFELOSE] = false; - badAbilities[(int)Constants::CANTMILLLOSE] = false; if (AInstantBasicAbilityModifierUntilEOT * abi = dynamic_cast(a)) { From 1c8852a7a255eb7667a83e287f62b563e6be01de Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 5 Nov 2015 23:25:39 +0800 Subject: [PATCH 06/22] Manacost Changes todo: kicker (other possible additional costs?) and change rule keyword to payzerorule... --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 2 +- projects/mtg/include/MTGCardInstance.h | 19 +---- projects/mtg/include/MTGRules.h | 11 ++- projects/mtg/src/AIPlayerBaka.cpp | 2 +- projects/mtg/src/MTGAbility.cpp | 2 +- projects/mtg/src/MTGCardInstance.cpp | 19 +++++ projects/mtg/src/MTGDefinitions.cpp | 2 +- projects/mtg/src/MTGRules.cpp | 83 +++++++++++++------- 8 files changed, 86 insertions(+), 54 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 257c81f05..16080c3b0 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -41603,7 +41603,7 @@ toughness=3 [card] name=Gravecrawler abilities=cantblock -autograveyard=aslongas(zombie|myBattlefield) transforms((,newability[CanPlayFromGraveyard])) +autograveyard=aslongas(zombie|myBattlefield) CanPlayFromGraveyard text=Gravecrawler can't block. -- You may cast Gravecrawler from your graveyard as long as you control a Zombie. mana={B} type=Creature diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 9eb7a64da..8c1882e91 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -254,24 +254,7 @@ public: bool isTargetter(); int cardistargetter; int myconvertedcost; - ManaCost * computeNewCost(MTGCardInstance * card,ManaCost * oldCost) - { - if(card->isLand()) - return oldCost; - - if(!card) - return NULL; - //i don't know why this method doesn't affect cards in hand, but is working on other zones....// - //pay zero costs// - //kicker???...// - //morph cost todo// - //trinisphere must be here below// - if(card->has(Constants::TRINISPHERE)) - for(int jj = oldCost->getConvertedCost(); jj < 3; jj++) - oldCost->add(Constants::MTG_COLOR_ARTIFACT, 1); - - return oldCost; - }; + ManaCost * computeNewCost(MTGCardInstance * card,ManaCost * oldCost); void eventattacked(); void eventattackedAlone(); diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index f99bdb7d4..f617f556a 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -175,18 +175,21 @@ public: virtual MTGMorphCostRule * clone() const; }; -class MTGPlayFromGraveyardRule: public MTGAlternativeCostRule +class MTGPayZeroRule: public MTGAlternativeCostRule { public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); + string CustomName; virtual ostream& toString(ostream& out) const; - MTGPlayFromGraveyardRule(GameObserver* observer, int _id); + MTGPayZeroRule(GameObserver* observer, int _id); const string getMenuText() { - return "Cast Card From This Zone"; + if(CustomName.size()) + return CustomName.c_str(); + return "Pay Zero To Cast"; } - virtual MTGPlayFromGraveyardRule * clone() const; + virtual MTGPayZeroRule * clone() const; }; diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index 4c54c565d..e0d269e69 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -631,7 +631,7 @@ int OrderedAIAction::getEfficiency() { efficiency += 55; } - else if (dynamic_cast(a)) + else if (dynamic_cast(a)) { efficiency += 45; } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 6b157fb32..10e9d30cc 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1159,7 +1159,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG found = s.find("playfromgraveyardrule"); if(found != string::npos) { - observer->addObserver(NEW MTGPlayFromGraveyardRule(observer, -1)); + observer->addObserver(NEW MTGPayZeroRule(observer, -1)); return NULL; } //this rule handles attacking ability during attacker phase diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index a70ef93b6..a56247912 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -918,6 +918,25 @@ JQuadPtr MTGCardInstance::getIcon() return WResourceManager::Instance()->RetrieveCard(this, CACHE_THUMB); } +ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * oldCost) +{ + if(card->isLand()) + return oldCost; + + if(!card) + return oldCost; + //use forcedalive// + //pay zero costs// + //kicker???...// + //morph cost todo// + //trinisphere must be here below// + if(card->has(Constants::TRINISPHERE)) + for(int jj = oldCost->getConvertedCost(); jj < 3; jj++) + oldCost->add(Constants::MTG_COLOR_ARTIFACT, 1); + + return oldCost; +} + MTGCardInstance * MTGCardInstance::getNextPartner() { MTGInPlay * inplay = controller()->game->inPlay; diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index a1645eb0a..7728bd1d2 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -148,7 +148,7 @@ const char* Constants::MTGBasicAbilities[] = { "protectionfromcoloredspells", "mygcreatureexiler", "oppgcreatureexiler", - "payzero", + "zerocast", "trinisphere", "canplayfromexile", "libraryeater" diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index bb62985fd..03b6dc136 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -284,8 +284,10 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *) { int cardsinhand = game->players[0]->game->hand->nb_cards; Player * player = game->currentlyActing(); - if (!player->game->hand->hasCard(card)) - return 0; + if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card)) + return 0; + if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) + return 0; if ((game->turn < 1) && (cardsinhand != 0) && (card->basicAbilities[(int)Constants::LEYLINE]) && game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN && game->players[0]->game->graveyard->nb_cards == 0 @@ -295,7 +297,7 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *) if (card->basicAbilities[(int)Constants::LEYLINE]) { - MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->temp); + MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->temp); Spell * spell = NEW Spell(game, copy); spell->resolve(); delete spell; @@ -412,7 +414,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card) delete previousManaPool; if (card->isLand()) { - MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->temp); + MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->temp); Spell * spell = NEW Spell(game, 0,copy,NULL,NULL, payResult); spell->resolve(); delete spellCost; @@ -421,7 +423,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card) else { Spell * spell = NULL; - MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->stack); + MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->stack); if (game->targetChooser) { spell = game->mLayers->stackLayer()->addSpell(copy, game->targetChooser, spellCost, payResult, 0); @@ -475,8 +477,10 @@ int MTGKickerRule::isReactingToClick(MTGCardInstance * card, ManaCost *) if(OptionKicker::KICKER_ALWAYS == options[Options::KICKERPAYMENT].number) return 0; Player * player = game->currentlyActing(); - if(!player->game->hand->hasCard(card)) - return 0; + if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card)) + return 0; + if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) + return 0; ManaCost * kicker = card->getManaCost()->getKicker(); if(!kicker) { @@ -484,7 +488,7 @@ int MTGKickerRule::isReactingToClick(MTGCardInstance * card, ManaCost *) return 0; } ManaCost * playerMana = player->getManaPool(); - ManaCost * withKickerCost= NEW ManaCost(card->getManaCost()); + ManaCost * withKickerCost= NEW ManaCost(card->model->data->getManaCost()); withKickerCost->add(withKickerCost->getKicker()); if(!playerMana->canAfford(withKickerCost)) { @@ -503,7 +507,7 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card) return 0; Player * player = game->currentlyActing(); - ManaCost * withKickerCost= NEW ManaCost(card->getManaCost());//using pointers here alters the real cost of the card. + ManaCost * withKickerCost= NEW ManaCost(card->model->data->getManaCost());//using pointers here alters the real cost of the card. if (card->getManaCost()->getKicker()->isMulti) { while(player->getManaPool()->canAfford(withKickerCost)) @@ -545,7 +549,7 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card) delete previousManaPool; if (card->isLand()) { - MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->temp); + MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->temp); Spell * spell = NEW Spell(game, 0,copy,NULL,NULL, ManaCost::MANA_PAID_WITH_KICKER); spell->resolve(); delete spellCost; @@ -554,7 +558,7 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card) else { Spell * spell = NULL; - MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->stack); + MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->stack); if (game->targetChooser) { spell = game->mLayers->stackLayer()->addSpell(copy, game->targetChooser, spellCost, ManaCost::MANA_PAID_WITH_KICKER, 0); @@ -616,7 +620,9 @@ PermanentAbility(observer, _id) int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) { ManaCost * alternateCost = card->getManaCost()->getAlternative(); - if (!game->currentlyActing()->game->hand->hasCard(card)) + if (!game->currentlyActing()->game->hand->hasCard(card) && !game->currentlyActing()->game->graveyard->hasCard(card) && !game->currentlyActing()->game->exile->hasCard(card)) + return 0; + if ((game->currentlyActing()->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (game->currentlyActing()->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) return 0; return isReactingToClick( card, mana, alternateCost ); } @@ -630,7 +636,12 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * if(!allowedToAltCast(card,player)) return 0; - if(card->model->data->getManaCost()->getAlternative() && card->model->data->getManaCost()->getAlternative()->alternativeName.size()) + + if(card->has(Constants::CANPLAYFROMGRAVEYARD)) + alternativeName = "Alternate Cast Card From Graveyard"; + else if(card->has(Constants::CANPLAYFROMEXILE)) + alternativeName = "Alternate Cast Card From Exile"; + else if(card->model->data->getManaCost()->getAlternative() && card->model->data->getManaCost()->getAlternative()->alternativeName.size()) alternativeName = card->model->data->getManaCost()->getAlternative()->alternativeName; if (card->isLand()) @@ -763,8 +774,10 @@ MTGAlternativeCostRule(observer, _id) int MTGBuyBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) { Player * player = game->currentlyActing(); - if (!player->game->hand->hasCard(card)) - return 0; + if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card)) + return 0; + if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) + return 0; if(!allowedToCast(card,player)) return 0; return MTGAlternativeCostRule::isReactingToClick( card, mana, card->getManaCost()->getBuyback() ); @@ -1129,46 +1142,60 @@ MTGMorphCostRule * MTGMorphCostRule::clone() const //------------------------------------------------------------------------- //------------------------------------------------------------------------- -MTGPlayFromGraveyardRule::MTGPlayFromGraveyardRule(GameObserver* observer, int _id) : +MTGPayZeroRule::MTGPayZeroRule(GameObserver* observer, int _id) : MTGAlternativeCostRule(observer, _id) { aType = MTGAbility::CASTINGRAVEEXILE_COST; } -int MTGPlayFromGraveyardRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) +int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) { Player * player = game->currentlyActing(); - ManaCost * cost = card->getManaCost(); + ManaCost * cost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL)); + if(card->getIncreasedManaCost()->getConvertedCost()) + cost->add(card->getIncreasedManaCost()); + if(card->getReducedManaCost()->getConvertedCost()) + cost->remove(card->getReducedManaCost()); - if (!player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card)) + if(card->isLand()) + return 0; + if(!card->has(Constants::PAYZERO)) + return 0; + if (!player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card)) return 0; if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card))) return 0; - + if(card->has(Constants::CANPLAYFROMGRAVEYARD)) + CustomName = "Pay Zero To Cast From Graveyard"; + else if(card->has(Constants::CANPLAYFROMEXILE)) + CustomName = "Pay Zero To Cast From Exile"; + else + CustomName = "Pay Zero To Cast"; + return MTGAlternativeCostRule::isReactingToClick(card, mana, cost); } -int MTGPlayFromGraveyardRule::reactToClick(MTGCardInstance * card) +int MTGPayZeroRule::reactToClick(MTGCardInstance * card) { if (!isReactingToClick(card)) return 0; - ManaCost * cost = card->getManaCost(); + ManaCost * cost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL)); card->paymenttype = MTGAbility::CASTINGRAVEEXILE_COST; - return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID_WITH_OTHERCOST); + return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID); } -ostream& MTGPlayFromGraveyardRule::toString(ostream& out) const +ostream& MTGPayZeroRule::toString(ostream& out) const { - out << "MTGPlayFromGraveyardRule ::: ("; + out << "MTGPayZeroRule ::: ("; return MTGAbility::toString(out) << ")"; } -MTGPlayFromGraveyardRule * MTGPlayFromGraveyardRule::clone() const +MTGPayZeroRule * MTGPayZeroRule::clone() const { - return NEW MTGPlayFromGraveyardRule(*this); + return NEW MTGPayZeroRule(*this); } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1718,7 +1745,7 @@ int MTGMomirRule::reactToClick(MTGCardInstance * card_to_discard, int cardId) ManaCost * cost = player->getManaPool(); player->getManaPool()->pay(cost); MTGCardInstance * card = genCreature(cardId); - player->game->putInZone(card_to_discard, player->game->hand, player->game->graveyard); + player->game->putInZone(card_to_discard, card_to_discard->currentZone, player->game->graveyard); player->game->stack->addCard(card); Spell * spell = NEW Spell(game, card); From 71390046f5aea64f667284b03dd2b997f528184a Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 6 Nov 2015 19:47:30 +0800 Subject: [PATCH 07/22] anyzone for cdaactive should handle most of them except sewer nemesis, chameleon colossus --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 180 +++++++++---------- projects/mtg/src/MTGAbility.cpp | 8 +- projects/mtg/src/MTGDeck.cpp | 10 ++ 3 files changed, 106 insertions(+), 92 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 16080c3b0..e33f7dbf8 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -2,7 +2,7 @@ #Please keep these card alphabetized, and try to have the "name=" line at the top of each card [card] name=Aeon Chronicler -auto=phandcount/phandcount cdaactive +anyzone=phandcount/phandcount cdaactive autoexile=@counterremoved(0/0,1,Time) from(sourcecard) suspended:draw:1 suspend(0)={X}{3}{U} text=Aeon Chronicler's power and toughness are each equal to the number of cards in your hand. -- Suspend X - {X}{3}{U}. X can't be 0. (Rather than cast this card from your hand, you may pay {X}{3}{U} and exile it with X time counters on it. At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost. It has haste.) -- Whenever a time counter is removed from Aeon Chronicler while it's exiled, draw a card. @@ -878,7 +878,7 @@ type=Instant [/card] [card] name=Adamaro, First to Desire -auto=type:*:opponenthand/type:*:opponenthand cdaactive +anyzone=type:*:opponenthand/type:*:opponenthand cdaactive text=Adamaro, First to Desire's power and toughness are each equal to the number of cards in the hand of the opponent with the most cards in hand. mana={1}{R}{R} type=Legendary Creature @@ -1493,7 +1493,7 @@ subtype=Ajani [/card] [card] name=Avatar Token -auto=lifetotal/lifetotal cdaactive +anyzone=lifetotal/lifetotal cdaactive type=Creature subtype=Avatar power=* @@ -2351,7 +2351,7 @@ toughness=1 [card] name=Altar Golem abilities=trample,doesnotuntap -auto=type:creature:battlefield/type:creature:battlefield cdaactive +anyzone=type:creature:battlefield/type:creature:battlefield cdaactive auto={T(creature|myBattlefield)}{T(creature|myBattlefield)}{T(creature|myBattlefield)}{T(creature|myBattlefield)}{T(creature|myBattlefield)}:untap text=Trample -- Altar Golem's power and toughness are each equal to the number of creatures on the battlefield. -- Altar Golem doesn't untap during your untap step. -- Tap five untapped creatures you control: Untap Altar Golem. mana={7} @@ -2937,7 +2937,7 @@ toughness=3 [/card] [card] name=Ancient Ooze -auto=pancientooze/pancientooze cdaactive +anyzone=pancientooze/pancientooze cdaactive text=Ancient Ooze's power and toughness are each equal to the total converted mana cost of other creatures you control. mana={5}{G}{G} type=Creature @@ -8068,7 +8068,7 @@ toughness=2 [card] name=Battle Squadron abilities=flying -auto=type:creature:myBattlefield/type:creature:myBattlefield cdaactive +anyzone=type:creature:myBattlefield/type:creature:myBattlefield cdaactive text=Flying -- Battle Squadron's power and toughness are each equal to the number of creatures you control. mana={3}{R}{R} type=Creature @@ -8381,7 +8381,7 @@ type=Enchantment [/card] [card] name=Beast of Burden -auto=type:creature:Battlefield/type:creature:Battlefield cdaactive +anyzone=type:creature:Battlefield/type:creature:Battlefield cdaactive text=Beast of Burden's power and toughness are each equal to the number of creatures on the battlefield. mana={6} type=Artifact Creature @@ -8671,7 +8671,7 @@ toughness=2 [/card] [card] name=Benalish Commander -auto=type:soldier:mybattlefield/type:soldier:mybattlefield cdaactive +anyzone=type:soldier:mybattlefield/type:soldier:mybattlefield cdaactive autoexile=@counterremoved(0/0,1,Time) from(sourcecard) suspended:token(Soldier,Creature Soldier,1/1,white) suspend(0)={X}{W}{W} text=Benalish Commander's power and toughness are each equal to the number of Soldiers you control. -- Suspend X - {X}{W}{W}. X can't be 0. (Rather than cast this card from your hand, you may pay {X}{W}{W} and exile it with X time counters on it. At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost. It has haste.) -- Whenever a time counter is removed from Benalish Commander while it's exiled, put a 1/1 white Soldier creature token onto the battlefield. @@ -11580,7 +11580,7 @@ toughness=2 [/card] [card] name=Boneyard Wurm -auto=type:creature:mygraveyard/type:creature:mygraveyard cdaactive +anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive text=Boneyard Wurm's power and toughness are each equal to the number of creature cards in your graveyard. mana={1}{G} type=Creature @@ -12926,7 +12926,7 @@ toughness=4 [card] name=Broodstar abilities=affinityartifacts,flying -auto=type:artifact:mybattlefield/type:artifact:mybattlefield cdaactive +anyzone=type:artifact:mybattlefield/type:artifact:mybattlefield cdaactive text=Affinity for artifacts (This spell costs {1} less to cast for each artifact you control.) -- Flying -- Broodstar's power and toughness are each equal to the number of artifacts you control. mana={8}{U}{U} type=Creature @@ -14098,7 +14098,7 @@ type=Sorcery [card] name=Cantivore abilities=vigilance -auto=type:enchantment:graveyard/type:enchantment:graveyard cdaactive +anyzone=type:enchantment:graveyard/type:enchantment:graveyard cdaactive text=Vigilance -- Cantivore's power and toughness are each equal to the number of enchantment cards in all graveyards. mana={1}{W}{W} type=Creature @@ -18066,7 +18066,7 @@ type=Instant [card] name=Cognivore abilities=flying -auto=type:instant:graveyard/type:instant:graveyard cdaactive +anyzone=type:instant:graveyard/type:instant:graveyard cdaactive text=Flying -- Cognivore's power and toughness are each equal to the number of instant cards in all graveyards. mana={6}{U}{U} type=Creature @@ -18086,7 +18086,7 @@ toughness=1 [/card] [card] name=Coiling Woodworm -auto=type:forest:battlefield/1 cdaactive +anyzone=type:forest:battlefield/1 cdaactive text=Coiling Woodworm's power is equal to the number of Forests on the battlefield. mana={2}{G} type=Creature @@ -20220,7 +20220,7 @@ toughness=4 [card] name=Crowd of Cinders abilities=fear -auto=type:*[black]:myBattlefield/type:*[black]:myBattlefield cdaactive +anyzone=type:*[black]:myBattlefield/type:*[black]:myBattlefield cdaactive text=Fear (This creature can't be blocked except by artifact creatures and/or black creatures.) -- Crowd of Cinders's power and toughness are each equal to the number of black permanents you control. mana={3}{B} type=Creature @@ -20455,7 +20455,7 @@ type=Enchantment [/card] [card] name=Crusader of Odric -auto=type:creature:mybattlefield/type:creature:mybattlefield cdaactive +anyzone=type:creature:mybattlefield/type:creature:mybattlefield cdaactive text=Crusader of Odric's power and toughness are each equal to the number of creatures you control. mana={2}{W} type=Creature @@ -21338,7 +21338,7 @@ subtype=Aura [/card] [card] name=Dakkon Blackblade -auto=type:land:myBattlefield/type:land:myBattlefield cdaactive +anyzone=type:land:myBattlefield/type:land:myBattlefield cdaactive text=Dakkon Blackblade's power and toughness are each equal to the number of lands you control. mana={2}{W}{U}{U}{B} type=Legendary Creature @@ -21401,7 +21401,7 @@ toughness=1 [/card] [card] name=Dakmor Sorceress -auto=type:swamp:myBattlefield/4 cdaactive +anyzone=type:swamp:myBattlefield/4 cdaactive text=Dakmor Sorceress's power is equal to the number of Swamps you control. mana={5}{B} type=Creature @@ -21917,7 +21917,7 @@ type=Artifact [card] name=Darksteel Juggernaut abilities=mustattack,indestructible -auto=type:artifact:mybattlefield/type:artifact:mybattlefield cdaactive +anyzone=type:artifact:mybattlefield/type:artifact:mybattlefield cdaactive text=Darksteel Juggernaut's power and toughness are equal to the number of artifacts you control. -- Darksteel Juggernaut is indestructible and attacks each turn if able. mana={5} type=Artifact Creature @@ -22113,7 +22113,7 @@ toughness=3 [/card] [card] name=Dauntless Dourbark -auto=pdauntless/pdauntless cdaactive +anyzone=pdauntless/pdauntless cdaactive auto=aslongas(other treefolk|myBattlefield) trample text=Dauntless Dourbark's power and toughness are each equal to the number of Forests you control plus the number of Treefolk you control. -- Dauntless Dourbark has trample as long as you control another Treefolk. mana={3}{G} @@ -22257,7 +22257,7 @@ toughness=1 [card] name=Dauthi Warlord abilities=shadow -auto=type:creature[shadow]:battlefield/1 cdaactive +anyzone=type:creature[shadow]:battlefield/1 cdaactive text=Shadow (This creature can block or be blocked by only creatures with shadow.) -- Dauthi Warlord's power is equal to the number of creatures with shadow on the battlefield. mana={1}{B} type=Creature @@ -24371,7 +24371,7 @@ text=Destroy target artifact with converted mana cost X. It can't be regenerated [/card] [card] name=Detritivore -auto=type:land[-basic]:opponentgraveyard/type:land[-basic]:opponentgraveyard cdaactive +anyzone=type:land[-basic]:opponentgraveyard/type:land[-basic]:opponentgraveyard cdaactive autoexile=@counterremoved(0/0,1,Time) from(sourcecard) suspended:destroy target(land[-basic]) suspend(0)={X}{3}{R} text=Detritivore's power and toughness are each equal to the number of nonbasic land cards in your opponents' graveyards. -- Suspend X - {X}{3}{R}. X can't be 0. (Rather than cast this card from your hand, you may pay {X}{3}{R} and exile it with X time counters on it. At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost. It has haste.) -- Whenever a time counter is removed from Detritivore while it's exiled, destroy target nonbasic land. @@ -25844,7 +25844,7 @@ type=Artifact [card] name=Doubtless One auto=spiritlink -auto=type:cleric:battlefield/type:cleric:battlefield cdaactive +anyzone=type:cleric:battlefield/type:cleric:battlefield cdaactive text=Doubtless One's power and toughness are each equal to the number of Clerics on the battlefield. -- Whenever Doubtless One deals damage, you gain that much life. mana={3}{W} type=Creature @@ -26976,7 +26976,7 @@ toughness=5 [card] name=Drift of the Dead abilities=defender -auto=type:land[snow]:myBattlefield/type:land[snow]:myBattlefield cdaactive +anyzone=type:land[snow]:myBattlefield/type:land[snow]:myBattlefield cdaactive text=Defender (This creature can't attack.) -- Drift of the Dead's power and toughness are each equal to the number of snow lands you control. mana={3}{B} type=Creature @@ -27335,7 +27335,7 @@ toughness=1 [card] name=Drove of Elves abilities=opponentshroud -auto=type:*[green]:myBattlefield/type:*[green]:myBattlefield cdaactive +anyzone=type:*[green]:myBattlefield/type:*[green]:myBattlefield cdaactive text=Drove of Elves's power and toughness are each equal to the number of green permanents you control. -- Drove of Elves can't be the target of spells or abilities your opponents control. mana={3}{G} type=Creature @@ -27686,7 +27686,7 @@ toughness=1 [card] name=Dungrove Elder abilities=opponentshroud -auto=type:forest:mybattlefield/type:forest:mybattlefield cdaactive +anyzone=type:forest:mybattlefield/type:forest:mybattlefield cdaactive text=Hexproof (This creature can't be the target of spells or abilities your opponents control.) -- Dungrove Elder's power and toughness are each equal to the number of Forests you control. mana={2}{G} type=Creature @@ -29051,7 +29051,7 @@ type=Sorcery name=Elephant T1 type=Creature subtype=Elephant -auto=type:creature:mygraveyard/type:creature:mygraveyard cdaactive +anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive text=This creature's power and toughness are each equal to the number of creature cards in its controller's graveyard. power=* toughness=* @@ -30620,7 +30620,7 @@ toughness=2 [/card] [card] name=Entropic Specter -auto=type:*:opponenthand/type:*:opponenthand cdaactive +anyzone=type:*:opponenthand/type:*:opponenthand cdaactive auto=@damageof(player) from(this):ability$!name(discard) target(*|myhand) reject!$ controller auto=@damagefoeof(player) from(this):ability$!name(discard) target(*|myhand) reject!$ opponent text=Flying -- As Entropic Specter enters the battlefield, choose an opponent. -- Entropic Specter's power and toughness are each equal to the number of cards in the chosen player's hand. -- Whenever Entropic Specter deals damage to a player, that player discards a card. @@ -32256,7 +32256,7 @@ toughness=1 [card] name=Faerie Swarm abilities=flying -auto=type:*[blue]:myBattlefield/type:*[blue]:myBattlefield cdaactive +anyzone=type:*[blue]:myBattlefield/type:*[blue]:myBattlefield cdaactive text=Flying -- Faerie Swarm's power and toughness are each equal to the number of blue permanents you control. mana={3}{U} type=Creature @@ -37804,7 +37804,7 @@ type=Instant name=Geist-Honored Monk abilities=vigilance auto=token(Spirit,Creature Spirit,1/1,white,flying)*2 -auto=type:creature:mybattlefield/type:creature:mybattlefield cdaactive +anyzone=type:creature:mybattlefield/type:creature:mybattlefield cdaactive text=Vigilance -- Geist-Honored Monk's power and toughness are each equal to the number of creatures you control. -- When Geist-Honored Monk enters the battlefield, put two 1/1 white Spirit creature tokens with flying onto the battlefield. mana={3}{W}{W} type=Creature @@ -44933,7 +44933,7 @@ subtype=Arcane [card] name=Heedless One abilities=trample -auto=type:elf:battlefield/type:elf:battlefield cdaactive +anyzone=type:elf:battlefield/type:elf:battlefield cdaactive text=Trample -- Heedless One's power and toughness are each equal to the number of Elves on the battlefield. mana={3}{G} type=Creature @@ -50066,7 +50066,7 @@ toughness=4 [/card] [card] name=Jagged-Scar Archers -auto=type:elf:myBattlefield/type:elf:myBattlefield cdaactive +anyzone=type:elf:myBattlefield/type:elf:myBattlefield cdaactive auto={T}:target(creature[flying]) dynamicability text=Jagged-Scar Archers's power and toughness are each equal to the number of Elves you control. -- {T}: Jagged-Scar Archers deals damage equal to its power to target creature with flying. mana={1}{G}{G} @@ -51346,7 +51346,7 @@ abilities=defender [/card] [card] name=Kagemaro, First to Suffer -auto=type:*:myhand/type:*:myhand cdaactive +anyzone=type:*:myhand/type:*:myhand cdaactive auto={B}{S}:-type:*:myhand/-type:*:myhand all(creature) text=Kagemaro, First to Suffer's power and toughness are each equal to the number of cards in your hand. -- {B}, Sacrifice Kagemaro: All creatures get -X/-X until end of turn, where X is the number of cards in your hand. mana={3}{B}{B} @@ -51417,7 +51417,7 @@ toughness=3 [/card] [card] name=Kalonian Twingrove -auto=type:forest:mybattlefield/type:forest:mybattlefield cdaactive +anyzone=type:forest:mybattlefield/type:forest:mybattlefield cdaactive auto=token(-383290) text=Kalonian Twingrove's power and toughness are each equal to the number of Forests you control. -- When Kalonian Twingrove enters the battlefield, put a green Treefolk Warrior creature token onto the battlefield with "this creature's power and toughness are each equal to the number of forests you control." mana={5}{G} @@ -51428,7 +51428,7 @@ toughness=* [/card] [card] name=Treefolk Warrior -auto=type:forest:mybattlefield/type:forest:mybattlefield cdaactive +anyzone=type:forest:mybattlefield/type:forest:mybattlefield cdaactive text=This creature's power and toughness are each equal to the number of forests you control. color=green type=Creature @@ -52469,7 +52469,7 @@ toughness=1 [/card] [card] name=Keldon Warlord -auto=type:creature[-wall]:myBattlefield/type:creature[-wall]:myBattlefield cdaactive +anyzone=type:creature[-wall]:myBattlefield/type:creature[-wall]:myBattlefield cdaactive text=Keldon Warlord's power and toughness are each equal to the number of non-Wall creatures you control. mana={2}{R}{R} type=Creature @@ -53129,7 +53129,7 @@ toughness=2 [card] name=Kithkin Rabble abilities=vigilance -auto=type:*[white]:myBattlefield/type:*[white]:myBattlefield cdaactive +anyzone=type:*[white]:myBattlefield/type:*[white]:myBattlefield cdaactive text=Vigilance -- Kithkin Rabble's power and toughness are each equal to the number of white permanents you control. mana={3}{W} type=Creature @@ -53253,7 +53253,7 @@ toughness=1 [/card] [card] name=Kiyomaro, First to Stand -auto=type:*:myhand/type:*:myhand cdaactive +anyzone=type:*:myhand/type:*:myhand cdaactive auto=aslongas(*|myhand) vigilance >3 auto=@damaged(creature,player) from(this) restriction{type(*|myhand)~morethan~6}:if type(*|myhand)~morethan~6 then life:7 controller text=Kiyomaro, First to Stand's power and toughness are each equal to the number of cards in your hand. -- As long as you have four or more cards in hand, Kiyomaro has vigilance. -- Whenever Kiyomaro deals damage, if you have seven or more cards in hand, you gain 7 life. @@ -53756,7 +53756,7 @@ toughness=1 [card] name=Kolaghan Forerunners abilities=trample -auto=type:creature:mybattlefield/3 cdaactive +anyzone=type:creature:mybattlefield/3 cdaactive other={R}{2} name(Dash) auto=if paid(alternative) then transforms((,newability[haste],newability[phaseaction[endofturn sourceinplay] moveto(ownerhand) all(this)])) forever text=Trample -- Kolaghan Forerunners's power is equal to the number of creatures you control. -- Dash {2}{R} (You may cast this spell for its dash cost. If you do, it gains haste, and it's returned from the battlefield to its owner's hand at the beginning of the next end step.) @@ -53990,7 +53990,7 @@ toughness=1 [card] name=Korlash Heir to Blackblade auto={discard(korlash heir to blackblade|myhand)}:moveto(mybattlefield) and!(tap)! target(swamp|mylibrary) -auto=type:swamp:mybattlefield/type:swamp:mybattlefield cdaactive +anyzone=type:swamp:mybattlefield/type:swamp:mybattlefield cdaactive auto={1}{B}:regenerate text=Korlash, Heir to Blackblade's power and toughness are each equal to the number of Swamps you control. -- {1}{B}: Regenerate Korlash. -- Grandeur - Discard another card named Korlash, Heir to Blackblade: Search your library for up to two Swamp cards, put them onto the battlefield tapped, then shuffle your library. mana={2}{B}{B} @@ -54444,7 +54444,7 @@ subtype=Aura [card] name=Krovikan Mist abilities=flying -auto=type:illusion:battlefield/type:illusion:battlefield cdaactive +anyzone=type:illusion:battlefield/type:illusion:battlefield cdaactive text=Flying -- Krovikan Mist's power and toughness are each equal to the number of Illusions on the battlefield. mana={1}{U} type=Creature @@ -56072,7 +56072,7 @@ toughness=5 [/card] [card] name=Lhurgoyf -auto=type:creature:graveyard/plusonetype:creature:graveyard cdaactive +anyzone=type:creature:graveyard/plusonetype:creature:graveyard cdaactive text=Lhurgoyf's power is equal to the number of creature cards in all graveyards and its toughness is equal to that number plus 1. mana={2}{G}{G} type=Creature @@ -57452,7 +57452,7 @@ toughness=2 [/card] [card] name=Lord of Extinction -auto=type:*:graveyard/type:*:graveyard cdaactive +anyzone=type:*:graveyard/type:*:graveyard cdaactive text=Lord of Extinction's power and toughness are each equal to the number of cards in all graveyards. mana={3}{B}{G} type=Creature @@ -58817,7 +58817,7 @@ toughness=6 [card] name=Magnivore abilities=haste -auto=type:sorcery:graveyard/type:sorcery:graveyard cdaactive +anyzone=type:sorcery:graveyard/type:sorcery:graveyard cdaactive text=Haste (This creature can attack the turn it comes under your control.) -- Magnivore's power and toughness are each equal to the number of sorcery cards in all graveyards. mana={2}{R}{R} type=Creature @@ -59639,7 +59639,7 @@ toughness=3 [/card] [card] name=Maraxus of Keld -auto=type:*[-tapped&-enchantment;-tapped&-planeswalker]/type:*[-tapped&-enchantment;-tapped&-planeswalker] cdaactive +anyzone=type:*[-tapped&-enchantment;-tapped&-planeswalker]/type:*[-tapped&-enchantment;-tapped&-planeswalker] cdaactive text=Maraxus of Keld's power and toughness are each equal to the number of untapped artifacts, creatures, and lands you control. mana={4}{R}{R} type=Legendary Creature @@ -60025,7 +60025,7 @@ toughness=4 [/card] [card] name=Maro -auto=type:*:myhand/type:*:myhand cdaactive +anyzone=type:*:myhand/type:*:myhand cdaactive text=Maro's power and toughness are each equal to the number of cards in your hand. mana={2}{G}{G} type=Creature @@ -60558,7 +60558,7 @@ toughness=2 [card] name=Master of Etherium auto=lord(other creature[artifact]|mybattlefield) 1/1 -auto=type:artifact:mybattlefield/type:artifact:mybattlefield cdaactive +anyzone=type:artifact:mybattlefield/type:artifact:mybattlefield cdaactive text=Master of Etherium's power and toughness are each equal to the number of artifacts you control. -- Other artifact creatures you control get +1/+1. mana={2}{U} type=Artifact Creature @@ -60663,7 +60663,7 @@ toughness=4 [/card] [card] name=Masumaro, First to Live -auto=twicetype:*:myhand/twicetype:*:myhand cdaactive +anyzone=twicetype:*:myhand/twicetype:*:myhand cdaactive text=Masumaro, First to Live's power and toughness are each equal to twice the number of cards in your hand. mana={3}{G}{G}{G} type=Legendary Creature @@ -60673,7 +60673,7 @@ toughness=* [/card] [card] name=Matca Rioters -auto=pbasiclandtypes/pbasiclandtypes cdaactive +anyzone=pbasiclandtypes/pbasiclandtypes cdaactive text=Domain - Matca Rioters's power and toughness are each equal to the number of basic land types among lands you control. mana={2}{G} type=Creature @@ -63699,7 +63699,7 @@ toughness=8 [card] name=Molimo, Maro-Sorcerer abilities=trample -auto=type:land:myBattlefield/type:land:myBattlefield cdaactive +anyzone=type:land:myBattlefield/type:land:myBattlefield cdaactive text=Trample (If this creature would deal enough damage to its blockers to destroy them, you may have it deal the rest of its damage to defending player or planeswalker.) -- Molimo, Maro-Sorcerer's power and toughness are each equal to the number of lands you control. mana={4}{G}{G}{G} type=Legendary Creature @@ -64585,7 +64585,7 @@ toughness=2 [card] name=Mortivore auto={B}:regenerate -auto=type:creature:graveyard/type:creature:graveyard cdaactive +anyzone=type:creature:graveyard/type:creature:graveyard cdaactive text=Mortivore's power and toughness are each equal to the number of creature cards in all graveyards. -- {B}: Regenerate Mortivore. (The next time this creature would be destroyed this turn, it isn't. Instead tap it, remove all damage from it, and remove it from combat.) mana={2}{B}{B} type=Creature @@ -64980,7 +64980,7 @@ toughness=2 [card] name=Multani, Maro-Sorcerer abilities=shroud -auto=type:*:hand/type:*:hand cdaactive +anyzone=type:*:hand/type:*:hand cdaactive text=Shroud (This permanent can't be the target of spells or abilities.) -- Multani's power and toughness are each equal to the total number of cards in all players' hands. mana={4}{G}{G} type=Legendary Creature @@ -65793,7 +65793,7 @@ subtype=Shapeshifter name=Nameless One facedown={3} autofacedown={2}{U}:morph -auto=type:wizard:battlefield/type:wizard:battlefield cdaactive +anyzone=type:wizard:battlefield/type:wizard:battlefield cdaactive text=Nameless One's power and toughness are each equal to the number of Wizards on the battlefield. -- Morph {2}{U} (You may cast this face down as a 2/2 creature for {3}. Turn it face up any time for its morph cost.) mana={3}{U} type=Creature @@ -67248,7 +67248,7 @@ type=Sorcery [card] name=Nightmare abilities=flying -auto=type:swamp:mybattlefield/type:swamp:mybattlefield cdaactive +anyzone=type:swamp:mybattlefield/type:swamp:mybattlefield cdaactive text=Flying -- Nightmare's power and toughness are each equal to the number of Swamps you control. mana={5}{B} type=Creature @@ -67366,7 +67366,7 @@ toughness=4 [/card] [card] name=Nightstalker Engine -auto=type:creature:myGraveyard/3 cdaactive +anyzone=type:creature:myGraveyard/3 cdaactive text=Nightstalker Engine's power is equal to the number of creature cards in your graveyard. mana={4}{B} type=Creature @@ -70197,7 +70197,7 @@ toughness=2 [/card] [card] name=Overbeing of Myth -auto=type:*:myhand/type:*:myhand cdaactive +anyzone=type:*:myhand/type:*:myhand cdaactive auto=@each my draw:draw:1 text=Overbeing of Myth's power and toughness are each equal to the number of cards in your hand. -- At the beginning of your draw step, draw an additional card. mana={GU}{GU}{GU}{GU}{GU} @@ -70450,7 +70450,7 @@ type=Sorcery [/card] [card] name=Pack Rat -auto=type:rat:mybattlefield/type:rat:mybattlefield cdaactive +anyzone=type:rat:mybattlefield/type:rat:mybattlefield cdaactive auto={2}{B}{discard(*|myhand)}:token(253624) text=Pack Rat's power and toughness are each equal to the number of Rats you control. -- {2}{B}, Discard a card: Put a token onto the battlefield that's a copy of Pack Rat. mana={1}{B} @@ -70694,7 +70694,7 @@ toughness=4 [/card] [card] name=Pallimud -auto=type:land[tapped]:opponentbattlefield/3 cdaactive +anyzone=type:land[tapped]:opponentbattlefield/3 cdaactive text=As Pallimud enters the battlefield, choose an opponent. -- Pallimud's power is equal to the number of tapped lands the chosen player controls. mana={2}{R} type=Creature @@ -71900,7 +71900,7 @@ toughness=6 [/card] [card] name=Pestilence Rats -auto=othertype:rat:battlefield/3 cdaactive +anyzone=othertype:rat:battlefield/3 cdaactive text=Pestilence Rats's power is equal to the number of other Rats on the battlefield. (For example, as long as there are two other Rats on the battlefield, Pestilence Rats's power and toughness are 2/3.) mana={2}{B} type=Creature @@ -73404,7 +73404,7 @@ toughness=1 [/card] [card] name=Plague Rats -auto=allmyname/allmyname cdaactive +anyzone=allmyname/allmyname cdaactive text=Plague Rats's power and toughness are each equal to the number of creatures named Plague Rats on the battlefield. mana={2}{B} type=Creature @@ -74639,7 +74639,7 @@ subtype=Aura [card] name=Primalcrux abilities=trample -auto=type:manag:mybattlefield/type:manag:mybattlefield cdaactive +anyzone=type:manag:mybattlefield/type:manag:mybattlefield cdaactive text=Trample -- Chroma - Primalcrux's power and toughness are each equal to the number of green mana symbols in the mana costs of permanents you control. mana={G}{G}{G}{G}{G}{G} type=Creature @@ -75329,7 +75329,7 @@ type=Enchantment [/card] [card] name=Psychosis Crawler -auto=type:*:myhand/type:*:myhand cdaactive +anyzone=type:*:myhand/type:*:myhand cdaactive auto=@drawof(player):life:-1 opponent text=Psychosis Crawler's power and toughness are each equal to the number of cards in your hand. - Whenever you draw a card, each opponent loses 1 life. mana={5} @@ -78392,7 +78392,7 @@ toughness=2 [card] name=Reckless One abilities=haste -auto=type:goblin:battlefield/type:goblin:battlefield cdaactive +anyzone=type:goblin:battlefield/type:goblin:battlefield cdaactive text=Haste -- Reckless One's power and toughness are each equal to the number of Goblins on the battlefield. mana={3}{R} type=Creature @@ -79781,7 +79781,7 @@ type=Artifact [card] name=Revenant abilities=flying -auto=type:creature:mygraveyard/type:creature:mygraveyard cdaactive +anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive text=Flying -- Revenant's power and toughness are each equal to the number of creature cards in your graveyard. mana={4}{B} type=Creature @@ -81838,7 +81838,7 @@ toughness=3 [/card] [card] name=Rubblehulk -auto=type:land:mybattlefield/type:land:mybattlefield cdaactive +anyzone=type:land:mybattlefield/type:land:mybattlefield cdaactive autohand={1}{R}{G}{discard}:name(bloodrush) target(creature[attacking]) type:land:mybattlefield/type:land:mybattlefield ueot text=Rubblehulk's power and toughness are each equal to the number of lands you control. -- Bloodrush — {1}{R}{G}, Discard Rubblehulk: Target attacking creature gets +X/+X until end of turn, where X is the number of lands you control. mana={4}{R}{G} @@ -82362,7 +82362,7 @@ type=Artifact [card] name=Rusting Golem auto=fading:5 -auto=counter{0%0.1.Fade}/counter{0%0.1.Fade} cdaactive +anyzone=counter{0%0.1.Fade}/counter{0%0.1.Fade} cdaactive text=Fading 5 (This creature enters the battlefield with five fade counters on it. At the beginning of your upkeep, remove a fade counter from it. If you can't, sacrifice it.) -- Rusting Golem's power and toughness are each equal to the number of fade counters on it. mana={4} type=Artifact Creature @@ -84429,7 +84429,7 @@ toughness=1 [/card] [card] name=Scion of the Wild -auto=type:creature:myBattlefield/type:creature:myBattlefield cdaactive +anyzone=type:creature:myBattlefield/type:creature:myBattlefield cdaactive text=Scion of the Wild's power and toughness are each equal to the number of creatures you control. mana={1}{G}{G} type=Creature @@ -86546,7 +86546,7 @@ toughness=3 name=Serpent of the Endless Sea abilities=cantattack auto=aslongas(island|opponentBattlefield) -cantattack -auto=type:island:myBattlefield/type:island:myBattlefield cdaactive +anyzone=type:island:myBattlefield/type:island:myBattlefield cdaactive text=Serpent of the Endless Sea's power and toughness are each equal to the number of Islands you control. -- Serpent of the Endless Sea can't attack unless defending player controls an Island. mana={4}{U} type=Creature @@ -86619,7 +86619,7 @@ toughness=1 [/card] [card] name=Serra Avatar -auto=lifetotal/lifetotal cdaactive +anyzone=lifetotal/lifetotal cdaactive autograveyard=moveTo(ownerlibrary) && shuffle text=Serra Avatar's power and toughness are each equal to your life total. -- When Serra Avatar is put into a graveyard from anywhere, shuffle it into its owner's library. mana={4}{W}{W}{W} @@ -89377,7 +89377,7 @@ toughness=5 [/card] [card] name=Sima Yi, Wei Field Marshal -auto=type:swamp:myBattlefield/4 cdaactive +anyzone=type:swamp:myBattlefield/4 cdaactive text=Sima Yi, Wei Field Marshal's power is equal to the number of Swamps you control. mana={5}{B} type=Legendary Creature @@ -90842,7 +90842,7 @@ toughness=3 [card] name=Skyshroud War Beast abilities=trample -auto=type:land[-basic]:opponentBattlefield/type:land[-basic]:opponentBattlefield cdaactive +anyzone=type:land[-basic]:opponentBattlefield/type:land[-basic]:opponentBattlefield cdaactive text=Trample -- As Skyshroud War Beast enters the battlefield, choose an opponent. -- Skyshroud War Beast's power and toughness are each equal to the number of nonbasic lands the chosen player controls. mana={1}{G} type=Creature @@ -90926,7 +90926,7 @@ toughness=3 [/card] [card] name=Slag Fiend -auto=type:artifact:graveyard/type:artifact:graveyard cdaactive +anyzone=type:artifact:graveyard/type:artifact:graveyard cdaactive text=Slag Fiend's power and toughness are each equal to the number of artifact cards in all graveyards. mana={R} type=Creature @@ -92448,7 +92448,7 @@ toughness=1 [card] name=Soramaro, First to Dream abilities=flying -auto=type:*:myhand/type:*:myhand cdaactive +anyzone=type:*:myhand/type:*:myhand cdaactive auto={4}{H(land|myBattlefield)}:draw:1 text=Flying -- Soramaro, First to Dream's power and toughness are each equal to the number of cards in your hand. -- {4}, Return a land you control to its owner's hand: Draw a card. mana={4}{U}{U} @@ -93035,7 +93035,7 @@ toughness=2 [/card] [card] name=Soulless One -auto=pgbzombie/pgbzombie cdaactive +anyzone=pgbzombie/pgbzombie cdaactive text=Soulless One's power and toughness are each equal to the number of Zombies on the battlefield plus the number of Zombie cards in all graveyards. mana={3}{B} type=Creature @@ -93092,7 +93092,7 @@ type=Instant [card] name=Soulsurge Elemental abilities=first strike -auto=type:creature:myBattlefield/1 cdaactive +anyzone=type:creature:myBattlefield/1 cdaactive text=First strike -- Soulsurge Elemental's power is equal to the number of creatures you control. mana={3}{R} type=Creature @@ -93637,7 +93637,7 @@ toughness=1 [card] name=Spellheart Chimera abilities=flying,trample -auto=pginstantsorcery/3 cdaactive +anyzone=pginstantsorcery/3 cdaactive text=Flying. -- Trample. -- Spellheart Chimera's power is equal to the number of instant and sorcery cards in your graveyard. mana={1}{U}{R} type=Creature @@ -94632,7 +94632,7 @@ color=green [card] name=Splinterfright abilities=trample -auto=type:creature:mygraveyard/type:creature:mygraveyard cdaactive +anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive auto=@each my upkeep:deplete:2 controller text=Trample -- Splinterfright's power and toughness are each equal to the number of creature cards in your graveyard -- At the beginning of your upkeep, put the top two cards of your library into your graveyard. mana={2}{G} @@ -95035,7 +95035,7 @@ type=Enchantment [/card] [card] name=Squelching Leeches -auto=type:swamp:myBattlefield/type:swamp:myBattlefield cdaactive +anyzone=type:swamp:myBattlefield/type:swamp:myBattlefield cdaactive text=Squelching Leeches's power and toughness are each equal to the number of Swamps you control. mana={2}{B}{B} type=Creature @@ -97237,7 +97237,7 @@ toughness=6 [card] name=Sturmgeist abilities=flying -auto=type:*:myhand/type:*:myhand cdaactive +anyzone=type:*:myhand/type:*:myhand cdaactive auto=@combatdamaged(player) from(this):draw:1 controller text=Flying -- Sturmgeist's power and toughness are each equal to the number of cards in your hand. -- Whenever Sturmgeist deals combat damage to a player, draw a card. mana={3}{U}{U} @@ -98406,7 +98406,7 @@ toughness=0 [/card] [card] name=Swarm of Rats -auto=type:rat:mybattlefield/1 cdaactive +anyzone=type:rat:mybattlefield/1 cdaactive text=Swarm of Rats's power is equal to the number of Rats you control. mana={1}{B} type=Creature @@ -98894,7 +98894,7 @@ type=Sorcery [/card] [card] name=Sylvan Yeti -auto=type:*:myhand/4 cdaactive +anyzone=type:*:myhand/4 cdaactive text=Sylvan Yeti's power is equal to the number of cards in your hand. mana={2}{G}{G} type=Creature @@ -99740,7 +99740,7 @@ toughness=7 [/card] [card] name=Tarmogoyf -auto=gravecardtypes/plusonegravecardtypes cdaactive +anyzone=gravecardtypes/plusonegravecardtypes cdaactive text=Tarmogoyf's power is equal to the number of card types among cards in all graveyards and its toughness is equal to that number plus 1. (The card types are artifact, creature, enchantment, instant, land, planeswalker, sorcery, and tribal.) mana={1}{G} type=Creature @@ -100774,7 +100774,7 @@ type=Artifact [card] name=Terravore abilities=trample -auto=type:land:graveyard/type:land:graveyard cdaactive +anyzone=type:land:graveyard/type:land:graveyard cdaactive text=Trample -- Terravore's power and toughness are each equal to the number of land cards in all graveyards. mana={1}{G}{G} type=Creature @@ -102693,7 +102693,7 @@ toughness=5 [card] name=Tidewalker auto=foreach(island|myBattlefield) counter(0/0,1,Time) oneshot -auto=counter{0%0.1.Time}/counter{0%0.1.Time} cdaactive +anyzone=counter{0%0.1.Time}/counter{0%0.1.Time} cdaactive auto=vanishing:0 text=Tidewalker enters the battlefield with a time counter on it for each Island you control. -- Vanishing (At the beginning of your upkeep, remove a time counter from this permanent. When the last is removed, sacrifice it.) -- Tidewalker's power and toughness are each equal to the number of time counters on it. mana={2}{U} @@ -105860,7 +105860,7 @@ toughness=2 [/card] [card] name=Uktabi Wildcats -auto=type:forest:mybattlefield/type:forest:mybattlefield cdaactive +anyzone=type:forest:mybattlefield/type:forest:mybattlefield cdaactive auto={G}{S(forest|myBattlefield)}:regenerate text=Uktabi Wildcats's power and toughness are each equal to the number of Forests you control. -- {G}, Sacrifice a Forest: Regenerate Uktabi Wildcats. mana={4}{G} @@ -105998,7 +105998,7 @@ type=Artifact [/card] [card] name=Umbra Stalker -auto=type:manab:mygraveyard/type:manab:mygraveyard cdaactive +anyzone=type:manab:mygraveyard/type:manab:mygraveyard cdaactive text=Chroma - Umbra Stalker's power and toughness are each equal to the number of black mana symbols in the mana costs of cards in your graveyard. mana={4}{B}{B}{B} type=Creature @@ -109908,7 +109908,7 @@ toughness=2 name=Elemental type=Creature subtype=Elemental -auto=type:creature:mybattlefield/type:creature:mybattlefield cdaactive +anyzone=type:creature:mybattlefield/type:creature:mybattlefield cdaactive text=This creature's power and toughness are each equal to the number of creature cards in its controller's battlefield. power=* toughness=* @@ -112185,7 +112185,7 @@ toughness=3 [/card] [card] name=Wayfaring Temple -auto=type:creature:mybattlefield/type:creature:mybattlefield cdaactive +anyzone=type:creature:mybattlefield/type:creature:mybattlefield cdaactive auto=@combatdamaged(player) from(this) restriction{type(creature[token]|mybattlefield)~morethan~0}:name(populate) clone notatarget(creature[token]|mybattlefield) text=Wayfaring Temple's power and toughness are each equal to the number of creatures you control. -- Whenever Wayfaring Temple deals combat damage to a player, populate. (Put a token onto the battlefield that's a copy of a creature token you control.) mana={1}{G}{W} @@ -113257,7 +113257,7 @@ toughness=4 [card] name=Wilderness Elemental abilities=trample -auto=type:land[-basic]:opponentbattlefield/3 cdaactive +anyzone=type:land[-basic]:opponentbattlefield/3 cdaactive text=Trample -- Wilderness Elemental's power is equal to the number of nonbasic lands your opponents control. mana={1}{R}{G} type=Creature @@ -115354,7 +115354,7 @@ type=Legendary Land [/card] [card] name=Yavimaya Kavu -auto=type:creature[red]:battlefield/type:creature[green]:battlefield cdaactive +anyzone=type:creature[red]:battlefield/type:creature[green]:battlefield cdaactive text=Yavimaya Kavu's power is equal to the number of red creatures on the battlefield. -- Yavimaya Kavu's toughness is equal to the number of green creatures on the battlefield. mana={2}{R}{G} type=Creature @@ -115776,7 +115776,7 @@ toughness=3 [/card] [card] name=Zendikar Incarnate -auto=type:land:mybattlefield/4 cdaactive +anyzone=type:land:mybattlefield/4 cdaactive text=Zendikar Incarnate's power is equal to the number of lands you control. mana={2}{R}{G} type=Creature diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 10e9d30cc..1cc5ecd0a 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -3080,7 +3080,11 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG } else if(s.find("cdaactive") != string::npos) { - return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true); + MTGAbility * a = NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true); + a->forcedAlive = 1; + a->forceDestroy = -1; + return a; + //return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true); } else return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,nonstatic); @@ -3751,7 +3755,7 @@ int AbilityFactory::getAbilities(vector * v, Spell * spell, MTGCar if (dest == zones->exile) { magicText = card->magicTexts["exile"]; - card->exileEffects = true; + card->exileEffects = true; break; } if (dest == zones->library) diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index 058c1d4c3..738d8289d 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -93,6 +93,16 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi } } } + if (key == "anyzone") + { + if (!primitive) primitive = NEW CardPrimitive(); + primitive->addMagicText(val,"hand"); + primitive->addMagicText(val,"library"); + primitive->addMagicText(val,"graveyard"); + primitive->addMagicText(val,"stack"); + primitive->addMagicText(val,"exile"); + primitive->addMagicText(val); + } break; case 'b': //buyback From e35c9f6087c7b40e1f0426279b9513835b014b1f Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 7 Nov 2015 09:59:30 +0800 Subject: [PATCH 08/22] AI plays zerocast cards, Update Rules folder! Its basic pay zero for now... Omniscience is possible :) --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 13 ++++ projects/mtg/include/MTGAbility.h | 2 +- projects/mtg/src/AIPlayerBaka.cpp | 66 ++++++++++++++++++-- projects/mtg/src/MTGAbility.cpp | 2 +- projects/mtg/src/MTGRules.cpp | 30 +++++---- 5 files changed, 96 insertions(+), 17 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index e33f7dbf8..bb577a278 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -11580,6 +11580,7 @@ toughness=2 [/card] [card] name=Boneyard Wurm +alias=001100 anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive text=Boneyard Wurm's power and toughness are each equal to the number of creature cards in your graveyard. mana={1}{G} @@ -14097,6 +14098,7 @@ type=Sorcery [/card] [card] name=Cantivore +alias=001100 abilities=vigilance anyzone=type:enchantment:graveyard/type:enchantment:graveyard cdaactive text=Vigilance -- Cantivore's power and toughness are each equal to the number of enchantment cards in all graveyards. @@ -18065,6 +18067,7 @@ type=Instant [/card] [card] name=Cognivore +alias=001100 abilities=flying anyzone=type:instant:graveyard/type:instant:graveyard cdaactive text=Flying -- Cognivore's power and toughness are each equal to the number of instant cards in all graveyards. @@ -24371,6 +24374,7 @@ text=Destroy target artifact with converted mana cost X. It can't be regenerated [/card] [card] name=Detritivore +alias=001100 anyzone=type:land[-basic]:opponentgraveyard/type:land[-basic]:opponentgraveyard cdaactive autoexile=@counterremoved(0/0,1,Time) from(sourcecard) suspended:destroy target(land[-basic]) suspend(0)={X}{3}{R} @@ -56072,6 +56076,7 @@ toughness=5 [/card] [card] name=Lhurgoyf +alias=001100 anyzone=type:creature:graveyard/plusonetype:creature:graveyard cdaactive text=Lhurgoyf's power is equal to the number of creature cards in all graveyards and its toughness is equal to that number plus 1. mana={2}{G}{G} @@ -57452,6 +57457,7 @@ toughness=2 [/card] [card] name=Lord of Extinction +alias=001100 anyzone=type:*:graveyard/type:*:graveyard cdaactive text=Lord of Extinction's power and toughness are each equal to the number of cards in all graveyards. mana={3}{B}{G} @@ -58816,6 +58822,7 @@ toughness=6 [/card] [card] name=Magnivore +alias=001100 abilities=haste anyzone=type:sorcery:graveyard/type:sorcery:graveyard cdaactive text=Haste (This creature can attack the turn it comes under your control.) -- Magnivore's power and toughness are each equal to the number of sorcery cards in all graveyards. @@ -64584,6 +64591,7 @@ toughness=2 [/card] [card] name=Mortivore +alias=001100 auto={B}:regenerate anyzone=type:creature:graveyard/type:creature:graveyard cdaactive text=Mortivore's power and toughness are each equal to the number of creature cards in all graveyards. -- {B}: Regenerate Mortivore. (The next time this creature would be destroyed this turn, it isn't. Instead tap it, remove all damage from it, and remove it from combat.) @@ -79780,6 +79788,7 @@ type=Artifact [/card] [card] name=Revenant +alias=001100 abilities=flying anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive text=Flying -- Revenant's power and toughness are each equal to the number of creature cards in your graveyard. @@ -90926,6 +90935,7 @@ toughness=3 [/card] [card] name=Slag Fiend +alias=001100 anyzone=type:artifact:graveyard/type:artifact:graveyard cdaactive text=Slag Fiend's power and toughness are each equal to the number of artifact cards in all graveyards. mana={R} @@ -94631,6 +94641,7 @@ color=green [/card] [card] name=Splinterfright +alias=001100 abilities=trample anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive auto=@each my upkeep:deplete:2 controller @@ -100773,6 +100784,7 @@ type=Artifact [/card] [card] name=Terravore +alias=001100 abilities=trample anyzone=type:land:graveyard/type:land:graveyard cdaactive text=Trample -- Terravore's power and toughness are each equal to the number of land cards in all graveyards. @@ -105998,6 +106010,7 @@ type=Artifact [/card] [card] name=Umbra Stalker +alias=001100 anyzone=type:manab:mygraveyard/type:manab:mygraveyard cdaactive text=Chroma - Umbra Stalker's power and toughness are each equal to the number of black mana symbols in the mana costs of cards in your graveyard. mana={4}{B}{B}{B} diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index af8cbbeee..70d6344b9 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -213,7 +213,7 @@ public: COUNTERS = 30, PUT_INTO_PLAY_WITH_KICKER = 31, STANDARD_FIZZLER = 32, - CASTINGRAVEEXILE_COST = 33, + PAYZERO_COST = 33, }; }; diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index e0d269e69..634414632 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -631,10 +631,6 @@ int OrderedAIAction::getEfficiency() { efficiency += 55; } - else if (dynamic_cast(a)) - { - efficiency += 45; - } SAFE_DELETE(transAbility); return efficiency; } @@ -1838,6 +1834,10 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty { shouldPlayPercentage = 90; } + else if (!card->isLand() && card->has(Constants::PAYZERO)) + { + shouldPlayPercentage = 70; + } else { // shouldPlay == baka_effect_bad giving it a 1 for odd ball lottery chance. @@ -1986,6 +1986,10 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty { shouldPlayPercentage = 90; } + else if (!card->isLand() && card->has(Constants::PAYZERO)) + { + shouldPlayPercentage = 70; + } else { // shouldPlay == baka_effect_bad giving it a 1 for odd ball lottery chance. @@ -2133,6 +2137,10 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty { shouldPlayPercentage = 90; } + else if (!card->isLand() && card->has(Constants::PAYZERO)) + { + shouldPlayPercentage = 70; + } else { // shouldPlay == baka_effect_bad giving it a 1 for odd ball lottery chance. @@ -2413,6 +2421,56 @@ int AIPlayerBaka::computeActions() nextCardToPlay = NULL; count++; } + + if(nextCardToPlay == NULL)//check if there is a free card to play, play it.... + {//TODO: add potential mana if we can pay if there is a cost increaser in play + CardDescriptor cd; + if (game->hand->hasAbility(Constants::PAYZERO)) + { + //Attempt to put free cards into play + cd.init(); + cd.SetExclusionColor(Constants::MTG_COLOR_LAND); + MTGCardInstance *freecard = cd.match(game->hand); + int canCastCard = game->playRestrictions->canPutIntoZone(freecard, game->inPlay); + if (freecard && (canCastCard == PlayRestriction::CAN_PLAY) && freecard->has(Constants::PAYZERO) && (freecard->getIncreasedManaCost()->getConvertedCost() < 1)) + { + MTGAbility * castFreeCard = observer->mLayers->actionLayer()->getAbility(MTGAbility::PAYZERO_COST); + AIAction * aa = NEW AIAction(this, castFreeCard, freecard); //TODO putinplay action + clickstream.push(aa); + break; + } + } + if (game->graveyard->hasAbility(Constants::PAYZERO) && game->graveyard->hasAbility(Constants::CANPLAYFROMGRAVEYARD)) + { + //Attempt to put free cards into play + cd.init(); + cd.SetExclusionColor(Constants::MTG_COLOR_LAND); + MTGCardInstance *freecard = cd.match(game->graveyard); + int canCastCard = game->playRestrictions->canPutIntoZone(freecard, game->inPlay); + if (freecard && (canCastCard == PlayRestriction::CAN_PLAY) && freecard->has(Constants::PAYZERO) && freecard->has(Constants::CANPLAYFROMGRAVEYARD) && (freecard->getIncreasedManaCost()->getConvertedCost() < 1) && (freecard->alias != 001100)) + { + MTGAbility * castFreeCard = observer->mLayers->actionLayer()->getAbility(MTGAbility::PAYZERO_COST); + AIAction * aa = NEW AIAction(this, castFreeCard, freecard); //TODO putinplay action + clickstream.push(aa); + break; + } + } + if (game->exile->hasAbility(Constants::PAYZERO) && game->exile->hasAbility(Constants::CANPLAYFROMEXILE)) + { + //Attempt to put free cards into play + cd.init(); + cd.SetExclusionColor(Constants::MTG_COLOR_LAND); + MTGCardInstance *freecard = cd.match(game->exile); + int canCastCard = game->playRestrictions->canPutIntoZone(freecard, game->inPlay); + if (freecard && (canCastCard == PlayRestriction::CAN_PLAY) && freecard->has(Constants::PAYZERO) && freecard->has(Constants::CANPLAYFROMEXILE) && (freecard->getIncreasedManaCost()->getConvertedCost() < 1) && (freecard->alias != 001100)) + { + MTGAbility * castFreeCard = observer->mLayers->actionLayer()->getAbility(MTGAbility::PAYZERO_COST); + AIAction * aa = NEW AIAction(this, castFreeCard, freecard); //TODO putinplay action + clickstream.push(aa); + break; + } + } + }//end } SAFE_DELETE(currentMana); diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 1cc5ecd0a..bcb131764 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1156,7 +1156,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG observer->addObserver(NEW MTGMorphCostRule(observer, -1)); return NULL; } - found = s.find("playfromgraveyardrule"); + found = s.find("payzerorule"); if(found != string::npos) { observer->addObserver(NEW MTGPayZeroRule(observer, -1)); diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 03b6dc136..d43c870ac 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -489,7 +489,11 @@ int MTGKickerRule::isReactingToClick(MTGCardInstance * card, ManaCost *) } ManaCost * playerMana = player->getManaPool(); ManaCost * withKickerCost= NEW ManaCost(card->model->data->getManaCost()); - withKickerCost->add(withKickerCost->getKicker()); + if(card->getIncreasedManaCost()->getConvertedCost()) + withKickerCost->add(card->getIncreasedManaCost()); + if(card->getReducedManaCost()->getConvertedCost()) + withKickerCost->remove(card->getReducedManaCost()); + withKickerCost->add(card->model->data->getManaCost()->getKicker()); if(!playerMana->canAfford(withKickerCost)) { delete withKickerCost; @@ -508,11 +512,15 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card) Player * player = game->currentlyActing(); ManaCost * withKickerCost= NEW ManaCost(card->model->data->getManaCost());//using pointers here alters the real cost of the card. - if (card->getManaCost()->getKicker()->isMulti) + if(card->getIncreasedManaCost()->getConvertedCost()) + withKickerCost->add(card->getIncreasedManaCost()); + if(card->getReducedManaCost()->getConvertedCost()) + withKickerCost->remove(card->getReducedManaCost()); + if (card->model->data->getManaCost()->getKicker()->isMulti) { while(player->getManaPool()->canAfford(withKickerCost)) { - withKickerCost->add(withKickerCost->getKicker()); + withKickerCost->add(card->model->data->getManaCost()->getKicker()); card->kicked += 1; } card->kicked -= 1; @@ -522,7 +530,7 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card) } else { - withKickerCost->add(withKickerCost->getKicker()); + withKickerCost->add(card->model->data->getManaCost()->getKicker()); card->paymenttype = MTGAbility::PUT_INTO_PLAY_WITH_KICKER; } if (withKickerCost->isExtraPaymentSet()) @@ -638,9 +646,9 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * if(card->has(Constants::CANPLAYFROMGRAVEYARD)) - alternativeName = "Alternate Cast Card From Graveyard"; + alternativeName = "Alternate Cast From Graveyard"; else if(card->has(Constants::CANPLAYFROMEXILE)) - alternativeName = "Alternate Cast Card From Exile"; + alternativeName = "Alternate Cast From Exile"; else if(card->model->data->getManaCost()->getAlternative() && card->model->data->getManaCost()->getAlternative()->alternativeName.size()) alternativeName = card->model->data->getManaCost()->getAlternative()->alternativeName; @@ -1145,7 +1153,7 @@ MTGMorphCostRule * MTGMorphCostRule::clone() const MTGPayZeroRule::MTGPayZeroRule(GameObserver* observer, int _id) : MTGAlternativeCostRule(observer, _id) { - aType = MTGAbility::CASTINGRAVEEXILE_COST; + aType = MTGAbility::PAYZERO_COST; } int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) @@ -1166,11 +1174,11 @@ int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card))) return 0; if(card->has(Constants::CANPLAYFROMGRAVEYARD)) - CustomName = "Pay Zero To Cast From Graveyard"; + CustomName = "Zero Cast From Graveyard"; else if(card->has(Constants::CANPLAYFROMEXILE)) - CustomName = "Pay Zero To Cast From Exile"; + CustomName = "Zero Cast From Exile"; else - CustomName = "Pay Zero To Cast"; + CustomName = "Zero Cast From Anywhere"; return MTGAlternativeCostRule::isReactingToClick(card, mana, cost); } @@ -1182,7 +1190,7 @@ int MTGPayZeroRule::reactToClick(MTGCardInstance * card) ManaCost * cost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL)); - card->paymenttype = MTGAbility::CASTINGRAVEEXILE_COST; + card->paymenttype = MTGAbility::PAYZERO_COST; return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID); } From efdc4071da960a1056a6b382e45aaa003abbfc2b Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 7 Nov 2015 10:45:54 +0800 Subject: [PATCH 09/22] comment --- projects/mtg/bin/Res/sets/primitives/unsupported.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/mtg/bin/Res/sets/primitives/unsupported.txt b/projects/mtg/bin/Res/sets/primitives/unsupported.txt index 6338488fa..be4eec13f 100644 --- a/projects/mtg/bin/Res/sets/primitives/unsupported.txt +++ b/projects/mtg/bin/Res/sets/primitives/unsupported.txt @@ -12498,6 +12498,7 @@ text=Pyrotechnics deals 4 damage divided as you choose among any number of targe mana={4}{R} type=Sorcery [/card] +#anyzone is basic for now and used for cdaactive [card] name=Qasali Ambusher text=Reach -- If a creature is attacking you and you control a Forest and a Plains, you may cast Qasali Ambusher without paying its mana cost and as though it had flash. @@ -12812,6 +12813,7 @@ mana={2}{U} type=Enchantment subtype=Aura [/card] +#needs suspend ability not suspend activated ability [card] name=Reality Strobe text=Return target permanent to its owner's hand. Exile Reality Strobe with three time counters on it. -- Suspend 3 - {2}{U} (Rather than cast this card from your hand, you may pay {2}{U} and exile it with three time counters on it. At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost.) From 6f4cf9e941b542a9aa147f363957809483b4694d Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 7 Nov 2015 19:16:31 +0800 Subject: [PATCH 10/22] Aluren & Omniscience MayAbility + resolve instead of MenuAbility + addtogame for dredge??? --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 15 +++++++ .../bin/Res/sets/primitives/unsupported.txt | 10 ++--- projects/mtg/include/MTGRules.h | 16 +++---- projects/mtg/src/MTGRules.cpp | 42 ++++++++++--------- 4 files changed, 50 insertions(+), 33 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index bb577a278..31a52ec1f 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -2405,6 +2405,14 @@ mana={1}{B}{S(creature|mybattlefield)} type=Instant [/card] [card] +name=Aluren +auto=lord(creature[manacost<=3]|hand,exile,graveyard) zerocast forcedalive +auto=lord(creature[manacost<=3]|hand,exile,graveyard) spellmastery forcedalive +text=Any player may play creature cards with converted mana cost 3 or less without paying their mana cost and as though they had flash. +mana={2}{G}{G} +type=Enchantment +[/card] +[card] name=Amass the Components auto=draw:3 controller auto=bottomoflibrary notatarget(*|myhand) @@ -69047,6 +69055,13 @@ power=3 toughness=3 [/card] [card] +name=Omniscience +auto=lord(*[-land]|myhand) zerocast forcedalive +text=You may cast nonland cards from your hand without paying their mana costs. +mana={7}{U}{U}{U} +type=Enchantment +[/card] +[card] name=Ondu Cleric auto=may life:type:ally:mybattlefield controller auto=@movedTo(other ally|myBattlefield):may life:type:ally:mybattlefield controller diff --git a/projects/mtg/bin/Res/sets/primitives/unsupported.txt b/projects/mtg/bin/Res/sets/primitives/unsupported.txt index be4eec13f..be85531ce 100644 --- a/projects/mtg/bin/Res/sets/primitives/unsupported.txt +++ b/projects/mtg/bin/Res/sets/primitives/unsupported.txt @@ -224,12 +224,6 @@ mana={1}{U} type=Instant [/card] [card] -name=Aluren -text=Any player may play creature cards with converted mana cost 3 or less without paying their mana cost and as though they had flash. -mana={2}{G}{G} -type=Enchantment -[/card] -[card] name=Amber Prison text=You may choose not to untap Amber Prison during your untap step. -- {4}, {T}: Tap target artifact, creature, or land. That permanent doesn't untap during its controller's untap step for as long as Amber Prison remains tapped. mana={4} @@ -3954,6 +3948,7 @@ subtype=Djinn power=3 toughness=5 [/card] +#needs alias borderline [card] name=Djinn of Wishes text=Flying -- Djinn of Wishes enters the battlefield with three wish counters on it. -- {2}{U}{U}, Remove a wish counter from Djinn of Wishes: Reveal the top card of your library. You may play that card without paying its mana cost. If you don't, exile it. @@ -8742,6 +8737,7 @@ text=Look at the top five cards of your library. You may reveal any number of cr mana={2}{G} type=Sorcery [/card] +#needs alias borderline [card] name=Leaf-Crowned Elder text=Kinship - At the beginning of your upkeep, you may look at the top card of your library. If it shares a creature type with Leaf-Crowned Elder, you may reveal it. If you do, you may play that card without paying its mana cost. @@ -9863,6 +9859,7 @@ text=Each opponent reveals cards from the top of his or her library until he or mana={X}{U}{B} type=Sorcery [/card] +#needs alias [card] name=Mind's Desire text=Shuffle your library. Then exile the top card of your library. Until end of turn, you may play that card without paying its mana cost. (If it has X in its mana cost, X is 0.) -- Storm (When you cast this spell, copy it for each spell cast before it this turn.) @@ -11075,6 +11072,7 @@ text=Look at the top three cards of your library, then put them back in any orde mana={1}{U} type=Sorcery [/card] +#needs alias [card] name=Omen Machine mana={6} diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index f617f556a..19fc9775c 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -298,15 +298,15 @@ public: class MTGDredgeRule: public PermanentAbility, public ReplacementEffect { public: - vectorsoulbonders; + //vectorsoulbonders; TargetChooser * tcb; - MTGAbility * dredgeAbility; - MTGAbility * targetAbility; - MTGAbility * targetAbilityAdder; - MTGAbility * targetAbility1; - MTGAbility * mod; - MTGAbility * activateDredge; - vectorpairing; + //MTGAbility * dredgeAbility; + //MTGAbility * targetAbility; + //MTGAbility * targetAbilityAdder; + //MTGAbility * targetAbility1; + //MTGAbility * mod; + //MTGAbility * activateDredge; + //vectorpairing; MTGDredgeRule(GameObserver* observer, int _id); WEvent * replace(WEvent *e); virtual ostream& toString(ostream& out) const; diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index d43c870ac..d2bd12990 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -1189,6 +1189,10 @@ int MTGPayZeroRule::reactToClick(MTGCardInstance * card) return 0; ManaCost * cost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL)); + if(card->getIncreasedManaCost()->getConvertedCost()) + cost->add(card->getIncreasedManaCost()); + if(card->getReducedManaCost()->getConvertedCost()) + cost->remove(card->getReducedManaCost()); card->paymenttype = MTGAbility::PAYZERO_COST; @@ -2190,9 +2194,9 @@ MTGDredgeRule::MTGDredgeRule(GameObserver* observer, int _id) : PermanentAbility(observer, _id) { tcb = NULL; - dredgeAbility = NULL; - targetAbility = NULL; - mod = NULL; + //dredgeAbility = NULL; + //targetAbility = NULL; + //mod = NULL; } ; @@ -2249,26 +2253,26 @@ WEvent * MTGDredgeRule::replace(WEvent * event) } //there is a memleak here that i have no idea what causes it. - dredgeAbility = NEW dredgeCard(game, game->mLayers->actionLayer()->getMaxId(), card,NULL); - dredgeAbility->oneShot = true; - targetAbility = NEW GenericTargetAbility(game, "Dredge A Card","",game->mLayers->actionLayer()->getMaxId(), card,tcb->clone(),dredgeAbility->clone()); - targetAbility->oneShot = true; - SAFE_DELETE(dredgeAbility); + dredgeCard *dc = NEW dredgeCard(game, game->mLayers->actionLayer()->getMaxId(), card,NULL); + dc->oneShot = true; + GenericTargetAbility *gta = NEW GenericTargetAbility(game, "Dredge A Card","",game->mLayers->actionLayer()->getMaxId(), card,tcb->clone(),dc->clone()); + gta->oneShot = true; + //SAFE_DELETE(dredgeAbility); - targetAbilityAdder = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), card,NULL,targetAbility->clone()); - targetAbilityAdder->oneShot = true; - SAFE_DELETE(targetAbility); - MTGAbility * setDredge = targetAbilityAdder->clone(); - SAFE_DELETE(targetAbilityAdder); - setDredge->oneShot = true; + GenericAddToGame *gatg = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), card,NULL,gta->clone()); + gatg->oneShot = true; + //SAFE_DELETE(targetAbility); + //MTGAbility * setDredge = targetAbilityAdder->clone(); + //SAFE_DELETE(targetAbilityAdder); + //setDredge->oneShot = true; - selection.push_back(setDredge); - targetAbility1 = NEW AADrawer(game, this->GetId(), card,card,NULL, "1",TargetChooser::CONTROLLER,true); - selection.push_back(targetAbility1); - MTGAbility * menuChoice = NEW MenuAbility(game, this->GetId(), card, card,true,selection,card->controller(),"Dredge or Draw"); + selection.push_back(gatg); + AADrawer *ad = NEW AADrawer(game, game->mLayers->actionLayer()->getMaxId(), card,card,NULL, "1",TargetChooser::CONTROLLER,true); + selection.push_back(ad); + MenuAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Dredge or Draw"); menuChoice->addToGame(); - SAFE_DELETE(tcb); + //SAFE_DELETE(tcb); } SAFE_DELETE(event); From a22991758f78cff20868cad3f4e89f22fa44dba4 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sun, 8 Nov 2015 18:18:33 +0800 Subject: [PATCH 11/22] mana producer for lands you/opponent could produce reflecting pool, exotic orchard... --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 84 ++++++++++++- .../bin/Res/sets/primitives/unsupported.txt | 44 +------ projects/mtg/include/AllAbilities.h | 110 ++++++++++++++++++ projects/mtg/src/CardGui.cpp | 2 + 4 files changed, 196 insertions(+), 44 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 31a52ec1f..fd72dec5b 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -31743,6 +31743,16 @@ mana={4}{B} type=Sorcery [/card] [card] +name=Exotic Orchard +auto=this(variable{olandg}>0) {t}:add{g} +auto=this(variable{olandu}>0) {t}:add{u} +auto=this(variable{olandr}>0) {t}:add{r} +auto=this(variable{olandb}>0) {t}:add{b} +auto=this(variable{olandw}>0) {t}:add{w} +text={T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. +type=Land +[/card] +[card] name=Expedition Map auto={2}{T}{S}:moveTo(ownerhand) target(land|myLibrary) text={2}, {T}, Sacrifice Expedition Map: Search your library for a land card, reveal it, and put it into your hand. Then shuffle your library. @@ -33223,6 +33233,17 @@ power=4 toughness=6 [/card] [card] +name=Fellwar Stone +auto=this(variable{olandg}>0) {t}:add{g} +auto=this(variable{olandu}>0) {t}:add{u} +auto=this(variable{olandr}>0) {t}:add{r} +auto=this(variable{olandb}>0) {t}:add{b} +auto=this(variable{olandw}>0) {t}:add{w} +text={T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. +mana={2} +type=Artifact +[/card] +[card] name=Femeref Archers auto={T}:damage:4 target(creature[attacking;flying]) text={T}: Femeref Archers deals 4 damage to target attacking creature with flying. @@ -34522,6 +34543,15 @@ power=2 toughness=3 [/card] [card] +name=Flame Wave +target=player +auto=damage:4 +auto=damage:4 all(creature|targetedpersonsbattlefield) +text=Flame Wave deals 4 damage to target player and each creature he or she controls. +mana={3}{R}{R}{R}{R} +type=Sorcery +[/card] +[card] name=Flameblast Dragon abilities=flying auto=this(attacking) {X}{R}:thisforeach(X) damage:1 target(creature,player) limit:1 @@ -36843,7 +36873,7 @@ type=Sorcery [/card] [card] name=Fumiko the Lowblood -auto=bushido(type:creature[attacking]:battlefield/type:creature[attacking]:battlefield) +auto=aslongas(creature[attacking]) bushido(type:creature[attacking]:battlefield/type:creature[attacking]:battlefield) auto=lord(creature|opponentBattlefield) mustattack text=Fumiko the Lowblood has bushido X, where X is the number of attacking creatures. (When this blocks or becomes blocked, it gets +X/+X until end of turn.) -- Creatures your opponents control attack each turn if able. mana={2}{R}{R} @@ -44122,6 +44152,20 @@ power=3 toughness=2 [/card] [card] +name=Harvester Druid +auto=this(variable{plandg}>0) {t}:add{g} +auto=this(variable{plandu}>0) {t}:add{u} +auto=this(variable{plandr}>0) {t}:add{r} +auto=this(variable{plandb}>0) {t}:add{b} +auto=this(variable{plandw}>0) {t}:add{w} +text={T}: Add to your mana pool one mana of any color that a land you control could produce. +mana={1}{G} +type=Creature +subtype=Human Druid +power=1 +toughness=1 +[/card] +[card] name=Harvester of Souls abilities=deathtouch auto=@movedTo(other creature[-token]|graveyard) from(battlefield):draw:1 controller @@ -76353,6 +76397,20 @@ power=1 toughness=1 [/card] [card] +name=Quirion Explorer +auto=this(variable{olandg}>0) {t}:add{g} +auto=this(variable{olandu}>0) {t}:add{u} +auto=this(variable{olandr}>0) {t}:add{r} +auto=this(variable{olandb}>0) {t}:add{b} +auto=this(variable{olandw}>0) {t}:add{w} +text={T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. +mana={1}{G} +type=Creature +subtype=Elf Druid Scout +power=1 +toughness=1 +[/card] +[card] name=Quirion Ranger auto={H(forest|myBattlefield)}:untap target(creature) limit:1 text=Return a Forest you control to its owner's hand: Untap target creature. Activate this ability only once each turn. @@ -78703,6 +78761,16 @@ power=0 toughness=2 [/card] [card] +name=Reflecting Pool +auto=this(variable{plandg}>0) {t}:add{g} +auto=this(variable{plandu}>0) {t}:add{u} +auto=this(variable{plandr}>0) {t}:add{r} +auto=this(variable{plandb}>0) {t}:add{b} +auto=this(variable{plandw}>0) {t}:add{w} +text={T}: Add to your mana pool one mana of any type that a land you control could produce. +type=Land +[/card] +[card] name=Reflex Sliver auto=lord(sliver) haste text=All Sliver creatures have haste. @@ -98929,6 +98997,20 @@ power=* toughness=4 [/card] [card] +name=Sylvok Explorer +auto=this(variable{olandg}>0) {t}:add{g} +auto=this(variable{olandu}>0) {t}:add{u} +auto=this(variable{olandr}>0) {t}:add{r} +auto=this(variable{olandb}>0) {t}:add{b} +auto=this(variable{olandw}>0) {t}:add{w} +text={T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. +mana={1}{G} +type=Creature +subtype=Human Druid +power=1 +toughness=1 +[/card] +[card] name=Sylvok Lifestaff auto=1/0 auto=@movedTo(mytgt|graveyard) from(battlefield):all(trigger[to]) life:3 controller diff --git a/projects/mtg/bin/Res/sets/primitives/unsupported.txt b/projects/mtg/bin/Res/sets/primitives/unsupported.txt index be85531ce..22d44537e 100644 --- a/projects/mtg/bin/Res/sets/primitives/unsupported.txt +++ b/projects/mtg/bin/Res/sets/primitives/unsupported.txt @@ -4763,11 +4763,6 @@ power=1 toughness=2 [/card] [card] -name=Exotic Orchard -text={T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. -type=Land -[/card] -[card] name=Experiment Kraj text=Experiment Kraj has all activated abilities of each other creature with a +1/+1 counter on it. -- {T}: Put a +1/+1 counter on target creature. mana={2}{G}{G}{U}{U} @@ -4986,12 +4981,6 @@ type=Enchantment subtype=Aura [/card] [card] -name=Fellwar Stone -text={T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. -mana={2} -type=Artifact -[/card] -[card] name=Feral Contest text=Put a +1/+1 counter on target creature you control. Another target creature blocks it this turn if able. mana={3}{G} @@ -6861,15 +6850,6 @@ power=1 toughness=1 [/card] [card] -name=Harvester Druid -text={T}: Add to your mana pool one mana of any color that a land you control could produce. -mana={1}{G} -type=Creature -subtype=Human Druid -power=1 -toughness=1 -[/card] -[card] name=Hatred text=As an additional cost to cast Hatred, pay X life. -- Target creature gets +X/+0 until end of turn. mana={3}{B}{B} @@ -12614,15 +12594,6 @@ mana={1}{U} type=Sorcery [/card] [card] -name=Quirion Explorer -text={T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. -mana={1}{G} -type=Creature -subtype=Elf Druid Scout -power=1 -toughness=1 -[/card] -[card] name=R&D's Secret Lair mana= type=Legendary Land @@ -12923,11 +12894,6 @@ mana={4} type=Artifact [/card] [card] -name=Reflecting Pool -text={T}: Add to your mana pool one mana of any type that a land you control could produce. -type=Land -[/card] -[card] name=Refraction Trap text=If an opponent cast a red instant or sorcery spell this turn, you may pay {W} rather than pay Refraction Trap's mana cost. -- Prevent the next 3 damage that a source of your choice would deal to you and/or permanents you control this turn. If damage is prevented this way, Refraction Trap deals that much damage to target creature or player. mana={3}{W} @@ -15570,6 +15536,7 @@ subtype=Monger power=3 toughness=3 [/card] +#needs alias [card] name=Squandered Resources text=Sacrifice a land: Add to your mana pool one mana of any type the sacrificed land could produce. @@ -16214,15 +16181,6 @@ power=2 toughness=2 [/card] [card] -name=Sylvok Explorer -text={T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. -mana={1}{G} -type=Creature -subtype=Human Druid -power=1 -toughness=1 -[/card] -[card] name=Symbol Status mana={2}{G}{G} type=Sorcery diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 66b33ff29..015bd2176 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -668,6 +668,116 @@ private: { intValue = target->controller()->handsize; } + else if (s == "olandg") + { + intValue = 0; + for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) + {//start + MTGAbility * a = ((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i]); + AManaProducer * amp = dynamic_cast (a); + if (amp && amp->source->isLand() && amp->source->controller() == target->controller()->opponent() && amp->output->hasColor(1)) + intValue = 1; + }//end + } + else if (s == "olandu") + { + intValue = 0; + for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) + {//start + MTGAbility * a = ((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i]); + AManaProducer * amp = dynamic_cast (a); + if (amp && amp->source->isLand() && amp->source->controller() == target->controller()->opponent() && amp->output->hasColor(2)) + intValue = 1; + }//end + } + else if (s == "olandr") + { + intValue = 0; + for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) + {//start + MTGAbility * a = ((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i]); + AManaProducer * amp = dynamic_cast (a); + if (amp && amp->source->isLand() && amp->source->controller() == target->controller()->opponent() && amp->output->hasColor(3)) + intValue = 1; + }//end + } + else if (s == "olandb") + { + intValue = 0; + for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) + {//start + MTGAbility * a = ((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i]); + AManaProducer * amp = dynamic_cast (a); + if (amp && amp->source->isLand() && amp->source->controller() == target->controller()->opponent() && amp->output->hasColor(4)) + intValue = 1; + }//end + } + else if (s == "olandw") + { + intValue = 0; + for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) + {//start + MTGAbility * a = ((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i]); + AManaProducer * amp = dynamic_cast (a); + if (amp && amp->source->isLand() && amp->source->controller() == target->controller()->opponent() && amp->output->hasColor(5)) + intValue = 1; + }//end + } + else if (s == "plandg") + { + intValue = 0; + for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) + {//start + MTGAbility * a = ((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i]); + AManaProducer * amp = dynamic_cast (a); + if (amp && amp->source->isLand() && amp->source->controller() == target->controller() && amp->output->hasColor(1)) + intValue = 1; + }//end + } + else if (s == "plandu") + { + intValue = 0; + for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) + {//start + MTGAbility * a = ((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i]); + AManaProducer * amp = dynamic_cast (a); + if (amp && amp->source->isLand() && amp->source->controller() == target->controller() && amp->output->hasColor(2)) + intValue = 1; + }//end + } + else if (s == "plandr") + { + intValue = 0; + for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) + {//start + MTGAbility * a = ((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i]); + AManaProducer * amp = dynamic_cast (a); + if (amp && amp->source->isLand() && amp->source->controller() == target->controller() && amp->output->hasColor(3)) + intValue = 1; + }//end + } + else if (s == "plandb") + { + intValue = 0; + for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) + {//start + MTGAbility * a = ((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i]); + AManaProducer * amp = dynamic_cast (a); + if (amp && amp->source->isLand() && amp->source->controller() == target->controller() && amp->output->hasColor(4)) + intValue = 1; + }//end + } + else if (s == "plandw") + { + intValue = 0; + for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) + {//start + MTGAbility * a = ((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i]); + AManaProducer * amp = dynamic_cast (a); + if (amp && amp->source->isLand() && amp->source->controller() == target->controller() && amp->output->hasColor(5)) + intValue = 1; + }//end + } else if (s == "controllerturn")//intvalue = 1 if its your turn this(variable{controllerturn}) { intValue = 0; diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index 00fec3c32..9b53f9041 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -365,6 +365,8 @@ void CardGui::Render() buff = "CT"; if(!card->isToken && card->isACopier) buff = "C"; + if(game && card->has(Constants::PAYZERO) && ((card->currentZone == card->controller()->game->hand) || (card->has(Constants::CANPLAYFROMGRAVEYARD) && card->currentZone == card->controller()->game->graveyard) || (card->has(Constants::CANPLAYFROMEXILE) && card->currentZone == card->controller()->game->exile))) + buff += "Z"; if(card->alias == 0000) { if(card->chooseacolor == 1) From 4f9f84fc6ac056ec65a807a806318eaddfe62701 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sun, 8 Nov 2015 20:56:31 +0800 Subject: [PATCH 12/22] comment unsupported --- projects/mtg/bin/Res/sets/primitives/unsupported.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/mtg/bin/Res/sets/primitives/unsupported.txt b/projects/mtg/bin/Res/sets/primitives/unsupported.txt index 22d44537e..2ad1ef6c6 100644 --- a/projects/mtg/bin/Res/sets/primitives/unsupported.txt +++ b/projects/mtg/bin/Res/sets/primitives/unsupported.txt @@ -1217,6 +1217,7 @@ text=Blazing Salvo deals 3 damage to target creature unless that creature's cont mana={R} type=Instant [/card] +#blazing torch is source of damage but the equipped creature has the activated ability... weird [card] name=Blazing Torch text=Equipped creature can't be blocked by Vampires or Zombies. -- Equipped creature has "{T}, Sacrifice Blazing Torch: Blazing Torch deals 2 damage to target creature or player." -- Equip {1} From 406f68ac5b040d7201b8808c4ce716b44f612c12 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 9 Nov 2015 19:04:31 +0800 Subject: [PATCH 13/22] Overload Cards the alias is for the Overload Check and Alternate Cost Restriction... ???Bestow??? --- projects/mtg/bin/Res/rules/Blitzkrieg.txt | 2 + projects/mtg/bin/Res/rules/hermit.txt | 2 + projects/mtg/bin/Res/rules/mtg.txt | 3 +- projects/mtg/bin/Res/sets/primitives/mtg.txt | 152 ++++++++++++++++++ .../bin/Res/sets/primitives/unsupported.txt | 72 --------- projects/mtg/include/MTGAbility.h | 2 + projects/mtg/include/MTGCardInstance.h | 2 +- projects/mtg/include/MTGRules.h | 15 +- projects/mtg/include/ManaCost.h | 4 +- projects/mtg/src/ActionStack.cpp | 6 + projects/mtg/src/MTGAbility.cpp | 14 +- projects/mtg/src/MTGGameZones.cpp | 2 +- projects/mtg/src/MTGRules.cpp | 63 +++++++- 13 files changed, 259 insertions(+), 80 deletions(-) diff --git a/projects/mtg/bin/Res/rules/Blitzkrieg.txt b/projects/mtg/bin/Res/rules/Blitzkrieg.txt index 7e534542e..38ac460df 100644 --- a/projects/mtg/bin/Res/rules/Blitzkrieg.txt +++ b/projects/mtg/bin/Res/rules/Blitzkrieg.txt @@ -13,6 +13,8 @@ auto=flashbackrule auto=retracerule auto=suspendrule auto=morphrule +auto=payzerorule +auto=overloadrule auto=attackrule auto=blockrule auto=combattriggerrule diff --git a/projects/mtg/bin/Res/rules/hermit.txt b/projects/mtg/bin/Res/rules/hermit.txt index ab454866d..6bd9d460a 100644 --- a/projects/mtg/bin/Res/rules/hermit.txt +++ b/projects/mtg/bin/Res/rules/hermit.txt @@ -12,6 +12,8 @@ auto=flashbackrule auto=retracerule auto=suspendrule auto=morphrule +auto=payzerorule +auto=overloadrule auto=attackrule auto=blockrule auto=combattriggerrule diff --git a/projects/mtg/bin/Res/rules/mtg.txt b/projects/mtg/bin/Res/rules/mtg.txt index 38f2f9b84..eec78cfb1 100644 --- a/projects/mtg/bin/Res/rules/mtg.txt +++ b/projects/mtg/bin/Res/rules/mtg.txt @@ -16,7 +16,8 @@ auto=flashbackrule auto=retracerule auto=suspendrule auto=morphrule -auto=playfromgraveyardrule +auto=payzerorule +auto=overloadrule auto=attackrule auto=blockrule auto=combattriggerrule diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index fd72dec5b..3dc75140d 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -10933,6 +10933,17 @@ power=2 toughness=1 [/card] [card] +name=Blustersquall +alias=110000 +other={3}{U} name(Overload) +target=creature|opponentbattlefield +auto=overload tap all(creature|opponentbattlefield) +auto=paidmana tap +text=Tap target creature you don't control. -- Overload {3}{U} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={U} +type=Instant +[/card] +[card] name=Boa Constrictor auto={T}:3/3 text={T}: Boa Constrictor gets +3/+3 until end of turn. @@ -16254,6 +16265,19 @@ mana={G} type=Sorcery [/card] [card] +name=Chemister's Trick +alias=110000 +other={3}{U}{R} name(Overload) +target=creature|opponentbattlefield +auto=paidmana -2/0 +auto=paidmana mustattack +auto=overload -2/0 all(creature|opponentbattlefield) +auto=overload mustattack all(creature|opponentbattlefield) +text=Target creature you don't control gets -2/-0 until end of turn and attacks this turn if able. -- Overload {3}{U}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={U}{R} +type=Instant +[/card] +[card] name=Chief of the Edge auto=lord(other warrior|myBattlefield) 1/0 text=Other Warrior creatures you control get +1/+0. @@ -19374,6 +19398,18 @@ mana={3}{U}{U} type=Instant [/card] [card] +name=Counterflux +alias=110000 +other={1}{U}{U}{R} name(Overload) +abilities=nofizzle +target=*|opponentstack +auto=paidmana fizzle +auto=overload fizzle all(*|opponentstack) +text=Counterflux can't be countered by spells or abilities. -- Counter target spell you don't control. -- Overload {1}{U}{U}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={U}{U}{R} +type=Instant +[/card] +[card] name=Counterintelligence target=creature auto=moveTo(ownerhand) @@ -21170,6 +21206,17 @@ mana={3}{B} type=Instant [/card] [card] +name=Cyclonic Rift +alias=110000 +other={6}{U} name(Overload) +target=*[-land]|opponentbattlefield +auto=overload moveto(ownerhand) all(*[-land]|opponentbattlefield) +auto=paidmana moveto(ownerhand) +text=Return target nonland permanent you don't control to its owner's hand. -- Overload {6}{U} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={1}{U} +type=Instant +[/card] +[card] name=Cyclopean Mummy auto=@movedTo(this|graveyard) from(battlefield):moveto(exile) text=When Cyclopean Mummy dies, exile Cyclopean Mummy. @@ -25946,6 +25993,17 @@ mana={1}{U} type=Instant [/card] [card] +name=Downsize +alias=110000 +other={2}{U} name(Overload) +target=creature|opponentbattlefield +auto=overload -4/0 all(creature|opponentbattlefield) +auto=paidmana -4/0 +text=Target creature you don't control gets -4/-0 until end of turn. -- Overload {2}{U} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={U} +type=Instant +[/card] +[card] name=Dowsing Shaman auto={2}{G}{T}:moveTo(myhand) target(enchantment|mygraveyard) text={2}{G}, {T}: Return target enchantment card from your graveyard to your hand. @@ -28225,6 +28283,17 @@ type=Enchantment subtype=Aura [/card] [card] +name=Dynacharge +alias=110000 +other={2}{R} name(Overload) +target=creature|mybattlefield +auto=paidmana 2/0 +auto=overload all(creature|mybattlefield) 2/0 +text=Target creature you control gets +2/+0 until end of turn. -- Overload {2}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={R} +type=Instant +[/card] +[card] name=Dystopia auto=cumulativeupcost[{L}] sacrifice auto=@each opponent upkeep:ability$!name(sacrifice) notatarget(creature[green;white]|mybattlefield) sacrifice !$ opponent @@ -28974,6 +29043,17 @@ power=1 toughness=1 [/card] [card] +name=Electrickery +alias=110000 +other={1}{R} name(Overload) +target=creature|opponentbattlefield +auto=paidmana damage:1 +auto=overload damage:1 all(creature|opponentbattlefield) +text=Electrickery deals 1 damage to target creature you don't control. -- Overload {1}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={R} +type=Instant +[/card] +[card] name=Electrolyze target=creature,player auto=damage:1 @@ -63401,6 +63481,30 @@ power=4 toughness=4 [/card] [card] +name=Mizzium Mortars +alias=110000 +other={3}{R}{R}{R} name(Overload) +target=creature|opponentbattlefield +auto=paidmana damage:4 +auto=overload damage:4 all(creature|opponentbattlefield) +text=Mizzium Mortars deals 4 damage to target creature you don't control. -- Overload {3}{R}{R}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={1}{R} +type=Sorcery +[/card] +[card] +name=Mizzium Skin +alias=110000 +other={1}{U} name(Overload) +target=creature|mybattlefield +auto=paidmana 0/1 +auto=paidmana opponentshroud +auto=overload all(creature|mybattlefield) 0/1 +auto=overload all(creature|mybattlefield) opponentshroud +text=Target creature you control gets +0/+1 and gains hexproof until end of turn. -- Overload {1}{U} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={U} +type=Instant +[/card] +[card] name=Mnemonic Nexus auto=moveto(opponentlibrary) all(*|opponentgraveyard) && shuffle opponent auto=moveto(mylibrary) all(*|mygraveyard) && shuffle controller @@ -96955,6 +97059,17 @@ power=3 toughness=4 [/card] [card] +name=Street Spasm +alias=110000 +other={X}{X}{R}{R} name(Overload) +target=creature[-flying]|opponentbattlefield +auto=paidmana damage:X +auto=overload damage:XX all(creature[-flying]|opponentbattlefield) +text=Street Spasm deals X damage to target creature without flying you don't control. -- Overload {X}{X}{R}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={X}{R} +type=Instant +[/card] +[card] name=Streetbreaker Wurm mana={3}{R}{G} type=Creature @@ -100365,6 +100480,19 @@ mana={U}{U}{U} type=Instant [/card] [card] +name=Teleportal +alias=110000 +other={3}{U}{R} name(Overload) +target=creature|mybattlefield +auto=paidmana 1/0 +auto=paidmana unblockable +auto=overload all(creature|mybattlefield) 1/0 +auto=overload all(creature|mybattlefield) unblockable +text=Target creature you control gets +1/+0 until end of turn and is unblockable this turn. -- Overload {3}{U}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={U}{R} +type=Sorcery +[/card] +[card] name=Telethopter auto={T(creature|myBattlefield)}:flying text=Tap an untapped creature you control: Telethopter gains flying until end of turn. @@ -107662,6 +107790,17 @@ type=Enchantment subtype=Aura [/card] [card] +name=Vandalblast +alias=110000 +other={4}{R} name(Overload) +target=artifact|opponentbattlefield +auto=overload destroy all(artifact|opponentbattlefield) +auto=paidmana destroy +text=Destroy target artifact you don't control. -- Overload {4}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={R} +type=Sorcery +[/card] +[card] name=Vanguard of Brimaz abilities=vigilance auto=@targeted(this) from(*[instant;sorcery;enchantment]|myhand,mygraveyard):token(Cat Soldier,Creature Cat Soldier,1/1,white,vigilance) controller @@ -112353,6 +112492,19 @@ mana={4} type=Artifact [/card] [card] +name=Weapon Surge +alias=110000 +other={1}{R} name(Overload) +target=creature|mybattlefield +auto=paidmana 1/0 +auto=paidmana first strike +auto=overload all(creature|mybattlefield) 1/0 +auto=overload all(creature|mybattlefield) first strike +text=Target creature you control gets +1/+0 and gains first strike until end of turn. -- Overload {1}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") +mana={R} +type=Instant +[/card] +[card] name=Weathered Wayfarer auto={W}{T}:moveTo(myhand) target(land|mylibrary) restriction{type(land|opponentbattlefield)~morethan~type(land|mybattlefield)} text={W}, {T}: Search your library for a land card, reveal it, and put it into your hand. Then shuffle your library. Activate this ability only if an opponent controls more lands than you. diff --git a/projects/mtg/bin/Res/sets/primitives/unsupported.txt b/projects/mtg/bin/Res/sets/primitives/unsupported.txt index 2ad1ef6c6..565840ba0 100644 --- a/projects/mtg/bin/Res/sets/primitives/unsupported.txt +++ b/projects/mtg/bin/Res/sets/primitives/unsupported.txt @@ -1304,12 +1304,6 @@ type=Enchantment text=Each noncreature, non-Equipment artifact is an Equipment with equip {X} and "Equipped creature gets +X/+0," where X is that artifact's converted mana cost. [/card] [card] -name=Blustersquall -text=Tap target creature you don't control. -- Overload {3}{U} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") -mana={U} -type=Instant -[/card] -[card] name=Boar Umbra mana={2}{G} type=Enchantment @@ -2380,12 +2374,6 @@ type=Enchantment text=Whenever any spell is played, counter that spell if each player, other than the caster and his or her teammates, agrees to choose and discard a card. Those players must discard those cards after agreeing. Checks and Balances may be played only in a game with three or more players. [/card] [card] -name=Chemister's Trick -text=Target creature you don't control gets -2/-0 until end of turn and attacks this turn if able. -- Overload {3}{U}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") -mana={U}{R} -type=Instant -[/card] -[card] name=Chicken Egg mana={1}{R} type=Summon — Egg @@ -2995,12 +2983,6 @@ mana={U}{U} type=Enchantment [/card] [card] -name=Counterflux -text=Counterflux can't be countered by spells or abilities. -- Counter target spell you don't control. -- Overload {1}{U}{U}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") -mana={U}{U}{R} -type=Instant -[/card] -[card] name=Countryside Crusher text=At the beginning of your upkeep, reveal the top card of your library. If it's a land card, put it into your graveyard and repeat this process. -- Whenever a land card is put into your graveyard from anywhere, put a +1/+1 counter on Countryside Crusher. mana={1}{R}{R} @@ -3300,12 +3282,6 @@ mana={2}{G}{G} type=Enchantment [/card] [card] -name=Cyclonic Rift -text=Return target nonland permanent you don't control to its owner's hand. -- Overload {6}{U} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") -mana={1}{U} -type=Instant -[/card] -[card] name=Cyclopean Giant text=When Cyclopean Giant is put into a graveyard from the battlefield, target land becomes a Swamp. Exile Cyclopean Giant. mana={2}{B}{B} @@ -4071,12 +4047,6 @@ mana={3}{B} // {2}{G} type=Sorcery // Sorcery [/card] [card] -name=Downsize -text=Target creature you don't control gets -4/-0 until end of turn. -- Overload {2}{U} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") -mana={U} -type=Instant -[/card] -[card] name=Draco text=Domain - Draco costs {2} less to cast for each basic land type among lands you control. -- Flying -- Domain - At the beginning of your upkeep, sacrifice Draco unless you pay {1}0}. This cost is reduced by {2} for each basic land type among lands you control. mana={16} @@ -4278,12 +4248,6 @@ power=1 toughness=1 [/card] [card] -name=Dynacharge -text=Target creature you control gets +2/+0 until end of turn. -- Overload {2}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") -mana={R} -type=Instant -[/card] -[card] name=Echo Chamber text={4}, {T}: An opponent chooses target creature he or she controls. Put a token that's a copy of that creature onto the battlefield. That token gains haste until end of turn. Exile the token at the beginning of the next end step. Activate this ability only any time you could cast a sorcery. mana={4} @@ -4334,12 +4298,6 @@ type=Land text={T}: Add {1} to your mana pool. {T}: Add {2} to your mana pool. Spend this mana only to cast colorless Eldrazi spells or activate abilities of colorless Eldrazi. [/card] [card] -name=Electrickery -text=Electrickery deals 1 damage to target creature you don't control. -- Overload {1}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") -mana={R} -type=Instant -[/card] -[card] name=Electropotence text=Whenever a creature enters the battlefield under your control, you may pay {2}{R}. If you do, that creature deals damage equal to its power to target creature or player. mana={2}{R} @@ -10075,18 +10033,6 @@ mana={1}{U}{U} type=Sorcery [/card] [card] -name=Mizzium Mortars -text=Mizzium Mortars deals 4 damage to target creature you don't control. -- Overload {3}{R}{R}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") -mana={1}{R} -type=Sorcery -[/card] -[card] -name=Mizzium Skin -text=Target creature you control gets +0/+1 and gains hexproof until end of turn. -- Overload {1}{U} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") -mana={U} -type=Instant -[/card] -[card] name=Mizzium Transreliquat text={3}: Mizzium Transreliquat becomes a copy of target artifact until end of turn. -- {1}{U}{R}: Mizzium Transreliquat becomes a copy of target artifact and gains this ability. mana={3} @@ -15879,12 +15825,6 @@ type=Enchantment subtype=Aura [/card] [card] -name=Street Spasm -text=Street Spasm deals X damage to target creature without flying you don't control. -- Overload {X}{X}{R}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") -mana={X}{R} -type=Instant -[/card] -[card] name=Strength of the Tajuru text=Multikicker {1} (You may pay an additional {1} any number of times as you cast this spell.) -- Choose target creature, then choose another target creature for each time Strength of the Tajuru was kicked. Put X +1/+1 counters on each of them. mana={X}{G}{G} @@ -16368,12 +16308,6 @@ mana={U} type=Enchantment [/card] [card] -name=Teleportal -text=Target creature you control gets +1/+0 until end of turn and is unblockable this turn. -- Overload {3}{U}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") -mana={U}{R} -type=Sorcery -[/card] -[card] name=Telling Time text=Look at the top three cards of your library. Put one of those cards into your hand, one on top of your library, and one on the bottom of your library. mana={1}{U} @@ -17394,12 +17328,6 @@ power=3 toughness=3 [/card] [card] -name=Vandalblast -text=Destroy target artifact you don't control. -- Overload {4}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") -mana={R} -type=Sorcery -[/card] -[card] name=Vanguard's Shield text=Equipped creature gets +0/+3 and can block an additional creature. -- Equip {3} ({3}: Attach to target creature you control. Equip only as a sorcery.) mana={2} diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 70d6344b9..d71d822f2 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -214,6 +214,8 @@ public: PUT_INTO_PLAY_WITH_KICKER = 31, STANDARD_FIZZLER = 32, PAYZERO_COST = 33, + OVERLOAD_COST = 34, + BESTOW_COST = 35, }; }; diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 8c1882e91..f5b5cdc5e 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -55,7 +55,7 @@ public: Pos* view; int X; int castX; - int alternateCostPaid[ManaCost::MANA_PAID_WITH_SUSPEND + 1]; + int alternateCostPaid[ManaCost::MANA_PAID_WITH_BESTOW + 1]; int paymenttype; int castMethod; /* Tells if the card reached its current zone by being cast or not (brought into the zone by an effect). non 0 == cast, 0 == not cast */ int frozen; diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index 19fc9775c..7f95e8cb6 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -101,7 +101,7 @@ class MTGAlternativeCostRule: public PermanentAbility { protected: int isReactingToClick(MTGCardInstance * card, ManaCost * mana, ManaCost *alternateManaCost); - int reactToClick(MTGCardInstance * card, ManaCost * alternateManaCost, int paymentType = ManaCost::MANA_PAID); + int reactToClick(MTGCardInstance * card, ManaCost * alternateManaCost, int paymentType = ManaCost::MANA_PAID, bool overload = false); string alternativeName; public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); @@ -192,6 +192,19 @@ public: virtual MTGPayZeroRule * clone() const; }; +class MTGOverloadRule: public MTGAlternativeCostRule +{ +public: + int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); + int reactToClick(MTGCardInstance * card); + virtual ostream& toString(ostream& out) const; + MTGOverloadRule(GameObserver* observer, int _id); + const string getMenuText() + { + return "Overload"; + } + virtual MTGOverloadRule * clone() const; +}; class MTGSuspendRule: public MTGAlternativeCostRule { diff --git a/projects/mtg/include/ManaCost.h b/projects/mtg/include/ManaCost.h index bdc3868ab..21a6a2c99 100644 --- a/projects/mtg/include/ManaCost.h +++ b/projects/mtg/include/ManaCost.h @@ -48,7 +48,9 @@ public: MANA_PAID_WITH_RETRACE = 6, MANA_PAID_WITH_MORPH = 7, MANA_PAID_WITH_SUSPEND = 8, - MANA_PAID_WITH_OTHERCOST = 9 + MANA_PAID_WITH_OVERLOAD = 9, + MANA_PAID_WITH_BESTOW = 10, + MANA_PAID_WITH_OTHERCOST = 11 }; ExtraCosts * extraCosts; diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index 88de3027b..47bf7ae8a 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -303,6 +303,12 @@ bool Spell::FullfilledAlternateCost(const int &costType) case ManaCost::MANA_PAID_WITH_SUSPEND: hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_SUSPEND); break; + case ManaCost::MANA_PAID_WITH_OVERLOAD: + hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_OVERLOAD); + break; + case ManaCost::MANA_PAID_WITH_BESTOW: + hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_BESTOW); + break; } return hasFullfilledAlternateCost; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index bcb131764..99cb4744b 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -39,7 +39,9 @@ const string kAlternateCostKeywords[] = "flashback", "retrace", "facedown", - "suspended" + "suspended", + "overload", + "bestow" }; const int kAlternateCostIds[] = { @@ -51,7 +53,9 @@ const int kAlternateCostIds[] = ManaCost::MANA_PAID_WITH_FLASHBACK, ManaCost::MANA_PAID_WITH_RETRACE, ManaCost::MANA_PAID_WITH_MORPH, - ManaCost::MANA_PAID_WITH_SUSPEND + ManaCost::MANA_PAID_WITH_SUSPEND, + ManaCost::MANA_PAID_WITH_OVERLOAD, + ManaCost::MANA_PAID_WITH_BESTOW }; //Used for "dynamic ability" parsing @@ -1162,6 +1166,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG observer->addObserver(NEW MTGPayZeroRule(observer, -1)); return NULL; } + found = s.find("overloadrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGOverloadRule(observer, -1)); + return NULL; + } //this rule handles attacking ability during attacker phase found = s.find("attackrule"); if(found != string::npos) diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index f74227a18..5fe7fcddd 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -546,7 +546,7 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy copy->kicked = card->kicked; copy->storedCard = card->storedCard; copy->storedSourceCard = card->storedSourceCard; - for (int i = 0; i < ManaCost::MANA_PAID_WITH_SUSPEND +1; i++) + for (int i = 0; i < ManaCost::MANA_PAID_WITH_BESTOW +1; i++) copy->alternateCostPaid[i] = card->alternateCostPaid[i]; //stupid bug with tokens... diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index d2bd12990..88c31a78c 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -632,6 +632,8 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * return 0; if ((game->currentlyActing()->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (game->currentlyActing()->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) return 0; + if (card->alias == 110000) + return 0;//overload has its own rule return isReactingToClick( card, mana, alternateCost ); } @@ -693,12 +695,17 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card) return reactToClick(card, alternateCost, ManaCost::MANA_PAID_WITH_ALTERNATIVE); } -int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alternateCost, int alternateCostType){ +int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alternateCost, int alternateCostType, bool overload){ Player * player = game->currentlyActing(); ManaPool * playerMana = player->getManaPool(); //this handles extra cost payments at the moment a card is played. + if(overload) + card->spellTargetType = ""; + else if(card->model->data->spellTargetType.size()) + card->spellTargetType = card->model->data->spellTargetType; + assert(alternateCost); if (alternateCost->isExtraPaymentSet() ) { @@ -1210,6 +1217,60 @@ MTGPayZeroRule * MTGPayZeroRule::clone() const return NEW MTGPayZeroRule(*this); } +MTGOverloadRule::MTGOverloadRule(GameObserver* observer, int _id) : +MTGAlternativeCostRule(observer, _id) +{ + aType = MTGAbility::OVERLOAD_COST; +} + +int MTGOverloadRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) +{ + Player * player = game->currentlyActing(); + ManaCost * cost = NEW ManaCost(card->model->data->getManaCost()->getAlternative()); + if(card->getIncreasedManaCost()->getConvertedCost()) + cost->add(card->getIncreasedManaCost()); + if(card->getReducedManaCost()->getConvertedCost()) + cost->remove(card->getReducedManaCost()); + + if (card->isLand()) + return 0; + if (card->alias != 110000) + return 0; + if (!player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card)) + return 0; + if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card))) + return 0; + + return MTGAlternativeCostRule::isReactingToClick(card, mana, cost); +} + +int MTGOverloadRule::reactToClick(MTGCardInstance * card) +{ + if (!isReactingToClick(card)) + return 0; + + ManaCost * cost = NEW ManaCost(card->model->data->getManaCost()->getAlternative()); + if(card->getIncreasedManaCost()->getConvertedCost()) + cost->add(card->getIncreasedManaCost()); + if(card->getReducedManaCost()->getConvertedCost()) + cost->remove(card->getReducedManaCost()); + + card->paymenttype = MTGAbility::OVERLOAD_COST; + + return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID_WITH_OVERLOAD, true); +} + +ostream& MTGOverloadRule::toString(ostream& out) const +{ + out << "MTGOverloadRule ::: ("; + return MTGAbility::toString(out) << ")"; +} + +MTGOverloadRule * MTGOverloadRule::clone() const +{ + return NEW MTGOverloadRule(*this); +} + /////////////////////////////////////////////////////////////////////////////////////////////////// bool MTGAttackRule::select(Target* t) From cd1b629191be6c529268540e6cbf237bcf98dfe8 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Tue, 10 Nov 2015 11:58:36 +0800 Subject: [PATCH 14/22] Fix Segmentation Fault & Formatting --- projects/mtg/include/AllAbilities.h | 8 +- projects/mtg/include/DeckMenuItem.h | 52 +++--- projects/mtg/include/DuelLayers.h | 12 +- projects/mtg/include/ExtraCost.h | 2 +- projects/mtg/include/GameObserver.h | 30 ++-- projects/mtg/include/GameState.h | 2 +- projects/mtg/include/InteractiveButton.h | 4 +- projects/mtg/include/MTGAbility.h | 6 +- projects/mtg/include/MTGDefinitions.h | 24 +-- projects/mtg/include/MTGRules.h | 32 ++-- projects/mtg/include/ManaCost.h | 32 ++-- projects/mtg/include/MenuItem.h | 4 +- projects/mtg/include/ModRules.h | 8 +- projects/mtg/include/Player.h | 2 +- projects/mtg/include/Rules.h | 10 +- projects/mtg/include/SimpleButton.h | 10 +- projects/mtg/include/SimpleMenuItem.h | 4 +- projects/mtg/include/ThisDescriptor.h | 10 +- projects/mtg/include/WEvent.h | 26 +-- projects/mtg/include/WFont.h | 2 +- projects/mtg/include/WResourceManager.h | 30 ++-- projects/mtg/include/WResourceManagerImpl.h | 4 +- projects/mtg/include/utils.h | 2 +- projects/mtg/src/AIPlayerBaka.cpp | 14 +- projects/mtg/src/AIStats.cpp | 4 +- projects/mtg/src/ActionLayer.cpp | 4 +- projects/mtg/src/ActionStack.cpp | 24 +-- projects/mtg/src/AllAbilities.cpp | 100 ++++++------ projects/mtg/src/CardGui.cpp | 36 ++--- projects/mtg/src/Credits.cpp | 2 +- projects/mtg/src/Damage.cpp | 2 +- projects/mtg/src/DeckMenu.cpp | 30 ++-- projects/mtg/src/DeckMenuItem.cpp | 72 ++++----- projects/mtg/src/DeckStats.cpp | 4 +- projects/mtg/src/DuelLayers.cpp | 10 +- projects/mtg/src/GameApp.cpp | 4 +- projects/mtg/src/GameObserver.cpp | 170 ++++++++++---------- projects/mtg/src/GameOptions.cpp | 24 +-- projects/mtg/src/GameState.cpp | 4 +- projects/mtg/src/GameStateDuel.cpp | 2 +- projects/mtg/src/GameStateMenu.cpp | 30 ++-- projects/mtg/src/GameStateOptions.cpp | 4 +- projects/mtg/src/GameStateShop.cpp | 6 +- projects/mtg/src/GuiAvatars.cpp | 4 +- projects/mtg/src/GuiHand.cpp | 2 +- projects/mtg/src/GuiMana.cpp | 16 +- projects/mtg/src/GuiPlay.cpp | 6 +- projects/mtg/src/IconButton.cpp | 4 +- projects/mtg/src/InteractiveButton.cpp | 2 +- projects/mtg/src/MTGAbility.cpp | 86 +++++----- projects/mtg/src/MTGCardInstance.cpp | 12 +- projects/mtg/src/MTGDeck.cpp | 2 +- projects/mtg/src/MTGDefinitions.cpp | 62 +++---- projects/mtg/src/MTGGameZones.cpp | 16 +- projects/mtg/src/MTGPack.cpp | 2 +- projects/mtg/src/MTGRules.cpp | 144 ++++++++--------- projects/mtg/src/ManaCost.cpp | 6 +- projects/mtg/src/ModRules.cpp | 64 ++++---- projects/mtg/src/Player.cpp | 16 +- projects/mtg/src/Rules.cpp | 20 +-- projects/mtg/src/SimpleButton.cpp | 2 +- projects/mtg/src/SimpleMenu.cpp | 2 +- projects/mtg/src/SimplePopup.cpp | 90 +++++------ projects/mtg/src/TargetChooser.cpp | 6 +- projects/mtg/src/TestSuiteAI.cpp | 4 +- projects/mtg/src/TextScroller.cpp | 48 +++--- projects/mtg/src/WCachedResource.cpp | 24 +-- projects/mtg/src/WDataSrc.cpp | 6 +- projects/mtg/src/WFont.cpp | 4 +- projects/mtg/src/WResourceManager.cpp | 18 +-- projects/mtg/src/utils.cpp | 8 +- 71 files changed, 769 insertions(+), 769 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 015bd2176..0912bbe9c 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -960,12 +960,12 @@ private: else if (s == "morethanfourcards") { if(card->playerTarget) - {//blackvise + {//blackvise intValue = 0; if ((card->playerTarget->game->hand->nb_cards - 4)>0) intValue = (card->playerTarget->game->hand->nb_cards - 4); } - else + else {//viseling intValue = 0; if ((card->controller()->opponent()->game->hand->nb_cards - 4)>0) @@ -1306,7 +1306,7 @@ public: class TrcardDrawn: public Trigger { public: - bool thiscontroller, thisopponent; + bool thiscontroller, thisopponent; TrcardDrawn(GameObserver* observer, int id, MTGCardInstance * source, TargetChooser * tc,bool once = false, bool thiscontroller = false, bool thisopponent = false) : Trigger(observer, id, source,once, tc),thiscontroller(thiscontroller),thisopponent(thisopponent) { @@ -4721,7 +4721,7 @@ public: vector dontremove; bool addNewColors; bool remove; - bool removeCreatureSubtypes; + bool removeCreatureSubtypes; bool removeTypes; string menu; diff --git a/projects/mtg/include/DeckMenuItem.h b/projects/mtg/include/DeckMenuItem.h index 53ee35d5e..4375a7d99 100644 --- a/projects/mtg/include/DeckMenuItem.h +++ b/projects/mtg/include/DeckMenuItem.h @@ -21,18 +21,18 @@ private: string mText; float mX; float mY; - float mTitleResetWidth; + float mTitleResetWidth; string mDescription; static float mYOffset; float mScrollerOffset; DeckMetaData *mMetaData; - string mImageFilename; + string mImageFilename; void checkUserClick(); public: - DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus = false, bool autoTranslate = false, DeckMetaData *meta = NULL); + DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus = false, bool autoTranslate = false, DeckMetaData *meta = NULL); ~DeckMenuItem(); virtual void Relocate(float x, float y); @@ -44,39 +44,39 @@ public: virtual bool ButtonPressed(); virtual ostream& toString(ostream& out) const; - virtual bool getTopLeft(float& top, float& left) + virtual bool getTopLeft(float& top, float& left) { top = mY + mYOffset; left = mX; return true; } - // Accessors - - string getImageFilename() const { return mImageFilename; }; - float getY() const { return mY; }; - float getX() const { return mX; }; - string getDescription() const { return mDescription; }; - string getText() const { return mText; }; - bool hasFocus() const { return mHasFocus; }; - bool hasMetaData() const { return mMetaData == NULL ? false : true;}; + // Accessors + + string getImageFilename() const { return mImageFilename; }; + float getY() const { return mY; }; + float getX() const { return mX; }; + string getDescription() const { return mDescription; }; + string getText() const { return mText; }; + bool hasFocus() const { return mHasFocus; }; + bool hasMetaData() const { return mMetaData == NULL ? false : true;}; - float getWidth() const; - string getDeckName() const; + float getWidth() const; + string getDeckName() const; - string getDeckStatsSummary() const - { - if (mMetaData) - return mMetaData->getStatsSummary(); - return ""; - } + string getDeckStatsSummary() const + { + if (mMetaData) + return mMetaData->getStatsSummary(); + return ""; + } - DeckMetaData *getMetaData() const - { - return mMetaData; - } + DeckMetaData *getMetaData() const + { + return mMetaData; + } - // Setters + // Setters void setDescription( const string& description ) { mDescription = description; } }; diff --git a/projects/mtg/include/DuelLayers.h b/projects/mtg/include/DuelLayers.h index b4ef7a5a4..f6ac2da05 100644 --- a/projects/mtg/include/DuelLayers.h +++ b/projects/mtg/include/DuelLayers.h @@ -29,7 +29,7 @@ protected: GuiAvatars * avatars; GameObserver* observer; MTGGamePhase* phaseHandler; - int mPlayerViewIndex; + int mPlayerViewIndex; CardSelectorBase* mCardSelector; public: @@ -48,11 +48,11 @@ public: void Remove(); int receiveEvent(WEvent * e); float RightBoundary(); - int getPlayerViewIndex(){ return mPlayerViewIndex; }; - Player* getRenderedPlayer(); - Player* getRenderedPlayerOpponent(); - CardSelectorBase* getCardSelector() { return mCardSelector; }; - GameObserver* getObserver(){ return observer; }; + int getPlayerViewIndex(){ return mPlayerViewIndex; }; + Player* getRenderedPlayer(); + Player* getRenderedPlayerOpponent(); + CardSelectorBase* getCardSelector() { return mCardSelector; }; + GameObserver* getObserver(){ return observer; }; }; #include "ActionLayer.h" diff --git a/projects/mtg/include/ExtraCost.h b/projects/mtg/include/ExtraCost.h index 09cf9323a..caa8bf35a 100644 --- a/projects/mtg/include/ExtraCost.h +++ b/projects/mtg/include/ExtraCost.h @@ -169,7 +169,7 @@ public: class MillExileCost : public MillCost { public: - MillExileCost(TargetChooser *_tc = NULL); + MillExileCost(TargetChooser *_tc = NULL); virtual int doPay(); }; diff --git a/projects/mtg/include/GameObserver.h b/projects/mtg/include/GameObserver.h index 25fcf745b..72bbf687c 100644 --- a/projects/mtg/include/GameObserver.h +++ b/projects/mtg/include/GameObserver.h @@ -190,23 +190,23 @@ class GameObserver{ class NetworkGameObserver : public GameObserver { protected: - JNetwork* mpNetworkSession; - bool mSynchronized; - bool mForwardAction; - virtual void logAction(const string& s); + JNetwork* mpNetworkSession; + bool mSynchronized; + bool mForwardAction; + virtual void logAction(const string& s); public: - // no serverIp means a server is being instantiated, otherwise a client - NetworkGameObserver(JNetwork* pNetwork, WResourceManager* output = 0, JGE* input = 0); - virtual ~NetworkGameObserver(); - virtual void loadPlayer(int playerId, Player* player); - virtual void Update(float dt); - void synchronize(); - static void loadPlayer(void*pThis, stringstream& in, stringstream& out); - static void sendAction(void*pThis, stringstream& in, stringstream& out); - static void synchronize(void*pThis, stringstream& in, stringstream& out); - static void checkSynchro(void*pxThis, stringstream& in, stringstream& out); + // no serverIp means a server is being instantiated, otherwise a client + NetworkGameObserver(JNetwork* pNetwork, WResourceManager* output = 0, JGE* input = 0); + virtual ~NetworkGameObserver(); + virtual void loadPlayer(int playerId, Player* player); + virtual void Update(float dt); + void synchronize(); + static void loadPlayer(void*pThis, stringstream& in, stringstream& out); + static void sendAction(void*pThis, stringstream& in, stringstream& out); + static void synchronize(void*pThis, stringstream& in, stringstream& out); + static void checkSynchro(void*pxThis, stringstream& in, stringstream& out); static void ignoreResponse(void*, stringstream&, stringstream&){}; - static void disconnect(void*pxThis, stringstream& in, stringstream& out); + static void disconnect(void*pxThis, stringstream& in, stringstream& out); }; #endif diff --git a/projects/mtg/include/GameState.h b/projects/mtg/include/GameState.h index 93ef9ff75..aa21d870a 100644 --- a/projects/mtg/include/GameState.h +++ b/projects/mtg/include/GameState.h @@ -1,7 +1,7 @@ #ifndef _GAME_STATE_H_ #define _GAME_STATE_H_ -#define FADING_SPEED 350.0f +#define FADING_SPEED 350.0f class JGE; diff --git a/projects/mtg/include/InteractiveButton.h b/projects/mtg/include/InteractiveButton.h index d15e768bc..cf6412ab1 100644 --- a/projects/mtg/include/InteractiveButton.h +++ b/projects/mtg/include/InteractiveButton.h @@ -16,8 +16,8 @@ using std::string; -#define SCALE_SELECTED 1.2f -#define SCALE_NORMAL 1.0f +#define SCALE_SELECTED 1.2f +#define SCALE_NORMAL 1.0f const int kDismissButtonId = 10000; const int kToggleDeckActionId = 10001; diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index d71d822f2..01565899f 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -211,8 +211,8 @@ public: MORPH_COST = 28, SUSPEND_COST = 29, COUNTERS = 30, - PUT_INTO_PLAY_WITH_KICKER = 31, - STANDARD_FIZZLER = 32, + PUT_INTO_PLAY_WITH_KICKER = 31, + STANDARD_FIZZLER = 32, PAYZERO_COST = 33, OVERLOAD_COST = 34, BESTOW_COST = 35, @@ -463,7 +463,7 @@ public: int parseRestriction(string s); int parseCastRestrictions(MTGCardInstance * card, Player * player, string restrictions); Counter * parseCounter(string s, MTGCardInstance * target, Spell * spell = NULL); - int parsePowerToughness(string s, int *power, int *toughness); + int parsePowerToughness(string s, int *power, int *toughness); int getAbilities(vector * v, Spell * spell, MTGCardInstance * card = NULL, int id = 0, MTGGameZone * dest = NULL); MTGAbility* parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, bool activated = false, bool forceUEOT = false, MTGGameZone * dest = NULL); int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY, TargetChooser * tc = NULL,Targetable * target = NULL); diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index c201679e4..23586eaad 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -276,21 +276,21 @@ class Constants GRADE_UNSUPPORTED = 4, GRADE_DANGEROUS = 5, - ASKIP_NONE=0, - ASKIP_SAFE=1, - ASKIP_FULL=2, - - WHO_P=0, - WHO_O=1, - WHO_R=2, - - KICKER_ALWAYS=0, - KICKER_CHOICE=1, - + ASKIP_NONE=0, + ASKIP_SAFE=1, + ASKIP_FULL=2, + + WHO_P=0, + WHO_O=1, + WHO_R=2, + + KICKER_ALWAYS=0, + KICKER_CHOICE=1, + }; enum - { + { NOT_CAST = 0, CAST_NORMALLY = 1, CAST_WITH_KICKER = 2, diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index 7f95e8cb6..fa8f59b63 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -180,7 +180,7 @@ class MTGPayZeroRule: public MTGAlternativeCostRule public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); - string CustomName; + string CustomName; virtual ostream& toString(ostream& out) const; MTGPayZeroRule(GameObserver* observer, int _id); const string getMenuText() @@ -436,28 +436,28 @@ private: vector pool[20]; int initialized; public: - MTGAllCards * collection; - MTGCardInstance * genEquip(int id); + MTGAllCards * collection; + MTGCardInstance * genEquip(int id); MTGStoneHewerRule(GameObserver* observer, int _id, MTGAllCards * _collection); - int receiveEvent(WEvent * event); - const string getMenuText() - { - return "Stone Hewer"; - } - virtual ostream& toString(ostream& out) const; - virtual MTGStoneHewerRule * clone() const; + int receiveEvent(WEvent * event); + const string getMenuText() + { + return "Stone Hewer"; + } + virtual ostream& toString(ostream& out) const; + virtual MTGStoneHewerRule * clone() const; }; //Hermit Druid avatar mode class MTGHermitRule: public PermanentAbility { public: MTGHermitRule(GameObserver* observer, int _id); - int receiveEvent(WEvent * event); - const string getMenuText() - { - return "Hermit"; - } - virtual MTGHermitRule * clone() const; + int receiveEvent(WEvent * event); + const string getMenuText() + { + return "Hermit"; + } + virtual MTGHermitRule * clone() const; }; // /* LifeLink */ diff --git a/projects/mtg/include/ManaCost.h b/projects/mtg/include/ManaCost.h index 21a6a2c99..85bfbfb0f 100644 --- a/projects/mtg/include/ManaCost.h +++ b/projects/mtg/include/ManaCost.h @@ -54,29 +54,29 @@ public: }; ExtraCosts * extraCosts; - ManaCost * getAlternative(){ return alternative; }; - void setAlternative(ManaCost * aMana){ SAFE_DELETE(alternative); alternative = aMana;}; + ManaCost * getAlternative(){ return alternative; }; + void setAlternative(ManaCost * aMana){ SAFE_DELETE(alternative); alternative = aMana;}; - ManaCost * getKicker(){ return kicker; }; - void setKicker(ManaCost * aMana){ SAFE_DELETE(kicker); kicker = aMana;}; + ManaCost * getKicker(){ return kicker; }; + void setKicker(ManaCost * aMana){ SAFE_DELETE(kicker); kicker = aMana;}; - ManaCost * getBuyback(){ return BuyBack; }; - void setBuyback(ManaCost * aMana){ SAFE_DELETE(BuyBack); BuyBack = aMana;}; + ManaCost * getBuyback(){ return BuyBack; }; + void setBuyback(ManaCost * aMana){ SAFE_DELETE(BuyBack); BuyBack = aMana;}; - ManaCost * getFlashback(){ return FlashBack; }; - void setFlashback(ManaCost * aMana){ SAFE_DELETE(FlashBack); FlashBack = aMana;}; + ManaCost * getFlashback(){ return FlashBack; }; + void setFlashback(ManaCost * aMana){ SAFE_DELETE(FlashBack); FlashBack = aMana;}; - ManaCost * getRetrace(){ return Retrace; }; - void setRetrace(ManaCost * aMana){ SAFE_DELETE(Retrace); Retrace = aMana;}; + ManaCost * getRetrace(){ return Retrace; }; + void setRetrace(ManaCost * aMana){ SAFE_DELETE(Retrace); Retrace = aMana;}; - ManaCost * getMorph(){ return morph; }; - void setMorph(ManaCost * aMana){ SAFE_DELETE(morph); morph = aMana;}; + ManaCost * getMorph(){ return morph; }; + void setMorph(ManaCost * aMana){ SAFE_DELETE(morph); morph = aMana;}; - ManaCost * getSuspend(){ return suspend; }; - void setSuspend(ManaCost * aMana){ SAFE_DELETE(suspend); suspend = aMana;}; + ManaCost * getSuspend(){ return suspend; }; + void setSuspend(ManaCost * aMana){ SAFE_DELETE(suspend); suspend = aMana;}; - ManaCost * getManaUsedToCast(){ return manaUsedToCast; }; - void setManaUsedToCast(ManaCost * aMana){ SAFE_DELETE(manaUsedToCast); manaUsedToCast = aMana;}; + ManaCost * getManaUsedToCast(){ return manaUsedToCast; }; + void setManaUsedToCast(ManaCost * aMana){ SAFE_DELETE(manaUsedToCast); manaUsedToCast = aMana;}; string alternativeName; bool isMulti; diff --git a/projects/mtg/include/MenuItem.h b/projects/mtg/include/MenuItem.h index 6a0df9eb4..8a308c8eb 100644 --- a/projects/mtg/include/MenuItem.h +++ b/projects/mtg/include/MenuItem.h @@ -7,8 +7,8 @@ #include using namespace std; -#define SCALE_SELECTED 1.2f -#define SCALE_NORMAL 1.0f +#define SCALE_SELECTED 1.2f +#define SCALE_NORMAL 1.0f class hgeParticleSystem; diff --git a/projects/mtg/include/ModRules.h b/projects/mtg/include/ModRules.h index fac6db85e..18c64a26c 100644 --- a/projects/mtg/include/ModRules.h +++ b/projects/mtg/include/ModRules.h @@ -109,11 +109,11 @@ public: int mFontSize; bool mFont; PIXEL_TYPE mFontColor; - /*Icons attributes*/ + /*Icons attributes*/ int mSizeIcon; - int mIconPosX; - int mIconPosY; - string mFileName; + int mIconPosX; + int mIconPosY; + string mFileName; ModRulesRenderCardGuiItem(string name, int posX, int posY, string formattedData, string filter, bool font, int fontSize, PIXEL_TYPE fontColor, int SizeIcon,int IconPosX,int IconPosY,string FileName); }; diff --git a/projects/mtg/include/Player.h b/projects/mtg/include/Player.h index 2d356e24f..316be5cbb 100644 --- a/projects/mtg/include/Player.h +++ b/projects/mtg/include/Player.h @@ -111,7 +111,7 @@ public: std::string GetCurrentDeckStatsFile(); virtual bool parseLine(const string& s); friend ostream& operator<<(ostream&, const Player&); - friend istream& operator>>(istream&, Player&); + friend istream& operator>>(istream&, Player&); bool operator<(Player& aPlayer); bool isDead(); }; diff --git a/projects/mtg/include/Rules.h b/projects/mtg/include/Rules.h index b38dc6e54..fa8cdbd77 100644 --- a/projects/mtg/include/Rules.h +++ b/projects/mtg/include/Rules.h @@ -57,17 +57,17 @@ public: }; string bg; - string filename; + string filename; GameType gamemode; bool hidden; - string displayName; - int unlockOption; + string displayName; + int unlockOption; string mUnlockOptionString; - static vector RulesList; + static vector RulesList; Rules(string bg = ""); int load(string _filename); - static int loadAllRules(); + static int loadAllRules(); static void unloadAllRules(); static Rules * getRulesByFilename(string _filename); void initPlayers(GameObserver *observer); diff --git a/projects/mtg/include/SimpleButton.h b/projects/mtg/include/SimpleButton.h index 960b5b7c3..39c890746 100644 --- a/projects/mtg/include/SimpleButton.h +++ b/projects/mtg/include/SimpleButton.h @@ -15,11 +15,11 @@ using std::string; -#define SCALE_SELECTED 1.2f -#define SCALE_NORMAL 1.0f -#define SCALE_SHRINK 0.75f -#define SCALE_SELECTED_LARGE 1.7F -#define SCALE_LARGE_NORMAL 1.5F +#define SCALE_SELECTED 1.2f +#define SCALE_NORMAL 1.0f +#define SCALE_SHRINK 0.75f +#define SCALE_SELECTED_LARGE 1.7f +#define SCALE_LARGE_NORMAL 1.5f class SimpleButton: public JGuiObject { diff --git a/projects/mtg/include/SimpleMenuItem.h b/projects/mtg/include/SimpleMenuItem.h index d535cf317..7f74e7874 100644 --- a/projects/mtg/include/SimpleMenuItem.h +++ b/projects/mtg/include/SimpleMenuItem.h @@ -9,8 +9,8 @@ using std::string; -#define SCALE_SELECTED 1.2f -#define SCALE_NORMAL 1.0f +#define SCALE_SELECTED 1.2f +#define SCALE_NORMAL 1.0f class SimpleMenuItem: public SimpleButton { diff --git a/projects/mtg/include/ThisDescriptor.h b/projects/mtg/include/ThisDescriptor.h index 12b5412b9..625f6c941 100644 --- a/projects/mtg/include/ThisDescriptor.h +++ b/projects/mtg/include/ThisDescriptor.h @@ -114,7 +114,7 @@ class ThisAttacked:public ThisDescriptor{ public: virtual int match(MTGCardInstance * card); - ThisAttacked(int attack); + ThisAttacked(int attack); ThisAttacked * clone() const; }; @@ -122,7 +122,7 @@ class ThisBlocked:public ThisDescriptor{ public: virtual int match(MTGCardInstance * card); - ThisBlocked(int block); + ThisBlocked(int block); ThisBlocked * clone() const; }; @@ -130,7 +130,7 @@ class ThisNotBlocked:public ThisDescriptor{ public: virtual int match(MTGCardInstance * card); - ThisNotBlocked(int unblocked); + ThisNotBlocked(int unblocked); ThisNotBlocked * clone() const; }; @@ -138,7 +138,7 @@ class ThisDamaged:public ThisDescriptor{ public: virtual int match(MTGCardInstance * card); - ThisDamaged(int wasDealtDamage); + ThisDamaged(int wasDealtDamage); ThisDamaged * clone() const; }; @@ -146,7 +146,7 @@ class ThisDualWield:public ThisDescriptor{ public: virtual int match(MTGCardInstance * card); - ThisDualWield(int dualWield); + ThisDualWield(int dualWield); ThisDualWield * clone() const; }; diff --git a/projects/mtg/include/WEvent.h b/projects/mtg/include/WEvent.h index 0f9b546ec..761662255 100644 --- a/projects/mtg/include/WEvent.h +++ b/projects/mtg/include/WEvent.h @@ -151,33 +151,33 @@ struct WEventCreatureAttacker : public WEventCardUpdate { //event when card attacks. struct WEventCardAttacked : public WEventCardUpdate { WEventCardAttacked(MTGCardInstance * card); - virtual Targetable * getTarget(int target); + virtual Targetable * getTarget(int target); }; //event when card attacks alone. struct WEventCardAttackedAlone : public WEventCardUpdate { WEventCardAttackedAlone(MTGCardInstance * card); - virtual Targetable * getTarget(int target); + virtual Targetable * getTarget(int target); }; //event when card attacks but is not blocked. struct WEventCardAttackedNotBlocked : public WEventCardUpdate { WEventCardAttackedNotBlocked(MTGCardInstance * card); - virtual Targetable * getTarget(int target); + virtual Targetable * getTarget(int target); }; //event when card attacks but is blocked. struct WEventCardAttackedBlocked : public WEventCardUpdate { WEventCardAttackedBlocked(MTGCardInstance * card,MTGCardInstance * opponent); MTGCardInstance * opponent; - virtual Targetable * getTarget(int target); + virtual Targetable * getTarget(int target); }; //event when card blocked. struct WEventCardBlocked : public WEventCardUpdate { WEventCardBlocked(MTGCardInstance * card,MTGCardInstance * opponent); MTGCardInstance * opponent; - virtual Targetable * getTarget(int target); + virtual Targetable * getTarget(int target); }; //event when card is sacrificed. @@ -190,13 +190,13 @@ struct WEventCardSacrifice : public WEventCardUpdate { //event when card is discarded. struct WEventCardDiscard : public WEventCardUpdate { WEventCardDiscard(MTGCardInstance * card); - virtual Targetable * getTarget(int target); + virtual Targetable * getTarget(int target); }; //event when card is cycled. struct WEventCardCycle : public WEventCardUpdate { WEventCardCycle(MTGCardInstance * card); - virtual Targetable * getTarget(int target); + virtual Targetable * getTarget(int target); }; //Event when a card's "defenser" status changes @@ -219,9 +219,9 @@ struct WEventBlockersChosen : public WEvent { }; struct WEventcardDraw : public WEvent { - WEventcardDraw(Player * player,int nb_cards); - Player * player; - int nb_cards; + WEventcardDraw(Player * player,int nb_cards); + Player * player; + int nb_cards; using WEvent::getTarget; virtual Targetable * getTarget(Player * player); }; @@ -276,19 +276,19 @@ struct WEventEmptyManaPool : public WEvent { //event when card-equipment unattached struct WEventCardUnattached : public WEventCardUpdate { WEventCardUnattached(MTGCardInstance * card); - virtual Targetable * getTarget(int target); + virtual Targetable * getTarget(int target); }; //event when card-equipment attached/equipped struct WEventCardEquipped : public WEventCardUpdate { WEventCardEquipped(MTGCardInstance * card); - virtual Targetable * getTarget(int target); + virtual Targetable * getTarget(int target); }; //event when card moves from player/opponent battlefield to player/opponent battlefield struct WEventCardControllerChange : public WEventCardUpdate { WEventCardControllerChange(MTGCardInstance * card); - virtual Targetable * getTarget(int target); + virtual Targetable * getTarget(int target); }; std::ostream& operator<<(std::ostream&, const WEvent&); diff --git a/projects/mtg/include/WFont.h b/projects/mtg/include/WFont.h index 84485b1ea..4645b360e 100644 --- a/projects/mtg/include/WFont.h +++ b/projects/mtg/include/WFont.h @@ -173,7 +173,7 @@ protected: int *mGBCode; int mCurr; - PIXEL_TYPE* mCharBuffer; + PIXEL_TYPE* mCharBuffer; virtual int PreCacheChar(const u8 *ch); }; diff --git a/projects/mtg/include/WResourceManager.h b/projects/mtg/include/WResourceManager.h index 9f650f52f..4abe05ed9 100644 --- a/projects/mtg/include/WResourceManager.h +++ b/projects/mtg/include/WResourceManager.h @@ -21,7 +21,7 @@ enum ENUM_WRES_INFO enum ENUM_RETRIEVE_STYLE { - RETRIEVE_EXISTING, //Only returns a resource if it already exists. Does not lock or unlock. + RETRIEVE_EXISTING, //Only returns a resource if it already exists. Does not lock or unlock. RETRIEVE_NORMAL, //Returns or creates a resource. Does not change lock status. RETRIEVE_LOCK, //As above, locks cached resource. Not for quads. RETRIEVE_UNLOCK, //As above, unlocks cached resource. Not for quads. @@ -33,7 +33,7 @@ enum ENUM_RETRIEVE_STYLE enum ENUM_CACHE_SUBTYPE { - CACHE_NORMAL = (1<<0), //Use default values. Not really a flag. + CACHE_NORMAL = (1<<0), //Use default values. Not really a flag. //CACHE_EXISTING = (1<<1), //Retrieve it only if it already exists //Because these bits only modify how a cached resource's Attempt() is called, @@ -51,8 +51,8 @@ enum ENUM_CACHE_ERROR CACHE_ERROR_NONE = 0, CACHE_ERROR_NOT_CACHED = CACHE_ERROR_NONE, CACHE_ERROR_404, - CACHE_ERROR_BAD, //Something went wrong with item->attempt() - CACHE_ERROR_BAD_ALLOC, //Couldn't allocate item + CACHE_ERROR_BAD, //Something went wrong with item->attempt() + CACHE_ERROR_BAD_ALLOC, //Couldn't allocate item CACHE_ERROR_LOST, CACHE_ERROR_NOT_MANAGED, }; @@ -69,16 +69,16 @@ public: static void Terminate(); virtual ~WResourceManager() - { - } + { + } virtual bool IsThreaded() = 0; - void PlaySample(const string& fileName) { - JSample*sample = RetrieveSample(fileName); - if(sample) { - JSoundSystem::GetInstance()->PlaySample(sample); - } - }; + void PlaySample(const string& fileName) { + JSample*sample = RetrieveSample(fileName); + if(sample) { + JSoundSystem::GetInstance()->PlaySample(sample); + } + }; virtual JQuadPtr RetrieveCard(MTGCard * card, int style = RETRIEVE_NORMAL,int submode = CACHE_NORMAL) = 0; virtual JSample * RetrieveSample(const string& filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL) = 0; virtual JTexture * RetrieveTexture(const string& filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL) = 0; @@ -90,7 +90,7 @@ public: virtual void Release(JTexture * tex) = 0; virtual void Release(JSample * sample) = 0; - //Refreshes all files in cache, for when mode/profile changes. + //Refreshes all files in cache, for when mode/profile changes. virtual void Refresh() = 0; //Manual clear of the cache @@ -132,8 +132,8 @@ protected: ** Singleton object only accessibly via Instance(), constructor is private */ WResourceManager() - { - } + { + } static WResourceManager* sInstance; }; diff --git a/projects/mtg/include/WResourceManagerImpl.h b/projects/mtg/include/WResourceManagerImpl.h index 471afc3ec..e9d9c8f4f 100644 --- a/projects/mtg/include/WResourceManagerImpl.h +++ b/projects/mtg/include/WResourceManagerImpl.h @@ -202,8 +202,8 @@ public: #endif private: - bool bThemedCards; //Does the theme have a "sets" directory for overwriting cards? - void FlattenTimes(); //To prevent bad cache timing on int overflow + bool bThemedCards; //Does the theme have a "sets" directory for overwriting cards? + void FlattenTimes(); //To prevent bad cache timing on int overflow //For cached stuff WCache textureWCache; diff --git a/projects/mtg/include/utils.h b/projects/mtg/include/utils.h index 41e21c7a7..612874c59 100644 --- a/projects/mtg/include/utils.h +++ b/projects/mtg/include/utils.h @@ -79,7 +79,7 @@ public: ostream& saveUsedRandValues(ostream& out) const; ostream& saveLoadedRandValues(ostream& out); int random(); - void setSeed(unsigned int seed) { srand(seed); }; + void setSeed(unsigned int seed) { srand(seed); }; template void random_shuffle(Iter first, Iter last) { ptrdiff_t i, n; diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index 634414632..84c294fe9 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -128,7 +128,7 @@ int OrderedAIAction::getEfficiency() break; } case MTGAbility::STANDARD_PREVENT: - { + { efficiency = 0;//starts out low to avoid spamming it when its not needed. if (!target) @@ -1521,12 +1521,12 @@ int AIPlayerBaka::chooseTarget(TargetChooser * _tc, Player * forceTarget,MTGCard if (tc->Owner != observer->currentlyActing()) { observer->currentActionPlayer = tc->Owner; - //this is a hack, but if we hit this condition we are locked in a infinate loop - //so lets give the tc to its owner - //todo:find the root cause of this. - DebugTrace("AIPLAYER: Error, was asked to chose targets but I don't own the source of the targetController\n"); - return 0; - } + //this is a hack, but if we hit this condition we are locked in a infinate loop + //so lets give the tc to its owner + //todo:find the root cause of this. + DebugTrace("AIPLAYER: Error, was asked to chose targets but I don't own the source of the targetController\n"); + return 0; + } Player * target = forceTarget; int playerTargetedZone = 1; if (!target) diff --git a/projects/mtg/src/AIStats.cpp b/projects/mtg/src/AIStats.cpp index b181e238b..c5003147d 100644 --- a/projects/mtg/src/AIStats.cpp +++ b/projects/mtg/src/AIStats.cpp @@ -107,8 +107,8 @@ int AIStats::receiveEvent(WEvent * event) //the following tells ai if a creature should be blocked or targeted bool AIStats::isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCountsForTrue) { - //return true; - //uncomment the above return to make Ai always multiblock your creatures. + //return true; + //uncomment the above return to make Ai always multiblock your creatures. if (stats.size() < max) return tooSmallCountsForTrue; unsigned int n = 0; diff --git a/projects/mtg/src/ActionLayer.cpp b/projects/mtg/src/ActionLayer.cpp index 5efec2e67..28f5453d9 100644 --- a/projects/mtg/src/ActionLayer.cpp +++ b/projects/mtg/src/ActionLayer.cpp @@ -361,8 +361,8 @@ int ActionLayer::reactToClick(MTGCardInstance * card) } #ifdef WIN32 - // if we hit this, then something strange has happened with the click logic - reactToClick() - // should never be called if isReactingToClick() previously didn't have an object return true + // if we hit this, then something strange has happened with the click logic - reactToClick() + // should never be called if isReactingToClick() previously didn't have an object return true assert(!mReactions.empty()); #endif diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index 47bf7ae8a..a0246881d 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -98,13 +98,13 @@ void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string if (!targetQuad) { /*if(source->controller()->isHuman() && source->controller()->opponent()->isAI() && !alt2.size() && _(action).c_str() == source->name) - mFont->DrawString("You play ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT); + mFont->DrawString("You play ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT); else if(source->controller()->isAI() && source->controller()->opponent()->isHuman() && !alt2.size() && _(action).c_str() == source->name) - mFont->DrawString("Opponent plays ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT);*/ + mFont->DrawString("Opponent plays ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT);*/ mFont->DrawString(_(action).c_str(), x + 35, y + GetVerticalTextOffset(), JGETEXT_LEFT); } else - { + { renderer->FillRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(235,10,10,10)); /*if(source->controller()->isHuman() && source->controller()->opponent()->isAI()) renderer->DrawRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(245,0,255,0)); @@ -351,13 +351,13 @@ int Spell::resolve() if (options[Options::SFXVOLUME].number > 0) { - if(observer->getResourceManager()) - observer->getResourceManager()->PlaySample(source->getSample()); + if(observer->getResourceManager()) + observer->getResourceManager()->PlaySample(source->getSample()); } if(this->cost) - { - source->getManaCost()->setManaUsedToCast(NEW ManaCost(this->cost)); - } + { + source->getManaCost()->setManaUsedToCast(NEW ManaCost(this->cost)); + } AbilityFactory af(observer); af.addAbilities(observer->mLayers->actionLayer()->getMaxId(), this); return 1; @@ -757,7 +757,7 @@ int ActionStack::resolve() { for (int i = 0; i < 2; i++) { - if (interruptDecision[i] != 2) + if (interruptDecision[i] != 2) interruptDecision[i] = NOT_DECIDED; } } @@ -821,7 +821,7 @@ int ActionStack::count(int type, int state, int display) Interruptible * ActionStack::getActionElementFromCard(MTGCardInstance * card) { - if(!card) + if(!card) return 0; for (size_t i = 0; i < mObjects.size(); i++) { @@ -1005,7 +1005,7 @@ void ActionStack::Update(float dt) //and set the timer to 4 secs. BUG FIX //http://code.google.com/p/wagic/issues/detail?id=464 extraTime = count(0, NOT_RESOLVED, 0); if (extraTime == 0) - extraTime = 1;//we never want this int to be 0. + extraTime = 1;//we never want this int to be 0. if (timer < 0) timer = static_cast(options[Options::INTERRUPT_SECONDS].number * extraTime); @@ -1253,7 +1253,7 @@ void ActionStack::Render() renderer->DrawRect(x0 - 6, y0+33, width + 15, height - 18, ARGB(255,89,89,89)); //stack border renderer->DrawRect(x0 - 7, y0+2, width + 17, height + 14, ARGB(255,240,240,240)); - + std::ostringstream stream; // WALDORF - changed "interrupt ?" to "Interrupt?". Don't display count down // seconds if the user disables auto progressing interrupts by setting the seconds diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index b681dfc36..2951f628d 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -1236,7 +1236,7 @@ int GenericPaidAbility::resolve() }*/ } if(asAlternate && nomenu && optionalCost->getConvertedCost() < 1) - { + { nomenuAbility->resolve(); } else @@ -1414,7 +1414,7 @@ AAEPIC * AAEPIC::clone() const AAFizzler::AAFizzler(GameObserver* observer, int _id, MTGCardInstance * card, Spell * _target, ManaCost * _cost) : ActivatedAbility(observer, _id, card, _cost, 0) { - aType = MTGAbility::STANDARD_FIZZLER; + aType = MTGAbility::STANDARD_FIZZLER; target = _target; // by default we put the spell to graveyard after fizzling @@ -1847,7 +1847,7 @@ int AANewTarget::resolve() } } if(!newhook) - { + { target = source; source = _target; } @@ -2528,7 +2528,7 @@ int AModifyHand::destroy() if (!p) return 0; - + WParsedInt handmodifier(hand, NULL, source); p->handmodifier -= handmodifier.getValue(); @@ -4175,12 +4175,12 @@ ATransformer::ATransformer(GameObserver* observer, int id, MTGCardInstance * sou myCurrentTurn = 1000; //this subkeyword adds a color without removing the existing colors. addNewColors = (sabilities.find("newcolors") != string::npos); - remove = (stypes.find("removealltypes") != string::npos); - removeCreatureSubtypes = (stypes.find("removecreaturesubtypes") != string::npos); + remove = (stypes.find("removealltypes") != string::npos); + removeCreatureSubtypes = (stypes.find("removecreaturesubtypes") != string::npos); removeTypes = (stypes.find("removetypes") != string::npos); - if (stypes.find("allsubtypes") != string::npos || stypes.find("removecreaturesubtypes") != string::npos) - { + if (stypes.find("allsubtypes") != string::npos || stypes.find("removecreaturesubtypes") != string::npos) + { const vector values = MTGAllCards::getValuesById(); for (size_t i = 0; i removeType(i,1); } - else if (remove) - { - for (it = oldtypes.begin(); it != oldtypes.end(); it++) - { - _target->removeType(*it); - } - } - else - { + else if (remove) + { + for (it = oldtypes.begin(); it != oldtypes.end(); it++) + { + _target->removeType(*it); + } + } + else + { for (it = types.begin(); it != types.end(); it++) - { + { if(removeCreatureSubtypes) { @@ -4280,8 +4280,8 @@ for (it = types.begin(); it != types.end(); it++) { _target->addType(*it); } - } - } + } + } for (it = colors.begin(); it != colors.end(); it++) { _target->setColor(*it); @@ -4361,7 +4361,7 @@ for (it = types.begin(); it != types.end(); it++) _target->switchPT(true); } else - _target->addbaseT(val->getValue()); + _target->addbaseT(val->getValue()); delete val; } @@ -4446,7 +4446,7 @@ int ATransformer::destroy() { _target->setColor(*it); } - + if(newpowerfound || newtoughnessfound) _target->isSettingBase -= 1; @@ -4473,22 +4473,22 @@ int ATransformer::destroy() newAbilities.erase(_target); } } - if (remove || removeCreatureSubtypes) - { - for (it = oldtypes.begin(); it != oldtypes.end(); it++) - { + if (remove || removeCreatureSubtypes) + { + for (it = oldtypes.begin(); it != oldtypes.end(); it++) + { if(!_target->hasSubtype(*it)) _target->addType(*it); - } - } - ////in the case that we removed or added types to a card, so that it retains its original name when the effect is removed. - //if(_target->model->data->name.size())//tokens don't have a model name. - // _target->setName(_target->model->data->name.c_str()); + } + } + ////in the case that we removed or added types to a card, so that it retains its original name when the effect is removed. + //if(_target->model->data->name.size())//tokens don't have a model name. + // _target->setName(_target->model->data->name.c_str()); //edit: this ability shouldn't have to reset the name on a card becuase removing a subtype changes the name of a land. //that should be handled in addType...not here. //im sure commenting this out will reintroduce a bug somewhere but it needs to be handled correctly. furthermore, why does adding and removing a type touch the name of a card? - } + } return 1; } @@ -4697,8 +4697,8 @@ int ALoseAbilities::addToGame() if (al->mObjects[i]) { MTGAbility * currentAction = (MTGAbility *) al->mObjects[i]; - ALord * l = dynamic_cast (currentAction); - if(l) + ALord * l = dynamic_cast (currentAction); + if(l) lordsInGame.push_back(l); } } @@ -4708,9 +4708,9 @@ int ALoseAbilities::addToGame() if (al->mObjects[i]) { MTGAbility * currentAction = (MTGAbility *) al->mObjects[i]; - ALoseAbilities * la = dynamic_cast (currentAction); - if(la) - continue; + ALoseAbilities * la = dynamic_cast (currentAction); + if(la) + continue; if (currentAction->source == _target) { bool canRemove = true; @@ -4751,20 +4751,20 @@ int ALoseAbilities::destroy() MTGAbility * a = storedAbilities[i]; //OneShot abilities are not supposed to stay in the game for long. // If we copied one, something wrong probably happened - if (a->oneShot) - { + if (a->oneShot) + { DebugTrace("ALLABILITIES: Ability should not be one shot"); - continue; + continue; } //Avoid inifinite loop of removing/putting back abilities if (dynamic_cast (a)) { - DebugTrace("ALLABILITIES: loseability won't be put in the loseability list"); - continue; - } + DebugTrace("ALLABILITIES: loseability won't be put in the loseability list"); + continue; + } - a->addToGame(); + a->addToGame(); } storedAbilities.clear(); return 1; @@ -5368,8 +5368,8 @@ void ABlink::resolveBlink() void ABlink::returnCardIntoPlay(MTGCardInstance* _target) { MTGCardInstance * Blinker = NULL; - if(!_target->blinked) - { + if(!_target->blinked) + { this->forceDestroy = 1; return; } @@ -5659,7 +5659,7 @@ int AEquip::unequip() { MTGAbility * a = currentAbilities[i]; if (dynamic_cast (a) || dynamic_cast (a) || dynamic_cast (a) - || dynamic_cast (AbilityFactory::getCoreAbility(a)) + || dynamic_cast (AbilityFactory::getCoreAbility(a)) || (a->aType == MTGAbility::STANDARD_TOKENCREATOR && a->oneShot)) { SAFE_DELETE(a); @@ -6013,7 +6013,7 @@ ATutorialMessage::ATutorialMessage(GameObserver* observer, MTGCardInstance * sou else { mMessage = _(message); //translate directly here, remove this and translate at rendering time if it bites us - ReplaceString(mMessage, "\\n", "\n"); + ReplaceString(mMessage, "\\n", "\n"); } } @@ -6143,7 +6143,7 @@ void ATutorialMessage::Render() if (options[Options::SFXVOLUME].number > 0) { - game->getResourceManager()->PlaySample("tutorial.wav"); + game->getResourceManager()->PlaySample("tutorial.wav"); } } else diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index 9b53f9041..1049cd41b 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -43,11 +43,11 @@ namespace } CardGui::CardGui(MTGCardInstance* card, float x, float y) - : PlayGuiObject(Height, x, y, 0, false), card(card) + : PlayGuiObject(Height, x, y, 0, false), card(card) { } CardGui::CardGui(MTGCardInstance* card, const Pos& ref) - : PlayGuiObject(Height, ref, 0, false), card(card) + : PlayGuiObject(Height, ref, 0, false), card(card) { } @@ -69,7 +69,7 @@ float CardView::GetCenterY() CardView::CardView(const SelectorZone owner, MTGCardInstance* card, float x, float y) - : CardGui(card, x, y), owner(owner) + : CardGui(card, x, y), owner(owner) { const Pos* ref = card->view; while (card) @@ -81,7 +81,7 @@ CardView::CardView(const SelectorZone owner, MTGCardInstance* card, float x, flo } CardView::CardView(const SelectorZone owner, MTGCardInstance* card, const Pos& ref) - : CardGui(card, ref), owner(owner) + : CardGui(card, ref), owner(owner) { const Pos* r = card->view; while (card) @@ -238,14 +238,14 @@ void CardGui::Render() { quad->SetColor(ARGB(static_cast(actA),255,255,255)); //fake border... - JQuadPtr fakeborder; - JQuadPtr highlightborder; + JQuadPtr fakeborder; + JQuadPtr highlightborder; fakeborder = game? game->getResourceManager()->GetQuad("white"):WResourceManager::Instance()->GetQuad("white"); highlightborder = game? game->getResourceManager()->GetQuad("white"):WResourceManager::Instance()->GetQuad("white"); - if(fakeborder) - { + if(fakeborder) + { fakeborder->SetColor(ARGB((int)(actA),15,15,15)); - renderer->RenderQuad(fakeborder.get(), actX, actY, actT, (29 * actZ + 1) / 16, 42 * actZ / 16); + renderer->RenderQuad(fakeborder.get(), actX, actY, actT, (29 * actZ + 1) / 16, 42 * actZ / 16); } //draw border for highlighting if (game) @@ -253,12 +253,12 @@ void CardGui::Render() if (card && card->isTargetted() && highlightborder) { highlightborder->SetColor(ARGB(95,255,0,0)); - renderer->RenderQuad(highlightborder.get(), actX, actY, actT, (30 * actZ + 1) / 16, 43 * actZ / 16); + renderer->RenderQuad(highlightborder.get(), actX, actY, actT, (30 * actZ + 1) / 16, 43 * actZ / 16); } if (card && card->isTargetter() && highlightborder) { highlightborder->SetColor(ARGB(95,0,245,0)); - renderer->RenderQuad(highlightborder.get(), actX, actY, actT, (30 * actZ + 1) / 16, 43 * actZ / 16); + renderer->RenderQuad(highlightborder.get(), actX, actY, actT, (30 * actZ + 1) / 16, 43 * actZ / 16); } } //draw the card image @@ -307,7 +307,7 @@ void CardGui::Render() { if (card && card->isTargetted()) { - if(card->isTapped()) + if(card->isTapped()) { if(mHasFocus) renderer->DrawRoundRect(actX - (scale * quad->mWidth / 2)-10,actY - (scale * quad->mHeight / 2)+6.5f, (scale * quad->mHeight)-0.02f, (scale * quad->mWidth)-0.02f, 1.8f,ARGB(250,255,0,0)); @@ -341,7 +341,7 @@ void CardGui::Render() ARGB(((static_cast(actA))/2),0,0,0)); renderer->DrawRect(actX - (13 * actZ), actY + 4 * actZ, 25.5f * actZ, 14 * actZ, ARGB(((static_cast(actA))),20,20,20)); - //damaged or buffed or powered down + //damaged or buffed or powered down if(card->wasDealtDamage && card->life <= 2) mFont->SetColor(ARGB(static_cast(actA),255,0,0));//red critical and damaged else if(!card->wasDealtDamage && card->pbonus < 0) @@ -350,7 +350,7 @@ void CardGui::Render() mFont->SetColor(ARGB(static_cast(actA),255,255,0));//yellow buff else if(card->hasType("legendary") && card->hasType("eldrazi")) mFont->SetColor(ARGB(static_cast(actA),238,130,238));//violet legendary eldrazi - else + else mFont->SetColor(ARGB(static_cast(actA),255,255,255));//white default mFont->SetScale(actZ); mFont->SetScale(actZ); @@ -366,7 +366,7 @@ void CardGui::Render() if(!card->isToken && card->isACopier) buff = "C"; if(game && card->has(Constants::PAYZERO) && ((card->currentZone == card->controller()->game->hand) || (card->has(Constants::CANPLAYFROMGRAVEYARD) && card->currentZone == card->controller()->game->graveyard) || (card->has(Constants::CANPLAYFROMEXILE) && card->currentZone == card->controller()->game->exile))) - buff += "Z"; + buff += "Z"; if(card->alias == 0000) { if(card->chooseacolor == 1) @@ -380,8 +380,8 @@ void CardGui::Render() else if(card->chooseacolor == 5) buff += "\n-White"; } - if(!alternate && buff != "" && game->gameType() == GAME_TYPE_CLASSIC)//it seems that other game modes makes cards as tokens!!! hmmm... - { + if(!alternate && buff != "" && game->gameType() == GAME_TYPE_CLASSIC)//it seems that other game modes makes cards as tokens!!! hmmm... + { mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); char buffer[200]; sprintf(buffer, "%s", buff.c_str()); @@ -1101,7 +1101,7 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb, bool noborder //white thin line to simulate card edge renderer->DrawRoundRect(x-92,pos.actY-130, (scale * quad->mWidth)-10, (scale * quad->mHeight)-11, 9.0f,ARGB(50,240,240,240)); } - //render card image + //render card image renderer->RenderQuad(quad.get(), x, pos.actY-2, pos.actT, scale-0.02f, scale-0.02f); } else diff --git a/projects/mtg/src/Credits.cpp b/projects/mtg/src/Credits.cpp index 64c4a609e..3e920c178 100644 --- a/projects/mtg/src/Credits.cpp +++ b/projects/mtg/src/Credits.cpp @@ -69,7 +69,7 @@ bool Unlockable::tryToUnlock(GameObserver * game) { string id = getValue("id"); assert(id.size() > 0); - GameOptionAward* goa = (GameOptionAward*) &options[id]; + GameOptionAward* goa = (GameOptionAward*) &options[id]; goa->giveAward(); return true; } diff --git a/projects/mtg/src/Damage.cpp b/projects/mtg/src/Damage.cpp index 3b677ff18..5691eed5a 100644 --- a/projects/mtg/src/Damage.cpp +++ b/projects/mtg/src/Damage.cpp @@ -76,7 +76,7 @@ int Damage::resolve() MTGCardInstance * _target = (MTGCardInstance *) target; if ((_target)->protectedAgainst(source)) damage = 0; - //rulings = 10/4/2004 The damage prevention ability works even if it has no counters, as long as some effect keeps its toughness above zero. + //rulings = 10/4/2004 The damage prevention ability works even if it has no counters, as long as some effect keeps its toughness above zero. //these creature are essentially immune to damage. however 0/-1 effects applied through lords or counters can kill them. if ((_target)->has(Constants::PROTECTIONFROMCOLOREDSPELLS)) {//damage is prevented as long as the damage source is a spell on the stack... diff --git a/projects/mtg/src/DeckMenu.cpp b/projects/mtg/src/DeckMenu.cpp index 6a9f7fa5a..3b670e9f5 100644 --- a/projects/mtg/src/DeckMenu.cpp +++ b/projects/mtg/src/DeckMenu.cpp @@ -20,7 +20,7 @@ namespace DeckMenuConst const float kLineHeight = 25; const float kDescriptionVerticalBoxPadding = -5; const float kDescriptionHorizontalBoxPadding = 5; - + const float kVerticalScrollSpeed = 7.0f; const int DETAILED_INFO_THRESHOLD = 20; @@ -69,7 +69,7 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc menuInitialized = false; float scrollerWidth = 200.0f; - float scrollerHeight = 28.0f; + float scrollerHeight = 28.0f; mScroller = NEW VerticalTextScroller(Fonts::MAIN_FONT, 14, 235, scrollerWidth, scrollerHeight, DeckMenuConst::kVerticalScrollSpeed); mAutoTranslate = true; @@ -94,7 +94,7 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc mSelectionTargetY = selectionY = DeckMenuConst::kVerticalMargin; if (NULL == stars) - stars = NEW hgeParticleSystem(WResourceManager::Instance()->RetrievePSI("stars.psi", WResourceManager::Instance()->GetQuad("stars").get())); + stars = NEW hgeParticleSystem(WResourceManager::Instance()->RetrievePSI("stars.psi", WResourceManager::Instance()->GetQuad("stars").get())); stars->FireAt(mX, mY); const string detailedInfoString = _("Detailed Info"); @@ -248,11 +248,11 @@ void DeckMenu::Render() if (currentMenuItem->getY() - DeckMenuConst::kLineHeight * startId < mY + height - DeckMenuConst::kLineHeight + 7) { // only load stats for visible items in the list - DeckMetaData* metaData = currentMenuItem->getMetaData(); + DeckMetaData* metaData = currentMenuItem->getMetaData(); if (metaData && !metaData->mStatsLoaded) { metaData->LoadStats(); - } + } if (currentMenuItem->hasFocus()) { @@ -291,7 +291,7 @@ void DeckMenu::Render() } // fill in the description part of the screen - string text = wordWrap(_(currentMenuItem->getDescription()), descWidth, descriptionFont->mFontID ); + string text = wordWrap(_(currentMenuItem->getDescription()), descWidth, descriptionFont->mFontID ); descriptionFont->SetColor(ARGB(255,255,255,255)); descriptionFont->DrawString(text.c_str(), descX, descY); @@ -314,19 +314,19 @@ void DeckMenu::Render() } } - if (!title.empty()) + if (!title.empty()) { mFont->SetColor(ARGB(255,255,255,255)); mFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER); } mScroller->Render(); - RenderBackground(); + RenderBackground(); RenderDeckManaColors(); renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE); - stars->Render(); - renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA); + stars->Render(); + renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA); } @@ -403,13 +403,13 @@ void DeckMenu::updateScroller() for (vector::iterator it = taskList.tasks.begin(); it != taskList.tasks.end(); it++) { - ostringstream taskDescription; - taskDescription << "Credits: " << setw(4) << (*it)->getReward() << " / " - << "Days Left: " << (*it)->getExpiration() << endl + ostringstream taskDescription; + taskDescription << "Credits: " << setw(4) << (*it)->getReward() << " / " + << "Days Left: " << (*it)->getExpiration() << endl << (*it)->getDesc() << endl << endl; - mScroller->Add(taskDescription.str()); + mScroller->Add(taskDescription.str()); } - + } void DeckMenu::Close() diff --git a/projects/mtg/src/DeckMenuItem.cpp b/projects/mtg/src/DeckMenuItem.cpp index ee5151ddd..d44e4725d 100644 --- a/projects/mtg/src/DeckMenuItem.cpp +++ b/projects/mtg/src/DeckMenuItem.cpp @@ -16,33 +16,33 @@ float DeckMenuItem::mYOffset = 0; DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus, bool autoTranslate, DeckMetaData *deckMetaData) : JGuiObject(id), parent(_parent), fontId(fontId), mX(x), mY(y) { - WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); + WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); mMetaData = deckMetaData; - mText = trim(text); + mText = trim(text); mIsValidSelection = false; - if (autoTranslate) - mText = _(mText); + if (autoTranslate) + mText = _(mText); mHasFocus = hasFocus; - float newImageWidth = 0.0f; + float newImageWidth = 0.0f; if (mMetaData && !mMetaData->getGamesPlayed()) { JTexture * tex = WResourceManager::Instance()->RetrieveTexture("new.png"); if (tex) { JQuadPtr quad = WResourceManager::Instance()->RetrieveQuad("new.png", 2.0f, 2.0f, tex->mWidth - 4.0f, tex->mHeight - 4.0f); //avoids weird rectangle around the texture because of bilinear filtering - newImageWidth = quad->mWidth; - } - } + newImageWidth = quad->mWidth; + } + } - float titleStringWidth = mFont->GetStringWidth( mText.c_str() ); - mTitleResetWidth = (titleStringWidth - newImageWidth )/ 2; - mScrollEnabled = titleStringWidth > ( ITEM_PX_WIDTH - newImageWidth ); - mScrollerOffset = 0.0f; + float titleStringWidth = mFont->GetStringWidth( mText.c_str() ); + mTitleResetWidth = (titleStringWidth - newImageWidth )/ 2; + mScrollEnabled = titleStringWidth > ( ITEM_PX_WIDTH - newImageWidth ); + mScrollerOffset = 0.0f; - if (hasFocus) + if (hasFocus) { mIsValidSelection = true; Entering(); @@ -67,7 +67,7 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, f break; } default: - mImageFilename = "noavatar.jpg"; + mImageFilename = "noavatar.jpg"; // do nothing. break; } @@ -75,15 +75,15 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, f } - mDisplayInitialized = false; + mDisplayInitialized = false; } void DeckMenuItem::Update(float dt) { - mScrollerOffset += kHorizontalScrollSpeed * dt; - if ( (mScrollerOffset) > mTitleResetWidth ) - mScrollerOffset = -ITEM_PX_WIDTH; + mScrollerOffset += kHorizontalScrollSpeed * dt; + if ( (mScrollerOffset) > mTitleResetWidth ) + mScrollerOffset = -ITEM_PX_WIDTH; } @@ -92,12 +92,12 @@ void DeckMenuItem::RenderWithOffset(float yOffset) mYOffset = yOffset; WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); - - if (!( mHasFocus && mScrollEnabled )) - mScrollerOffset = 0; - if (!mHasFocus && mScrollEnabled) - mScrollerOffset = -1 * ( getWidth() - ITEM_PX_WIDTH )/2; - float offSet = mScrollerOffset; + + if (!( mHasFocus && mScrollEnabled )) + mScrollerOffset = 0; + if (!mHasFocus && mScrollEnabled) + mScrollerOffset = -1 * ( getWidth() - ITEM_PX_WIDTH )/2; + float offSet = mScrollerOffset; if (mHasFocus) mFont->SetScale(SCALE_SELECTED); @@ -105,8 +105,8 @@ void DeckMenuItem::RenderWithOffset(float yOffset) mFont->SetScale(SCALE_NORMAL); mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER, offSet, ITEM_PX_WIDTH); - mDisplayInitialized = true; - //Render a "new" icon for decks that have never been played yet + mDisplayInitialized = true; + //Render a "new" icon for decks that have never been played yet if (mMetaData && !mMetaData->getGamesPlayed()) { JTexture * tex = WResourceManager::Instance()->RetrieveTexture("new.png"); @@ -128,7 +128,7 @@ void DeckMenuItem::Render() void DeckMenuItem::checkUserClick() { - int x1 = -1, y1 = -1; + int x1 = -1, y1 = -1; if (mEngine->GetLeftClickCoordinates(x1, y1)) { mIsValidSelection = false; @@ -136,8 +136,8 @@ void DeckMenuItem::checkUserClick() if ( (x1 >= x2) && (x1 <= (x2 + ITEM_PX_WIDTH)) && (y1 >= y2) && (y1 < (y2 + kItemYHeight))) mIsValidSelection = true; } - else - mIsValidSelection = true; + else + mIsValidSelection = true; } @@ -175,14 +175,14 @@ float DeckMenuItem::getWidth() const string DeckMenuItem::getDeckName() const { - if (mMetaData) - return mMetaData->getName(); + if (mMetaData) + return mMetaData->getName(); - std::string s; - std::stringstream out; - out << mMetaData->getDeckId(); - s = out.str(); - return "[deck" + s + "]"; + std::string s; + std::stringstream out; + out << mMetaData->getDeckId(); + s = out.str(); + return "[deck" + s + "]"; } ostream& DeckMenuItem::toString(ostream& out) const diff --git a/projects/mtg/src/DeckStats.cpp b/projects/mtg/src/DeckStats.cpp index 677760bb6..8ba637293 100644 --- a/projects/mtg/src/DeckStats.cpp +++ b/projects/mtg/src/DeckStats.cpp @@ -394,9 +394,9 @@ void StatsWrapper::updateStats(string filename, MTGAllCards *collection) void StatsWrapper::updateStats(DeckDataWrapper *myDeck) { - if (!this->needUpdate || !myDeck) return; + if (!this->needUpdate || !myDeck) return; - this->needUpdate = false; + this->needUpdate = false; this->cardCount = myDeck->getCount(WSrcDeck::UNFILTERED_COPIES); this->countLands = myDeck->getCount(Constants::MTG_COLOR_LAND); this->totalPrice = myDeck->totalPrice(); diff --git a/projects/mtg/src/DuelLayers.cpp b/projects/mtg/src/DuelLayers.cpp index 2c1713849..b97112aa7 100644 --- a/projects/mtg/src/DuelLayers.cpp +++ b/projects/mtg/src/DuelLayers.cpp @@ -89,7 +89,7 @@ DuelLayers::DuelLayers(GameObserver* go, int playerViewIndex) : nbitems(0), mPlayerViewIndex(playerViewIndex) { observer = go; - observer->mLayers = this; + observer->mLayers = this; mCardSelector = NEW CardSelector(go, this); //1 Action Layer action = NEW ActionLayer(go); @@ -98,8 +98,8 @@ DuelLayers::DuelLayers(GameObserver* go, int playerViewIndex) : //Other display elements action->Add(NEW HUDDisplay(go, -1)); - Add(NEW GuiMana(20, 20, getRenderedPlayerOpponent())); - Add(NEW GuiMana(440, 20, getRenderedPlayer())); + Add(NEW GuiMana(20, 20, getRenderedPlayerOpponent())); + Add(NEW GuiMana(440, 20, getRenderedPlayer())); Add(stack = NEW ActionStack(go)); Add(combat = NEW GuiCombat(go)); Add(action); @@ -216,10 +216,10 @@ float DuelLayers::RightBoundary() Player* DuelLayers::getRenderedPlayer() { - return observer->players[mPlayerViewIndex]; + return observer->players[mPlayerViewIndex]; }; Player* DuelLayers::getRenderedPlayerOpponent() { - return observer->players[mPlayerViewIndex]->opponent(); + return observer->players[mPlayerViewIndex]->opponent(); }; diff --git a/projects/mtg/src/GameApp.cpp b/projects/mtg/src/GameApp.cpp index bdc8fbe05..60fcfd31a 100644 --- a/projects/mtg/src/GameApp.cpp +++ b/projects/mtg/src/GameApp.cpp @@ -77,7 +77,7 @@ GameApp::GameApp() : mCurrentState = NULL; mNextState = NULL; - rules = 0; + rules = 0; music = NULL; } @@ -156,7 +156,7 @@ void GameApp::Create() //Setup Cache before calling any gfx/sfx functions - WResourceManager::Instance()->ResetCacheLimits(); + WResourceManager::Instance()->ResetCacheLimits(); LOG("Checking for music files"); diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 2731b2429..0b1705378 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -165,18 +165,18 @@ void GameObserver::nextGamePhase() { Phase * cPhaseOld = phaseRing->getCurrentPhase(); if (cPhaseOld->id == MTG_PHASE_COMBATDAMAGE) - if ((FIRST_STRIKE == combatStep) || (END_FIRST_STRIKE == combatStep) || (DAMAGE == combatStep)) - { - nextCombatStep(); - return; - } + if ((FIRST_STRIKE == combatStep) || (END_FIRST_STRIKE == combatStep) || (DAMAGE == combatStep)) + { + nextCombatStep(); + return; + } if (cPhaseOld->id == MTG_PHASE_COMBATBLOCKERS) - if (BLOCKERS == combatStep || TRIGGERS == combatStep) - { - nextCombatStep(); - return; - } + if (BLOCKERS == combatStep || TRIGGERS == combatStep) + { + nextCombatStep(); + return; + } phaseRing->forward(); @@ -191,12 +191,12 @@ void GameObserver::nextGamePhase() mCurrentGamePhase = cPhase->id; if (MTG_PHASE_COMBATDAMAGE == mCurrentGamePhase) - nextCombatStep(); + nextCombatStep(); if (MTG_PHASE_COMBATEND == mCurrentGamePhase) combatStep = BLOCKERS; //if (currentPlayer != cPhase->player) - // nextPlayer();//depreciated; we call this at EOT step now. unsure what the purpose of this was originally.fix for a bug? + // nextPlayer();//depreciated; we call this at EOT step now. unsure what the purpose of this was originally.fix for a bug? //init begin of turn if (mCurrentGamePhase == MTG_PHASE_BEFORE_BEGIN) @@ -229,8 +229,8 @@ void GameObserver::nextGamePhase() handmodified = currentPlayer->handsize+currentPlayer->handmodifier; //Auto Hand cleaning, in case the player didn't do it himself if(handmodified < 0) - handmodified = 0; - while (currentPlayer->game->hand->nb_cards > handmodified && currentPlayer->nomaxhandsize == false) + handmodified = 0; + while (currentPlayer->game->hand->nb_cards > handmodified && currentPlayer->nomaxhandsize == false) { WEvent * e = NEW WEventCardDiscard(currentPlayer->game->hand->cards[0]); receiveEvent(e); @@ -312,16 +312,16 @@ void GameObserver::userRequestNextGamePhase(bool allowInterrupt, bool log) cardClick(getCurrentTargetChooser()->source, 0, false); } if (allowInterrupt && mLayers->stackLayer()->getNext(NULL, 0, NOT_RESOLVED)) - return; + return; if (getCurrentTargetChooser()) - return; + return; //if (mLayers->actionLayer()->isWaitingForAnswer()) - // return; + // return; // Wil 12/5/10: additional check, not quite understanding why TargetChooser doesn't seem active at this point. // If we deem that an extra cost payment needs to be made, don't allow the next game phase to proceed. // Here's what I find weird - if the extra cost is something like a sacrifice, doesn't that imply a TargetChooser? if (WaitForExtraPayment(NULL)) - return; + return; Phase * cPhaseOld = phaseRing->getCurrentPhase(); if (allowInterrupt && ((cPhaseOld->id == MTG_PHASE_COMBATBLOCKERS && combatStep == ORDER) @@ -329,7 +329,7 @@ void GameObserver::userRequestNextGamePhase(bool allowInterrupt, bool log) || (cPhaseOld->id == MTG_PHASE_COMBATDAMAGE) || opponent()->isAI() || options[Options::optionInterrupt(mCurrentGamePhase)].number - || currentPlayer->offerInterruptOnPhase - 1 == mCurrentGamePhase + || currentPlayer->offerInterruptOnPhase - 1 == mCurrentGamePhase )) { mLayers->stackLayer()->AddNextGamePhase(); @@ -577,7 +577,7 @@ void GameObserver::Update(float dt) } currentActionPlayer = player; if (isInterrupting) - player = isInterrupting; + player = isInterrupting; if(mLayers) { mLayers->Update(dt, player); @@ -597,7 +597,7 @@ void GameObserver::gameStateBasedEffects() { if(getCurrentTargetChooser() && int(getCurrentTargetChooser()->getNbTargets()) == getCurrentTargetChooser()->maxtargets) getCurrentTargetChooser()->done = true; - ///////////////////////////////////// + ///////////////////////////////////// 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, players[d]->game->exile }; @@ -608,8 +608,8 @@ void GameObserver::gameStateBasedEffects() { for (int c = zone->nb_cards - 1; c >= 0; c--) { - zone->cards[c]->cardistargetted = 0; - zone->cards[c]->cardistargetter = 0; + zone->cards[c]->cardistargetted = 0; + zone->cards[c]->cardistargetter = 0; } } }//check for losers if its GAMEOVER clear the stack to allow gamestateeffects to continue @@ -1167,9 +1167,9 @@ void GameObserver::Render() if(mLayers) mLayers->Render(); if (targetChooser || (mLayers && mLayers->actionLayer()->isWaitingForAnswer())) - JRenderer::GetInstance()->DrawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(255,255,0,0)); + JRenderer::GetInstance()->DrawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(255,255,0,0)); if (mExtraPayment) - mExtraPayment->Render(); + mExtraPayment->Render(); for (size_t i = 0; i < players.size(); ++i) { @@ -1253,7 +1253,7 @@ void GameObserver::stackObjectClicked(Interruptible * action) { int reaction = mLayers->actionLayer()->isReactingToTargetClick(action); if (reaction == -1) - mLayers->actionLayer()->reactToTargetClick(action); + mLayers->actionLayer()->reactToTargetClick(action); } } @@ -1333,7 +1333,7 @@ int GameObserver::cardClick(MTGCardInstance * card, Targetable * object, bool lo MTGCardInstance* backup = NULL; if (!card) { - clickedPlayer = ((Player *) object); + clickedPlayer = ((Player *) object); } else { backup = card; zone = card->currentZone; @@ -1447,7 +1447,7 @@ int GameObserver::cardClick(MTGCardInstance * card, Targetable * object, bool lo //Current player's hand handmodified = currentPlayer->handsize+currentPlayer->handmodifier; if(handmodified < 0) - handmodified = 0; + handmodified = 0; if (currentPlayer->game->hand->hasCard(card) && mCurrentGamePhase == MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards > handmodified && currentPlayer->nomaxhandsize == false) { @@ -1487,9 +1487,9 @@ int GameObserver::untap(MTGCardInstance * card) return 0; } if (card->has(Constants::DOESNOTUNTAP)) - return 0; + return 0; if (card->frozen > 0) - return 0; + return 0; card->attemptUntap(); return 1; } @@ -1511,7 +1511,7 @@ int GameObserver::isInPlay(MTGCardInstance * card) for (int i = 0; i < 2; i++) { if (players[i]->game->isInPlay(card)) - return 1; + return 1; } return 0; } @@ -1552,10 +1552,10 @@ void GameObserver::untapPhase() int GameObserver::receiveEvent(WEvent * e) { if (!e) - return 0; + return 0; eventsQueue.push(e); if (eventsQueue.size() > 1) - return -1; //resolving events can generate more events + return -1; //resolving events can generate more events int result = 0; while (eventsQueue.size()) { @@ -1574,7 +1574,7 @@ int GameObserver::receiveEvent(WEvent * e) Player * GameObserver::currentlyActing() { if (isInterrupting) - return isInterrupting; + return isInterrupting; return currentActionPlayer; } @@ -1667,7 +1667,7 @@ bool GameObserver::load(const string& ss, bool undo, int controlledPlayerIndex ) { bool currentPlayerSet = false; - int state = -1; + int state = -1; string s; stringstream stream(ss); @@ -1686,7 +1686,7 @@ bool GameObserver::load(const string& ss, bool undo, int controlledPlayerIndex if (s.find("seed ") == 0) { mSeed = atoi(s.substr(5).c_str()); - randomGenerator.setSeed(mSeed); + randomGenerator.setSeed(mSeed); continue; } if (s.find("rvalues:") == 0) @@ -1755,7 +1755,7 @@ bool GameObserver::load(const string& ss, bool undo, int controlledPlayerIndex case 3: if (s.compare("[end]") == 0) { - turn = 0; + turn = 0; mLayers = NEW DuelLayers(this, controlledPlayerIndex); currentPlayer = players[currentPlayerId]; phaseRing = NEW PhaseRing(this); @@ -1844,7 +1844,7 @@ bool GameObserver::processAction(const string& s) DebugTrace("no clue about: " + s); } - return true; + return true; } bool GameObserver::processActions(bool undo @@ -1885,7 +1885,7 @@ bool GameObserver::processActions(bool undo for(loadingite = loadingList.begin(); loadingite != loadingList.end(); loadingite++, cmdIndex++) { - processAction(*loadingite); + processAction(*loadingite); size_t nb = actionsList.size(); @@ -1965,7 +1965,7 @@ Player* GameObserver::createPlayer(const string& playerMode ) { Player::Mode aMode = (Player::Mode)atoi(playerMode.c_str()); - Player* pPlayer = 0; + Player* pPlayer = 0; switch(aMode) { @@ -1989,12 +1989,12 @@ Player* GameObserver::createPlayer(const string& playerMode break; } - if(pPlayer) - { - players.push_back(pPlayer); - } + if(pPlayer) + { + players.push_back(pPlayer); + } - return pPlayer; + return pPlayer; } #ifdef TESTSUITE @@ -2040,7 +2040,7 @@ void GameObserver::loadPlayer(int playerId, PlayerType playerType, int decknb, b loadPlayer(playerId, NEW HumanPlayer(this, deckFile, deckFileSmall, premadeDeck)); } - } + } else { //AI Player, chooses deck AIPlayerFactory playerCreator; @@ -2076,43 +2076,43 @@ void GameObserver::loadPlayer(int playerId, PlayerType playerType, int decknb, b #ifdef NETWORK_SUPPORT NetworkGameObserver::NetworkGameObserver(JNetwork* pNetwork, WResourceManager* output, JGE* input) - : GameObserver(output, input), mpNetworkSession(pNetwork), mSynchronized(false) + : GameObserver(output, input), mpNetworkSession(pNetwork), mSynchronized(false) { - mpNetworkSession->registerCommand("loadPlayer", this, loadPlayer, ignoreResponse); - mpNetworkSession->registerCommand("synchronize", this, synchronize, checkSynchro); - mpNetworkSession->registerCommand("sendAction", this, sendAction, checkSynchro); - mpNetworkSession->registerCommand("disconnect", this, disconnect, ignoreResponse); + mpNetworkSession->registerCommand("loadPlayer", this, loadPlayer, ignoreResponse); + mpNetworkSession->registerCommand("synchronize", this, synchronize, checkSynchro); + mpNetworkSession->registerCommand("sendAction", this, sendAction, checkSynchro); + mpNetworkSession->registerCommand("disconnect", this, disconnect, ignoreResponse); } NetworkGameObserver::~NetworkGameObserver() { - mpNetworkSession->sendCommand("disconnect", ""); + mpNetworkSession->sendCommand("disconnect", ""); } void NetworkGameObserver::disconnect(void*pxThis, stringstream&, stringstream&) { - NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis; - pThis->setLoser(pThis->getView()->getRenderedPlayerOpponent()); + NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis; + pThis->setLoser(pThis->getView()->getRenderedPlayerOpponent()); } void NetworkGameObserver::Update(float dt) { - mpNetworkSession->Update(); - ::GameObserver::Update(dt); + mpNetworkSession->Update(); + ::GameObserver::Update(dt); } void NetworkGameObserver::loadPlayer(int playerId, Player* player) { - GameObserver::loadPlayer(playerId, player); - stringstream out; - out << *player; - mpNetworkSession->sendCommand("loadPlayer", out.str()); + GameObserver::loadPlayer(playerId, player); + stringstream out; + out << *player; + mpNetworkSession->sendCommand("loadPlayer", out.str()); } void NetworkGameObserver::loadPlayer(void*pxThis, stringstream& in, stringstream&) { - NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis; - Player* pPlayer = 0; + NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis; + Player* pPlayer = 0; string s; while(std::getline(in, s)) @@ -2135,50 +2135,50 @@ void NetworkGameObserver::loadPlayer(void*pxThis, stringstream& in, stringstream void NetworkGameObserver::synchronize() { - if(!mSynchronized && mpNetworkSession->isServer()) - { - stringstream out; - out << *this; - mpNetworkSession->sendCommand("synchronize", out.str()); - mSynchronized = true; - } + if(!mSynchronized && mpNetworkSession->isServer()) + { + stringstream out; + out << *this; + mpNetworkSession->sendCommand("synchronize", out.str()); + mSynchronized = true; + } } void NetworkGameObserver::synchronize(void*pxThis, stringstream& in, stringstream& out) { - NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis; - // now, we need to load the game from player 2's perspective - pThis->load(in.str(), false, 1); - out << *pThis; + NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis; + // now, we need to load the game from player 2's perspective + pThis->load(in.str(), false, 1); + out << *pThis; } void NetworkGameObserver::checkSynchro(void*pxThis, stringstream& in, stringstream&) { - NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis; - - GameObserver aGame; - aGame.mRules = pThis->mRules; - aGame.load(in.str()); + NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis; + + GameObserver aGame; + aGame.mRules = pThis->mRules; + aGame.load(in.str()); - assert(aGame == *pThis); + assert(aGame == *pThis); } void NetworkGameObserver::sendAction(void*pxThis, stringstream& in, stringstream&) { - NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis; + NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis; pThis->mForwardAction = false; - pThis->processAction(in.str()); + pThis->processAction(in.str()); pThis->mForwardAction = true; - //out << *pThis; + //out << *pThis; } void NetworkGameObserver::logAction(const string& s) { - GameObserver::logAction(s); - if(mForwardAction) - mpNetworkSession->sendCommand("sendAction", s); + GameObserver::logAction(s); + if(mForwardAction) + mpNetworkSession->sendCommand("sendAction", s); } #endif diff --git a/projects/mtg/src/GameOptions.cpp b/projects/mtg/src/GameOptions.cpp index 548029827..c10bf2435 100644 --- a/projects/mtg/src/GameOptions.cpp +++ b/projects/mtg/src/GameOptions.cpp @@ -18,8 +18,8 @@ const string Options::optionNames[] = { "sfxVolume", "difficulty", "cheatmode", - "optimizedhand", - "cheatmodedecks", + "optimizedhand", + "cheatmodedecks", "displayOSD", "closed_hand", "hand_direction", @@ -352,11 +352,11 @@ int GameOptions::load() } // (PSY) Make sure that cheatmode is switched off for ineligible profiles: if (options[Options::ACTIVE_PROFILE].str != SECRET_PROFILE) - { + { (*this)[Options::CHEATMODE].number = 0; - (*this)[Options::OPTIMIZE_HAND].number = 0; - (*this)[Options::CHEATMODEAIDECK].number = 0; - } + (*this)[Options::OPTIMIZE_HAND].number = 0; + (*this)[Options::CHEATMODEAIDECK].number = 0; + } //Default values. Anywhere else to put those ? if (!(*this)[Options::MAX_GRADE].number) @@ -371,11 +371,11 @@ int GameOptions::save() { // (PSY) Make sure that cheatmode is switched off for ineligible profiles: if (options[Options::ACTIVE_PROFILE].str != SECRET_PROFILE) - { + { (*this)[Options::CHEATMODE].number = 0; - (*this)[Options::OPTIMIZE_HAND].number = 0; - (*this)[Options::CHEATMODEAIDECK].number = 0; - } + (*this)[Options::OPTIMIZE_HAND].number = 0; + (*this)[Options::CHEATMODEAIDECK].number = 0; + } std::ofstream file; if (JFileSystem::GetInstance()->openForWrite(file, mFilename)) @@ -997,9 +997,9 @@ OptionManaDisplay::OptionManaDisplay() { mDef.values.push_back(EnumDefinition::assoc(DYNAMIC, "Eye candy")); mDef.values.push_back(EnumDefinition::assoc(STATIC, "Simple")); - mDef.values.push_back(EnumDefinition::assoc(NOSTARSDYNAMIC, "No Glitter")); + mDef.values.push_back(EnumDefinition::assoc(NOSTARSDYNAMIC, "No Glitter")); mDef.values.push_back(EnumDefinition::assoc(BOTH, "Both"));//no luck in getting this to show up as an option. - //Both should still work as always however the enum and this dont want to pair up, no "both" in options now. + //Both should still work as always however the enum and this dont want to pair up, no "both" in options now. } ; OptionVolume OptionVolume::mDef; diff --git a/projects/mtg/src/GameState.cpp b/projects/mtg/src/GameState.cpp index 30c4eabd1..ff26683fc 100644 --- a/projects/mtg/src/GameState.cpp +++ b/projects/mtg/src/GameState.cpp @@ -70,7 +70,7 @@ vector GameState::BuildDeckList(const string& path, const string { std::ostringstream aiStatsDeckName; aiStatsDeckName << smallDeckPrefix << "_deck" << nbDecks; - meta->mStatsFilename = aiStatsDeckName.str(); + meta->mStatsFilename = aiStatsDeckName.str(); meta->mIsAI = true; if (meta->mPlayerDeck != statsPlayer->GetCurrentDeckStatsFile()) { @@ -100,7 +100,7 @@ vector GameState::BuildDeckList(const string& path, const string meta = NULL; } - std::sort(retList.begin(), retList.end(), sortByName); + std::sort(retList.begin(), retList.end(), sortByName); return retList; } diff --git a/projects/mtg/src/GameStateDuel.cpp b/projects/mtg/src/GameStateDuel.cpp index 2af6be905..98baeddf1 100644 --- a/projects/mtg/src/GameStateDuel.cpp +++ b/projects/mtg/src/GameStateDuel.cpp @@ -1095,7 +1095,7 @@ void GameStateDuel::Render() char buf[4096]; mFont->SetColor(ARGB(255,255,255,255)); - int elapsedTime = testSuite->getElapsedTime(); + int elapsedTime = testSuite->getElapsedTime(); sprintf(buf, "Time to run the tests: %is", elapsedTime/1000); mFont->DrawString(buf,0,SCREEN_HEIGHT/2 - 20); diff --git a/projects/mtg/src/GameStateMenu.cpp b/projects/mtg/src/GameStateMenu.cpp index 0fa693f16..82dc9f005 100644 --- a/projects/mtg/src/GameStateMenu.cpp +++ b/projects/mtg/src/GameStateMenu.cpp @@ -169,7 +169,7 @@ void GameStateMenu::genNbCardsStr() PlayerData * playerdata = NEW PlayerData(MTGCollection()); size_t totalUnique = MTGCollection()->primitives.size(); size_t totalPrints = MTGCollection()->totalCards(); - + if (totalUnique != totalPrints) { if (playerdata && !options[Options::ACTIVE_PROFILE].isDefault()) @@ -481,7 +481,7 @@ void GameStateMenu::Update(float dt) mParent->mpNetwork->connect(mParent->mServerAddress); // we let the server choose the game mode mParent->gameType = GAME_TYPE_SLAVE; - // just to select one, the HOST is in control here. + // just to select one, the HOST is in control here. mParent->rules = Rules::getRulesByFilename("classic.txt"); hasChosenGameType = true; subMenuController->Close(); @@ -599,16 +599,16 @@ void GameStateMenu::Update(float dt) case MENU_STATE_NETWORK_DEFINE: if(MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR)) { - currentState = MENU_STATE_MAJOR_SUBMENU; + currentState = MENU_STATE_MAJOR_SUBMENU; subMenuController = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60); - if (subMenuController) - { - subMenuController->Add(SUBMENUITEM_HOST_GAME, "Host a game"); - subMenuController->Add(SUBMENUITEM_JOIN_GAME, "Join a game"); - subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel"); - } - } - break; + if (subMenuController) + { + subMenuController->Add(SUBMENUITEM_HOST_GAME, "Host a game"); + subMenuController->Add(SUBMENUITEM_JOIN_GAME, "Join a game"); + subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel"); + } + } + break; case MENU_STATE_NETWORK_WAIT: if(MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR)) { @@ -619,9 +619,9 @@ void GameStateMenu::Update(float dt) } else if(!subMenuController) { - string aString; - mParent->mpNetwork->getServerIp(aString); - aString = "Waiting for connection to " + aString; + string aString; + mParent->mpNetwork->getServerIp(aString); + aString = "Waiting for connection to " + aString; subMenuController = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60, aString.c_str()); if (subMenuController) @@ -918,7 +918,7 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId) subMenuController->Close(); } #ifdef NETWORK_SUPPORT - SAFE_DELETE(mParent->mpNetwork); + SAFE_DELETE(mParent->mpNetwork); #endif //NETWORK_SUPPORT currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_SUBMENU_CLOSING; break; diff --git a/projects/mtg/src/GameStateOptions.cpp b/projects/mtg/src/GameStateOptions.cpp index 95d4856c9..57d983833 100644 --- a/projects/mtg/src/GameStateOptions.cpp +++ b/projects/mtg/src/GameStateOptions.cpp @@ -81,8 +81,8 @@ void GameStateOptions::Start() optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"), -102, GameStateOptionsConst::kNewProfileID, this)); optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODE, "Enable Cheat Mode"))); - optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::OPTIMIZE_HAND, "Optimize Starting Hand"))); - optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODEAIDECK, "Unlock All Ai Decks"))); + optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::OPTIMIZE_HAND, "Optimize Starting Hand"))); + optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODEAIDECK, "Unlock All Ai Decks"))); optionsTabs->Add(optionsList); diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index d7f6f76b5..47f300379 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -627,12 +627,12 @@ void GameStateShop::Update(float dt) else if (btn == JGE_BTN_CANCEL) options[Options::DISABLECARDS].number = !options[Options::DISABLECARDS].number; else if (btn == JGE_BTN_SEC) - { + { bListCards = !bListCards; disablePurchase = false; clearInput = true; return; - } + } else if (shopMenu) { #if defined (IOS) || defined (ANDROID) @@ -770,7 +770,7 @@ void GameStateShop::Render() #ifndef TOUCH_ENABLED float len = 4 + mFont->GetStringWidth(kOtherCardsString.c_str()); - r->RenderQuad(pspIcons[6].get(), SCREEN_WIDTH - len - 0.5 - 10, SCREEN_HEIGHT - 8, 0, kPspIconScaleFactor, kPspIconScaleFactor); + r->RenderQuad(pspIcons[6].get(), SCREEN_WIDTH - len - 0.5 - 10, SCREEN_HEIGHT - 8, 0, kPspIconScaleFactor, kPspIconScaleFactor); mFont->DrawString(kOtherCardsString, SCREEN_WIDTH - len, SCREEN_HEIGHT - 14); #else enableButtons(); diff --git a/projects/mtg/src/GuiAvatars.cpp b/projects/mtg/src/GuiAvatars.cpp index 173604e05..b12d2a8fd 100644 --- a/projects/mtg/src/GuiAvatars.cpp +++ b/projects/mtg/src/GuiAvatars.cpp @@ -10,11 +10,11 @@ GuiAvatars::GuiAvatars(DuelLayers* duelLayers) : GuiLayer(duelLayers), active(NULL) { - Add(self = NEW GuiAvatar(SCREEN_WIDTH, SCREEN_HEIGHT, false, mpDuelLayers->getRenderedPlayer(), GuiAvatar::BOTTOM_RIGHT, this)); + 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)); - //myexile + //myexile 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)); diff --git a/projects/mtg/src/GuiHand.cpp b/projects/mtg/src/GuiHand.cpp index ef318c8c9..950585dd9 100644 --- a/projects/mtg/src/GuiHand.cpp +++ b/projects/mtg/src/GuiHand.cpp @@ -330,4 +330,4 @@ int GuiHandOpponent::receiveEventMinus(WEvent* e) // I wanna write it like that. GCC doesn't want me to without -O. // I'm submitting a bug report. -// it->x = (it->x + (flip ? RightRowX : LeftRowX)) / 2; +// it->x = (it->x + (flip ? RightRowX : LeftRowX)) / 2; diff --git a/projects/mtg/src/GuiMana.cpp b/projects/mtg/src/GuiMana.cpp index e5ab1145c..14c73d720 100644 --- a/projects/mtg/src/GuiMana.cpp +++ b/projects/mtg/src/GuiMana.cpp @@ -106,14 +106,14 @@ ManaIcon::ManaIcon(int color, float x, float y, float destx, float desty) : // if we want to throttle the amount of particles for mana, // here's where to do it - this is hardcoded to something like 114 in the psi file - if(OptionManaDisplay::NOSTARSDYNAMIC == options[Options::MANADISPLAY].number) - { + if(OptionManaDisplay::NOSTARSDYNAMIC == options[Options::MANADISPLAY].number) + { particleSys->info.nEmission = 0; - } - else - { + } + else + { particleSys->info.nEmission = 60; - } + } icon = manaIcons[color]; particleSys->FireAt(x, y); @@ -193,7 +193,7 @@ void ManaIcon::Update(float dt, float shift) if (particleSys && (fabs(destx - x) < 5) && (fabs(desty + shift - y) < 5)) { - if (OptionManaDisplay::STATIC == options[Options::MANADISPLAY].number) + if (OptionManaDisplay::STATIC == options[Options::MANADISPLAY].number) { SAFE_DELETE(particleSys); //Static Mana Only: avoid expensive particle processing } @@ -305,7 +305,7 @@ void GuiMana::Render() for (vector::iterator it = manas.begin(); it != manas.end(); ++it) (*it)->Render(); - if (OptionManaDisplay::DYNAMIC != options[Options::MANADISPLAY].number && OptionManaDisplay::NOSTARSDYNAMIC != options[Options::MANADISPLAY].number ) + if (OptionManaDisplay::DYNAMIC != options[Options::MANADISPLAY].number && OptionManaDisplay::NOSTARSDYNAMIC != options[Options::MANADISPLAY].number ) RenderStatic(); } diff --git a/projects/mtg/src/GuiPlay.cpp b/projects/mtg/src/GuiPlay.cpp index e4fc0bd7c..02bbe0939 100644 --- a/projects/mtg/src/GuiPlay.cpp +++ b/projects/mtg/src/GuiPlay.cpp @@ -124,7 +124,7 @@ void GuiPlay::BattleField::reset(float x, float y) void GuiPlay::BattleField::EnstackAttacker(CardView* card) { card->x = CARD_WIDTH + 20 + (currentAttacker * (HORZWIDTH) / (attackers+1)); - card->y = baseY + (card->card->getObserver()->getView()->getRenderedPlayer() == card->card->controller() ? 20 + y : -20 - y); + card->y = baseY + (card->card->getObserver()->getView()->getRenderedPlayer() == card->card->controller() ? 20 + y : -20 - y); ++currentAttacker; // JRenderer::GetInstance()->RenderQuad(WResourceManager::Instance()->GetQuad("BattleIcon"), card->actX, card->actY, 0, 0.5 + 0.1 * sinf(JGE::GetInstance()->GetTime()), 0.5 + 0.1 * sinf(JGE::GetInstance()->GetTime())); } @@ -197,7 +197,7 @@ void GuiPlay::Replace() { if((!(*it)->card->hasSubtype(Subtypes::TYPE_AURA)|| ((*it)->card->hasSubtype(Subtypes::TYPE_AURA) && (*it)->card->playerTarget)) && !(*it)->card->hasType(Subtypes::TYPE_PLANESWALKER)) { - if (mpDuelLayers->getRenderedPlayer() == (*it)->card->controller()) + if (mpDuelLayers->getRenderedPlayer() == (*it)->card->controller()) ++selfSpellsN; else ++opponentSpellsN; @@ -398,7 +398,7 @@ int GuiPlay::receiveEventPlus(WEvent * e) } else { - // this should never happen, if you have a consistent repro case, ping Wil please + // this should never happen, if you have a consistent repro case, ping Wil please assert(false); } return 1; diff --git a/projects/mtg/src/IconButton.cpp b/projects/mtg/src/IconButton.cpp index 75515b478..8644183b2 100644 --- a/projects/mtg/src/IconButton.cpp +++ b/projects/mtg/src/IconButton.cpp @@ -4,8 +4,8 @@ #include "WResourceManager.h" #include "WFont.h" -#define SCALE_SELECTED 1.2f -#define SCALE_NORMAL 1.0f +#define SCALE_SELECTED 1.2f +#define SCALE_NORMAL 1.0f IconButtonsController::IconButtonsController(JGE* jge, float x, float y): JGuiController(jge, 0, NULL), mX(x), mY(y) { diff --git a/projects/mtg/src/InteractiveButton.cpp b/projects/mtg/src/InteractiveButton.cpp index 91a41813b..b86524204 100644 --- a/projects/mtg/src/InteractiveButton.cpp +++ b/projects/mtg/src/InteractiveButton.cpp @@ -80,7 +80,7 @@ void InteractiveButton::Render() mYOffset += 2; #endif - float buttonXOffset = getX() - mXOffset; + float buttonXOffset = getX() - mXOffset; float buttonYOffset = getY() + mYOffset; if (buttonImage != NULL) { diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 99cb4744b..16ffa9b41 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -730,8 +730,8 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell bool limitOnceATurn = (s.find("turnlimited") != string::npos); bool isSuspended = (s.find("suspended") != string::npos); bool opponentPoisoned = (s.find("opponentpoisoned") != string::npos); - bool lifelost = (s.find("foelost(") != string::npos); - int lifeamount = lifelost ? atoi(s.substr(s.find("foelost(") + 8,')').c_str()) : 0; + bool lifelost = (s.find("foelost(") != string::npos); + int lifeamount = lifelost ? atoi(s.substr(s.find("foelost(") + 8,')').c_str()) : 0; bool neverRemove = (s.find("dontremove") != string::npos); //Card Changed Zone @@ -1063,12 +1063,12 @@ MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a) if (MultiAbility * abi = dynamic_cast(a)) return getCoreAbility(abi->abilities[0]); - if (NestedAbility * na = dynamic_cast (a)) - { - if(na->ability) - //only atempt to return a nestedability if it contains a valid ability. example where this causes a bug otherwise. AEquip is considered nested, but contains no ability. - return getCoreAbility(na->ability); - } + if (NestedAbility * na = dynamic_cast (a)) + { + if(na->ability) + //only atempt to return a nestedability if it contains a valid ability. example where this causes a bug otherwise. AEquip is considered nested, but contains no ability. + return getCoreAbility(na->ability); + } if (MenuAbility * ma = dynamic_cast(a)) return getCoreAbility(ma->abilities[0]); @@ -1093,8 +1093,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG MTGCardInstance * target = card->target; if (!target) target = card; - //pay and castcard? - if(s.find("castcard(restricted") != string::npos && (s.find("pay(") != string::npos || s.find("pay[[") != string::npos)) + //pay and castcard? + if(s.find("castcard(restricted") != string::npos && (s.find("pay(") != string::npos || s.find("pay[[") != string::npos)) asAlternate = true; //MTG Specific rules //adds the bonus credit system @@ -1826,7 +1826,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG found = string::npos; i = -1; - for (size_t j = 0; j < kLordKeywordsCount; ++j) + for (size_t j = 0; j < kLordKeywordsCount; ++j) { size_t found2 = s.find(kLordKeywords[j]); if (found2 != string::npos && ((found == string::npos) || found2 < found)) @@ -2602,16 +2602,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG return a; } - //set hand size - vector splitSetHand = parseBetween(s, "sethand:", " ", false); - if (splitSetHand.size()) - { - int hand = atoi(splitSetHand[1].c_str()); - Damageable * t = spell ? spell->getNextDamageableTarget() : NULL; + //set hand size + vector splitSetHand = parseBetween(s, "sethand:", " ", false); + if (splitSetHand.size()) + { + int hand = atoi(splitSetHand[1].c_str()); + Damageable * t = spell ? spell->getNextDamageableTarget() : NULL; MTGAbility * a = NEW AASetHand(observer, id, card, t, hand, NULL, who); - a->oneShot = 1; - return a; - } + a->oneShot = 1; + return a; + } //set life total vector splitLifeset = parseBetween(s, "lifeset:", " ", false); @@ -2723,7 +2723,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG } //Cast/Play Restrictions - for (size_t i = 0; i < kMaxCastKeywordsCount; ++i) + for (size_t i = 0; i < kMaxCastKeywordsCount; ++i) { vector splitCast = parseBetween(s, kMaxCastKeywords[i], ")"); if (splitCast.size()) @@ -2939,9 +2939,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG { vector becomesParameters = split(splitBecomes[1], ','); string stypes = becomesParameters[0]; - string newPower = ""; + string newPower = ""; string newToughness = ""; - bool ptFound = false; + bool ptFound = false; if(becomesParameters.size() >1) { vector pt = split(becomesParameters[1], '/'); @@ -2952,17 +2952,17 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG ptFound = true; } } - string sabilities = ""; + string sabilities = ""; unsigned int becomesSize = ptFound?2:1; - if(becomesParameters.size() > becomesSize) - { - for(unsigned int i = becomesSize;i < becomesParameters.size();i++) - { - sabilities.append(becomesParameters[i].c_str()); - if(i+1 < becomesParameters.size()) - sabilities.append(","); - } - } + if(becomesParameters.size() > becomesSize) + { + for(unsigned int i = becomesSize;i < becomesParameters.size();i++) + { + sabilities.append(becomesParameters[i].c_str()); + if(i+1 < becomesParameters.size()) + sabilities.append(","); + } + } if (oneShot || forceUEOT || forceForever) return NEW ATransformerInstant(observer, id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector(),false,forceForever,untilYourNextTurn); @@ -3044,14 +3044,14 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG newtoughnessfound = true; newtoughness = splitToughness[1]; } - if(abilities[j].find("newability[") != string::npos) - { - size_t NewSkill = abilities[j].find("newability["); - size_t NewSkillEnd = abilities[j].find_last_of("]"); - string newAbilities = abilities[j].substr(NewSkill + 11,NewSkillEnd - NewSkill - 11); - newAbilitiesList.push_back(newAbilities); - newAbilityFound = true; - } + if(abilities[j].find("newability[") != string::npos) + { + size_t NewSkill = abilities[j].find("newability["); + size_t NewSkillEnd = abilities[j].find_last_of("]"); + string newAbilities = abilities[j].substr(NewSkill + 11,NewSkillEnd - NewSkill - 11); + newAbilitiesList.push_back(newAbilities); + newAbilityFound = true; + } } if (oneShot || forceUEOT || forceForever) @@ -3088,7 +3088,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG { return NEW PTInstant(observer, id, card, target, wppt,s,nonstatic); } - else if(s.find("cdaactive") != string::npos) + else if(s.find("cdaactive") != string::npos) { MTGAbility * a = NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true); a->forcedAlive = 1; @@ -3096,7 +3096,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG return a; //return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true); } - else + else return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,nonstatic); } return NEW PTInstant(observer, id, card, target, wppt,s,nonstatic); diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index a56247912..6dfdb9add 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -753,7 +753,7 @@ bool MTGCardInstance::StackIsEmptyandSorcerySpeed() controller() == getObserver()->currentPlayer && !getObserver()->isInterrupting) { - return true; + return true; } return false; } @@ -777,10 +777,10 @@ bool MTGCardInstance::isTargetted() } } } - } + } if(cardistargetted) return true; - return false; + return false; } //check targetter? @@ -802,10 +802,10 @@ bool MTGCardInstance::isTargetter() } } } - } + } if(cardistargetter) return true; - return false; + return false; } int MTGCardInstance::canBlock() @@ -927,7 +927,7 @@ ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * old return oldCost; //use forcedalive// //pay zero costs// - //kicker???...// + //kicker???...// //morph cost todo// //trinisphere must be here below// if(card->has(Constants::TRINISPHERE)) diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index 738d8289d..0189b2208 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -281,7 +281,7 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi { string value = val; std::transform(value.begin(), value.end(), value.begin(), ::tolower); - cost->setSuspend(ManaCost::parseManaCost(value)); + cost->setSuspend(ManaCost::parseManaCost(value)); primitive->suspendedTime = suspendTime; } diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index 7728bd1d2..f01fbbd14 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -14,9 +14,9 @@ const string Constants::kManaRed = "red"; const string Constants::kManaBlack = "black"; const string Constants::kManaWhite = "white"; -int Constants::_r[7] = {75, 20, 20, 200,50,255,128}; -int Constants::_g[7] = {30, 140, 30, 15, 50,255,128}; -int Constants::_b[7] = {20, 0, 140,15, 50,255,128}; +int Constants::_r[7] = {75,20,20,200,50,255,128}; +int Constants::_g[7] = {30,140,30,15,50,255,128}; +int Constants::_b[7] = {20,0,140,15,50,255,128}; const string Constants::kAlternativeKeyword = "alternative"; @@ -184,36 +184,36 @@ int Constants::GetColorStringIndex(string mtgColor) const string Constants::MTGPhaseNames[] = { - "---", - "Untap", - "Upkeep", - "Draw", - "Main phase 1", - "Combat begins", - "Attackers", - "Blockers", - "Combat damage", - "Combat ends", - "Main phase 2", - "End", - "Cleanup", - "---" + "---", + "Untap", + "Upkeep", + "Draw", + "Main phase 1", + "Combat begins", + "Attackers", + "Blockers", + "Combat damage", + "Combat ends", + "Main phase 2", + "End", + "Cleanup", + "---" }; const char* Constants::MTGPhaseCodeNames[] = { - "beginofturn", - "untap", - "upkeep", - "draw", - "firstmain", - "combatbegins", - "attackers", - "blockers", - "combatdamage", - "combatends", - "secondmain", - "end", - "cleanup", - "beforenextturn" + "beginofturn", + "untap", + "upkeep", + "draw", + "firstmain", + "combatbegins", + "attackers", + "blockers", + "combatdamage", + "combatends", + "secondmain", + "end", + "cleanup", + "beforenextturn" }; diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 5fe7fcddd..cfa757aa2 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -323,12 +323,12 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone int doCopy = 1; bool shufflelibrary = card->basicAbilities[(int)Constants::SHUFFLELIBRARYDEATH]; bool inplaytoinplay = false; - bool ripToken = false; - if (g->players[0]->game->battlefield->hasName("Rest in Peace")||g->players[1]->game->battlefield->hasName("Rest in Peace")) + bool ripToken = false; + if (g->players[0]->game->battlefield->hasName("Rest in Peace")||g->players[1]->game->battlefield->hasName("Rest in Peace")) ripToken = true; //Madness or Put in Play... for(int i = 0; i < 2; ++i) - { + { if (card->discarded && (to == g->players[i]->game->graveyard) && (from == g->players[i]->game->hand)) { if(card->basicAbilities[(int)Constants::MADNESS]) @@ -337,7 +337,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone } //Darksteel Colossus, Legacy Weapon ... top priority since we replace destination directly automatically... for(int i = 0; i < 2; ++i) - { + { if ((to == g->players[i]->game->graveyard) && ( card->basicAbilities[(int)Constants::LIBRARYDEATH]|| card->basicAbilities[(int)Constants::SHUFFLELIBRARYDEATH])) @@ -347,13 +347,13 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone } //Leyline of the Void, Yawgmoth's Agenda... effect... for(int i = 0; i < 2; ++i) - { + { if ((to == g->players[i]->game->graveyard) && ( (g->players[i]->game->battlefield->hasAbility(Constants::MYGCREATUREEXILER) && card->isCreature()) || (g->players[i]->opponent()->game->battlefield->hasAbility(Constants::OPPGCREATUREEXILER) && card->isCreature())|| g->players[i]->game->battlefield->hasAbility(Constants::MYGRAVEEXILER) || g->players[i]->opponent()->game->battlefield->hasAbility(Constants::OPPGRAVEEXILER))) - { + { if ((card->isToken && ripToken)) to = g->players[i]->game->exile; if (!card->isToken) @@ -379,7 +379,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone {//set discarded for madness... if(from == g->players[0]->game->hand || from == g->players[1]->game->hand) copy->discarded = true; - else//turn off discarded if its previous zone is not in hand... + else//turn off discarded if its previous zone is not in hand... copy->discarded = false; } if (options[Options::SFXVOLUME].number > 0) @@ -742,7 +742,7 @@ bool MTGGameZone::hasColor(int value) { for (int i = 0; i < (nb_cards); i++) { - if (cards[i]->getManaCost()->hasColor(value) && cards[i]->getManaCost()->getConvertedCost() > 0) + if (cards[i]->getManaCost()->hasColor(value) && cards[i]->getManaCost()->getConvertedCost() > 0) { return true; } diff --git a/projects/mtg/src/MTGPack.cpp b/projects/mtg/src/MTGPack.cpp index 5e8b53d34..67ed5e4e4 100644 --- a/projects/mtg/src/MTGPack.cpp +++ b/projects/mtg/src/MTGPack.cpp @@ -28,7 +28,7 @@ int MTGPackEntryRandom::addCard(WSrcCards *pool, MTGDeck *to) } int MTGPackEntrySpecific::addCard(WSrcCards *, MTGDeck *to) { - if (!card) + if (!card) return copies; for (int i = 0; i < copies; i++) to->add(card); diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 88c31a78c..eeb228e53 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -58,8 +58,8 @@ int MTGEventBonus::receiveEvent(WEvent * event) //bonus for chain chain casting without tapping for mana or being interupted; //note gaining mana from other sources is still possible. //only spells going to the stack are counted. - if(game->turn <2)//this shouldnt trigger on first turn, chances are they are cheating. - return 0; + if(game->turn <2)//this shouldnt trigger on first turn, chances are they are cheating. + return 0; if (dynamic_cast(event)) { @@ -285,9 +285,9 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *) int cardsinhand = game->players[0]->game->hand->nb_cards; Player * player = game->currentlyActing(); if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card)) - return 0; - if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) - return 0; + return 0; + if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) + return 0; if ((game->turn < 1) && (cardsinhand != 0) && (card->basicAbilities[(int)Constants::LEYLINE]) && game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN && game->players[0]->game->graveyard->nb_cards == 0 @@ -478,13 +478,13 @@ int MTGKickerRule::isReactingToClick(MTGCardInstance * card, ManaCost *) return 0; Player * player = game->currentlyActing(); if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card)) - return 0; - if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) - return 0; + return 0; + if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) + return 0; ManaCost * kicker = card->getManaCost()->getKicker(); if(!kicker) { - SAFE_DELETE(kicker); + SAFE_DELETE(kicker); return 0; } ManaCost * playerMana = player->getManaPool(); @@ -627,13 +627,13 @@ PermanentAbility(observer, _id) int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) { - ManaCost * alternateCost = card->getManaCost()->getAlternative(); - if (!game->currentlyActing()->game->hand->hasCard(card) && !game->currentlyActing()->game->graveyard->hasCard(card) && !game->currentlyActing()->game->exile->hasCard(card)) - return 0; - if ((game->currentlyActing()->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (game->currentlyActing()->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) - return 0; if (card->alias == 110000) return 0;//overload has its own rule + ManaCost * alternateCost = card->getManaCost()->getAlternative(); + if (!game->currentlyActing()->game->hand->hasCard(card) && !game->currentlyActing()->game->graveyard->hasCard(card) && !game->currentlyActing()->game->exile->hasCard(card)) + return 0; + if ((game->currentlyActing()->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (game->currentlyActing()->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) + return 0; return isReactingToClick( card, mana, alternateCost ); } @@ -647,7 +647,7 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * return 0; - if(card->has(Constants::CANPLAYFROMGRAVEYARD)) + if(card->has(Constants::CANPLAYFROMGRAVEYARD)) alternativeName = "Alternate Cast From Graveyard"; else if(card->has(Constants::CANPLAYFROMEXILE)) alternativeName = "Alternate Cast From Exile"; @@ -686,11 +686,11 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card) { - if ( !isReactingToClick(card)) - return 0; + if ( !isReactingToClick(card)) + return 0; - ManaCost *alternateCost = card->getManaCost()->getAlternative(); - card->paymenttype = MTGAbility::ALTERNATIVE_COST; + ManaCost *alternateCost = card->getManaCost()->getAlternative(); + card->paymenttype = MTGAbility::ALTERNATIVE_COST; return reactToClick(card, alternateCost, ManaCost::MANA_PAID_WITH_ALTERNATIVE); } @@ -703,15 +703,15 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter if(overload) card->spellTargetType = ""; - else if(card->model->data->spellTargetType.size()) + else if(card->model->data->spellTargetType.size()) card->spellTargetType = card->model->data->spellTargetType; assert(alternateCost); if (alternateCost->isExtraPaymentSet() ) { if (!game->targetListIsSet(card)) - return 0; - } + return 0; + } else { alternateCost->setExtraCostsAction(this, card); @@ -790,9 +790,9 @@ int MTGBuyBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) { Player * player = game->currentlyActing(); if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card)) - return 0; - if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) - return 0; + return 0; + if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE))) + return 0; if(!allowedToCast(card,player)) return 0; return MTGAlternativeCostRule::isReactingToClick( card, mana, card->getManaCost()->getBuyback() ); @@ -1180,7 +1180,7 @@ int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) return 0; if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card))) return 0; - if(card->has(Constants::CANPLAYFROMGRAVEYARD)) + if(card->has(Constants::CANPLAYFROMGRAVEYARD)) CustomName = "Zero Cast From Graveyard"; else if(card->has(Constants::CANPLAYFROMEXILE)) CustomName = "Zero Cast From Exile"; @@ -1225,6 +1225,8 @@ MTGAlternativeCostRule(observer, _id) int MTGOverloadRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) { + if (card->alias != 110000) + return 0; Player * player = game->currentlyActing(); ManaCost * cost = NEW ManaCost(card->model->data->getManaCost()->getAlternative()); if(card->getIncreasedManaCost()->getConvertedCost()) @@ -1234,8 +1236,6 @@ int MTGOverloadRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) if (card->isLand()) return 0; - if (card->alias != 110000) - return 0; if (!player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card)) return 0; if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card))) @@ -1912,7 +1912,7 @@ MTGStoneHewerRule::MTGStoneHewerRule(GameObserver* observer, int _id, MTGAllCard for (size_t i = 0; i < collection->ids.size(); i++) { MTGCard * card = collection->collection[collection->ids[i]]; - if (card->data->hasSubtype("equipment") && (card->getRarity() != Constants::RARITY_T) && //remove tokens + if (card->data->hasSubtype("equipment") && (card->getRarity() != Constants::RARITY_T) && //remove tokens card->setId != MTGSets::INTERNAL_SET //remove cards that are defined in primitives. Those are workarounds (usually tokens) and should only be used internally ) { @@ -1928,32 +1928,32 @@ MTGStoneHewerRule::MTGStoneHewerRule(GameObserver* observer, int _id, MTGAllCard int MTGStoneHewerRule::receiveEvent(WEvent * event) { - WEventZoneChange * e = (WEventZoneChange *) event; - if (e->to == game->currentlyActing()->game->inPlay && e->card->isCreature()) - { - int eId = genRandomEquipId(e->card->getManaCost()->getConvertedCost()); - MTGCardInstance * card = genEquip(eId); - if(card) - { - game->currentlyActing()->game->temp->addCard(card); + WEventZoneChange * e = (WEventZoneChange *) event; + if (e->to == game->currentlyActing()->game->inPlay && e->card->isCreature()) + { + int eId = genRandomEquipId(e->card->getManaCost()->getConvertedCost()); + MTGCardInstance * card = genEquip(eId); + if(card) + { + game->currentlyActing()->game->temp->addCard(card); Spell * spell = NEW Spell(game, card); - spell->resolve(); - spell->source->isToken = 1; + spell->resolve(); + spell->source->isToken = 1; for (size_t i = 1; i < game->mLayers->actionLayer()->mObjects.size(); i++) - { + { MTGAbility * a = ((MTGAbility *) game->mLayers->actionLayer()->mObjects[i]); - AEquip * eq = dynamic_cast (a); - if (eq && eq->source == spell->source) - { - ((AEquip*)a)->unequip(); - ((AEquip*)a)->equip(e->card); - } - } - SAFE_DELETE(spell); - } - return 1; - } - return 0; + AEquip * eq = dynamic_cast (a); + if (eq && eq->source == spell->source) + { + ((AEquip*)a)->unequip(); + ((AEquip*)a)->equip(e->card); + } + } + SAFE_DELETE(spell); + } + return 1; + } + return 0; } MTGCardInstance * MTGStoneHewerRule::genEquip(int id) @@ -1967,8 +1967,8 @@ MTGCardInstance * MTGStoneHewerRule::genEquip(int id) int MTGStoneHewerRule::genRandomEquipId(int convertedCost) { - if (convertedCost >= 20) - convertedCost = 19; + if (convertedCost >= 20) + convertedCost = 19; int total_cards = 0; int i = (game->getRandomGenerator()->random() % int(convertedCost+1));//+1 becuase we want to generate a random "<=" the coverted. while (!total_cards && i >= 0) @@ -2004,29 +2004,29 @@ PermanentAbility(observer, _id) int MTGHermitRule::receiveEvent(WEvent * event) { - WEventPhaseChange * e = dynamic_cast(event); + WEventPhaseChange * e = dynamic_cast(event); if (e && e->from->id == MTG_PHASE_UNTAP) - { - MTGCardInstance * lcard = NULL; - vectorlands = vector(); - for(int i = 0; i < game->currentPlayer->game->library->nb_cards-1; i++) - { - MTGCardInstance * temp = game->currentPlayer->game->library->cards[i]; - if(temp && temp->isLand()) - lands.push_back(temp); - } - if(lands.size()) + { + MTGCardInstance * lcard = NULL; + vectorlands = vector(); + for(int i = 0; i < game->currentPlayer->game->library->nb_cards-1; i++) + { + MTGCardInstance * temp = game->currentPlayer->game->library->cards[i]; + if(temp && temp->isLand()) + lands.push_back(temp); + } + if(lands.size()) lcard = lands[game->getRandomGenerator()->random() % lands.size()]; - if(lcard) - { - MTGCardInstance * copy = game->currentPlayer->game->putInZone(lcard,game->currentPlayer->game->library, game->currentPlayer->game->temp); + if(lcard) + { + MTGCardInstance * copy = game->currentPlayer->game->putInZone(lcard,game->currentPlayer->game->library, game->currentPlayer->game->temp); Spell * spell = NEW Spell(game, copy); spell->resolve(); delete spell; - } - return 1; - } - return 0; + } + return 1; + } + return 0; } MTGHermitRule * MTGHermitRule::clone() const diff --git a/projects/mtg/src/ManaCost.cpp b/projects/mtg/src/ManaCost.cpp index 31a338161..df9446c67 100644 --- a/projects/mtg/src/ManaCost.cpp +++ b/projects/mtg/src/ManaCost.cpp @@ -94,7 +94,7 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan } //switch on the first letter. If two costs share their first letter, add an "if" within the switch - std::transform(value.begin(), value.end(), value.begin(), ::tolower); + std::transform(value.begin(), value.end(), value.begin(), ::tolower); switch (value[0]) { case 'x': @@ -695,7 +695,7 @@ ManaCostHybrid * ManaCost::getHybridCost(unsigned int i) ExtraCost * ManaCost::getExtraCost(unsigned int i) { if(extraCosts && extraCosts->costs.size()) - { + { if (extraCosts->costs.size() <= i) return NULL; return extraCosts->costs[i]; @@ -1055,7 +1055,7 @@ ostream& operator<<(ostream& out, ManaCost m) void ManaPool::Empty() { - SAFE_DELETE(extraCosts); + SAFE_DELETE(extraCosts); SAFE_DELETE(kicker); SAFE_DELETE(alternative); SAFE_DELETE(BuyBack); diff --git a/projects/mtg/src/ModRules.cpp b/projects/mtg/src/ModRules.cpp index a39c99bc9..102f35b87 100644 --- a/projects/mtg/src/ModRules.cpp +++ b/projects/mtg/src/ModRules.cpp @@ -301,12 +301,12 @@ ModRulesRenderCardGuiItem::ModRulesRenderCardGuiItem(string name, int posX, int mFormattedData = formattedData; mFilter = filter; mFontSize = fontSize; - mFont = font; + mFont = font; mFontColor = fontColor; mSizeIcon = SizeIcon; - mIconPosX = IconPosX; - mIconPosY = IconPosY; - mFileName = FileName; + mIconPosX = IconPosX; + mIconPosY = IconPosY; + mFileName = FileName; } @@ -318,12 +318,12 @@ void ModRulesCardGui::parse(TiXmlElement* element) string _FormattedText; string _Filter; int _FontSize; - bool _Font; - PIXEL_TYPE _FontColor; - int _SizeIcon; - int _IconPosX; - int _IconPosY; - string _FileName; + bool _Font; + PIXEL_TYPE _FontColor; + int _SizeIcon; + int _IconPosX; + int _IconPosY; + string _FileName; @@ -353,12 +353,12 @@ void ModRulesCardGui::parse(TiXmlElement* element) _FormattedText = ""; _Filter = ""; _FontSize = 0; - _Font = false; + _Font = false; _FontColor = 0; _SizeIcon = 0; - _IconPosX = 0; - _IconPosY = 0 ; - _FileName = ""; + _IconPosX = 0; + _IconPosY = 0 ; + _FileName = ""; TiXmlElement* ItemElement = node->ToElement(); @@ -379,11 +379,11 @@ void ModRulesCardGui::parse(TiXmlElement* element) } ChildNode = ItemElement->FirstChild("font"); - if (ChildNode) { - _Font = true; - _FontSize = atoi(ChildNode->ToElement()->Attribute("size")); - vector argb = split( ChildNode->ToElement()->Attribute("color"), ','); - _FontColor = ARGB( + if (ChildNode) { + _Font = true; + _FontSize = atoi(ChildNode->ToElement()->Attribute("size")); + vector argb = split( ChildNode->ToElement()->Attribute("color"), ','); + _FontColor = ARGB( atoi(argb[0].c_str()), atoi(argb[1].c_str()), atoi(argb[2].c_str()), @@ -392,7 +392,7 @@ void ModRulesCardGui::parse(TiXmlElement* element) } ChildNode = ItemElement->FirstChild("iconposition"); - if (ChildNode) { + if (ChildNode) { _IconPosX = atoi(ChildNode->ToElement()->Attribute("x")); _IconPosY = atoi(ChildNode->ToElement()->Attribute("y")); } @@ -408,7 +408,7 @@ void ModRulesCardGui::parse(TiXmlElement* element) } - + renderbig.push_back(NEW ModRulesRenderCardGuiItem( _Name, _Posx, _Posy, _FormattedText, _Filter,_Font, _FontSize, _FontColor,_SizeIcon,_IconPosX,_IconPosY,_FileName )); } } @@ -423,12 +423,12 @@ void ModRulesCardGui::parse(TiXmlElement* element) _FormattedText = ""; _Filter = ""; _FontSize = 0; - _Font = false; + _Font = false; _FontColor = 0; _SizeIcon = 0; - _IconPosX = 0; - _IconPosY = 0 ; - _FileName = ""; + _IconPosX = 0; + _IconPosY = 0 ; + _FileName = ""; TiXmlElement* ItemElement = node->ToElement(); @@ -449,11 +449,11 @@ void ModRulesCardGui::parse(TiXmlElement* element) } ChildNode = ItemElement->FirstChild("font"); - if (ChildNode) { - _Font = true; - _FontSize = atoi(ChildNode->ToElement()->Attribute("size")); - vector argb = split( ChildNode->ToElement()->Attribute("color"), ','); - _FontColor = ARGB( + if (ChildNode) { + _Font = true; + _FontSize = atoi(ChildNode->ToElement()->Attribute("size")); + vector argb = split( ChildNode->ToElement()->Attribute("color"), ','); + _FontColor = ARGB( atoi(argb[0].c_str()), atoi(argb[1].c_str()), atoi(argb[2].c_str()), @@ -462,7 +462,7 @@ void ModRulesCardGui::parse(TiXmlElement* element) } ChildNode = ItemElement->FirstChild("iconposition"); - if (ChildNode) { + if (ChildNode) { _IconPosX = atoi(ChildNode->ToElement()->Attribute("x")); _IconPosY = atoi(ChildNode->ToElement()->Attribute("y")); } @@ -478,7 +478,7 @@ void ModRulesCardGui::parse(TiXmlElement* element) } - + rendertinycrop.push_back(NEW ModRulesRenderCardGuiItem( _Name, _Posx, _Posy, _FormattedText, _Filter,_Font, _FontSize, _FontColor,_SizeIcon,_IconPosX,_IconPosY,_FileName )); } } diff --git a/projects/mtg/src/Player.cpp b/projects/mtg/src/Player.cpp index fe5c07931..8c4b7ca30 100644 --- a/projects/mtg/src/Player.cpp +++ b/projects/mtg/src/Player.cpp @@ -266,7 +266,7 @@ bool Player::DeadLifeState(bool check) if (cantlosers < 1) { if(!check) - { + { ActionStack * stack = getObserver()->mLayers->stackLayer(); for (int i = stack->mObjects.size() - 1; i >= 0; i--) { @@ -320,7 +320,7 @@ bool Player::parseLine(const string& s) } else if (areaS.compare("mode") == 0) { - this->playMode = (Player::Mode)atoi(s.substr(limiter + 1).c_str()); + this->playMode = (Player::Mode)atoi(s.substr(limiter + 1).c_str()); return true; } else if (areaS.compare("avatar") == 0) @@ -406,12 +406,12 @@ ostream& operator<<(ostream& out, const Player& p) { out << "mode=" << p.playMode << endl; out << *(Damageable*)&p; - if(p.manaPool) - { - string manapoolstring = p.manaPool->toString(); - if(manapoolstring != "") - out << "manapool=" << manapoolstring << endl; - } + if(p.manaPool) + { + string manapoolstring = p.manaPool->toString(); + if(manapoolstring != "") + out << "manapool=" << manapoolstring << endl; + } if(p.mAvatarName != "") out << "avatar=" << p.mAvatarName << endl; if(p.phaseRing != "") diff --git a/projects/mtg/src/Rules.cpp b/projects/mtg/src/Rules.cpp index e5f095454..80bf52ab2 100644 --- a/projects/mtg/src/Rules.cpp +++ b/projects/mtg/src/Rules.cpp @@ -18,9 +18,9 @@ vector Rules::RulesList = vector(); //Sorting by displayName struct RulesMenuCmp{ - bool operator()(const Rules * a,const Rules * b) const{ + bool operator()(const Rules * a,const Rules * b) const{ return a->displayName < b->displayName; - } + } } RulesMenuCmp_; Rules * Rules::getRulesByFilename(string _filename) @@ -391,12 +391,12 @@ void Rules::initGame(GameObserver *g, bool currentPlayerSet) if(OptionWhosFirst::WHO_O == options[Options::FIRSTPLAYER].number) initState.player = 1; } - if(!currentPlayerSet) - { - g->currentPlayerId = initState.player; - } - g->currentPlayer = g->players[g->currentPlayerId]; - g->currentActionPlayer = g->currentPlayer; + if(!currentPlayerSet) + { + g->currentPlayerId = initState.player; + } + g->currentPlayer = g->players[g->currentPlayerId]; + g->currentActionPlayer = g->currentPlayer; g->phaseRing->goToPhase(0, g->currentPlayer, false); g->phaseRing->goToPhase(initState.phase, g->currentPlayer); g->setCurrentGamePhase(initState.phase); @@ -623,7 +623,7 @@ GameType Rules::strToGameMode(string s) if (s.compare("random1") == 0) return GAME_TYPE_RANDOM1; if (s.compare("random2") == 0) return GAME_TYPE_RANDOM2; if (s.compare("story") == 0) return GAME_TYPE_STORY; - if (s.compare("stonehewer") == 0) return GAME_TYPE_STONEHEWER; - if (s.compare("hermit") == 0) return GAME_TYPE_HERMIT; + if (s.compare("stonehewer") == 0) return GAME_TYPE_STONEHEWER; + if (s.compare("hermit") == 0) return GAME_TYPE_HERMIT; return GAME_TYPE_CLASSIC; } diff --git a/projects/mtg/src/SimpleButton.cpp b/projects/mtg/src/SimpleButton.cpp index 9fabd7eac..3e4bdd026 100644 --- a/projects/mtg/src/SimpleButton.cpp +++ b/projects/mtg/src/SimpleButton.cpp @@ -42,7 +42,7 @@ JGuiObject(id), mX(x), mY(y), parent(_parent), mFontId(fontId) mXOffset = mX; - if (hasFocus) + if (hasFocus) { setIsSelectionValid(true); Entering(); diff --git a/projects/mtg/src/SimpleMenu.cpp b/projects/mtg/src/SimpleMenu.cpp index 8fb514185..eef34a2f1 100644 --- a/projects/mtg/src/SimpleMenu.cpp +++ b/projects/mtg/src/SimpleMenu.cpp @@ -144,7 +144,7 @@ void SimpleMenu::Render() float scaleFactor = titleFont->GetScale(); titleFont->SetScale(SCALE_NORMAL); if ((!title.empty()) && (mWidth < titleFont->GetStringWidth(title.c_str()))) - mWidth = titleFont->GetStringWidth(title.c_str()); + mWidth = titleFont->GetStringWidth(title.c_str()); titleFont->SetScale(scaleFactor); mWidth += 2 * SimpleMenuConst::kHorizontalMargin; diff --git a/projects/mtg/src/SimplePopup.cpp b/projects/mtg/src/SimplePopup.cpp index e8cccf5e4..0640dce45 100644 --- a/projects/mtg/src/SimplePopup.cpp +++ b/projects/mtg/src/SimplePopup.cpp @@ -19,7 +19,7 @@ SimplePopup::SimplePopup(int id, JGuiListener* listener, const int fontId, const { mX = 19; mY = 66; - mWidth = 180.0f; + mWidth = 180.0f; mTitle = _title; mMaxLines = 12; @@ -41,11 +41,11 @@ void SimplePopup::Render() const float textHeight = mTextFont->GetHeight() * mMaxLines; r->FillRoundRect(mX, mY + 2, mWidth + 11, textHeight - 12, 2.0f, ARGB( 255, 0, 0, 0 ) ); - // currently causes a crash on the PSP when drawing the corners. - // TODO: clean up the image ot make it loook cleaner. Find solution to load gfx to not crash PSP + // currently causes a crash on the PSP when drawing the corners. + // TODO: clean up the image ot make it loook cleaner. Find solution to load gfx to not crash PSP #if 0 r->DrawRoundRect(mX, mY + 2, mWidth + 11, textHeight - 12, 2.0f, ARGB( 255, 125, 255, 0) ); - drawBoundingBox( mX-3, mY, mWidth + 3, textHeight ); + drawBoundingBox( mX-3, mY, mWidth + 3, textHeight ); #endif mTextFont->DrawString(detailedInformation.c_str(), mX + 9 , mY + 10); @@ -58,22 +58,22 @@ void SimplePopup::drawBoundingBox( float x, float y, float width, float height ) //draw the corners string topCornerImageName = "top_corner.png"; string bottomCornerImageName = "bottom_corner.png"; - string verticalBarImageName = "vert_bar.png"; + string verticalBarImageName = "vert_bar.png"; string horizontalBarImageName = "top_bar.png"; - const float boxWidth = ( width + 15 ) / 3.0f; - const float boxHeight = ( height + 15 ) / 3.0f; + const float boxWidth = ( width + 15 ) / 3.0f; + const float boxHeight = ( height + 15 ) / 3.0f; - drawHorzPole( horizontalBarImageName, false, false, x, y, boxWidth ); - drawHorzPole( horizontalBarImageName, false, true, x, y + height, boxWidth ); - - drawVertPole( verticalBarImageName, false, false, x, y, boxHeight ); - drawVertPole( verticalBarImageName, true, false, x + width, y, boxHeight ); + drawHorzPole( horizontalBarImageName, false, false, x, y, boxWidth ); + drawHorzPole( horizontalBarImageName, false, true, x, y + height, boxWidth ); + + drawVertPole( verticalBarImageName, false, false, x, y, boxHeight ); + drawVertPole( verticalBarImageName, true, false, x + width, y, boxHeight ); - drawCorner( topCornerImageName, false, false, x, y ); - drawCorner( topCornerImageName, true, false, x + width, y ); - drawCorner( bottomCornerImageName, false, false, x, y + height ); - drawCorner( bottomCornerImageName, true, false, x + width, y + height ); + drawCorner( topCornerImageName, false, false, x, y ); + drawCorner( topCornerImageName, true, false, x + width, y ); + drawCorner( bottomCornerImageName, false, false, x, y + height ); + drawCorner( bottomCornerImageName, true, false, x + width, y + height ); } void SimplePopup::Update(DeckMetaData* selectedDeck) @@ -130,52 +130,52 @@ void SimplePopup::Update(float) // drawing routines void SimplePopup::drawCorner(string imageName, bool flipX, bool flipY, float x, float y) { - LOG(" Drawing a Corner! "); + LOG(" Drawing a Corner! "); JRenderer* r = JRenderer::GetInstance(); JQuadPtr horizontalBarImage = WResourceManager::Instance()->RetrieveTempQuad( imageName, TEXTURE_SUB_5551); - horizontalBarImage->SetHFlip(flipX); - horizontalBarImage->SetVFlip(flipY); + horizontalBarImage->SetHFlip(flipX); + horizontalBarImage->SetVFlip(flipY); - r->RenderQuad(horizontalBarImage.get(), x, y); - LOG(" Done Drawing a Corner! "); + r->RenderQuad(horizontalBarImage.get(), x, y); + LOG(" Done Drawing a Corner! "); } void SimplePopup::drawHorzPole(string imageName, bool flipX = false, bool flipY = false, float x = 0, float y = 0, float width = SCREEN_WIDTH_F) { - LOG(" Drawing a horizontal border! "); + LOG(" Drawing a horizontal border! "); JRenderer* r = JRenderer::GetInstance(); JQuadPtr horizontalBarImage = WResourceManager::Instance()->RetrieveTempQuad( imageName, TEXTURE_SUB_5551); - if ( horizontalBarImage != NULL ) - { - horizontalBarImage->SetHFlip(flipX); - horizontalBarImage->SetVFlip(flipY); + if ( horizontalBarImage != NULL ) + { + horizontalBarImage->SetHFlip(flipX); + horizontalBarImage->SetVFlip(flipY); - r->RenderQuad(horizontalBarImage.get(), x, y, 0, width); - } - else - { - LOG ( "ERROR: Error trying to render horizontal edge! "); - } - LOG(" Done Drawing a horizontal border! "); + r->RenderQuad(horizontalBarImage.get(), x, y, 0, width); + } + else + { + LOG ( "ERROR: Error trying to render horizontal edge! "); + } + LOG(" Done Drawing a horizontal border! "); } void SimplePopup::drawVertPole(string imageName, bool flipX = false, bool flipY = false, float x = 0, float y = 0, float height = SCREEN_HEIGHT_F) { - LOG(" Drawing a Vertical border! "); + LOG(" Drawing a Vertical border! "); JRenderer* r = JRenderer::GetInstance(); JQuadPtr verticalBarImage = WResourceManager::Instance()->RetrieveTempQuad( imageName, TEXTURE_SUB_5551); - if ( verticalBarImage != NULL ) - { - verticalBarImage->SetHFlip(flipX); - verticalBarImage->SetVFlip(flipY); + if ( verticalBarImage != NULL ) + { + verticalBarImage->SetHFlip(flipX); + verticalBarImage->SetVFlip(flipY); - r->RenderQuad(verticalBarImage.get(), x, y, 0, 1.0f, height); - } - else - { - LOG ( "ERROR: Error trying to render vertical edge! "); - } - LOG(" DONE Drawing a horizontal border! "); + r->RenderQuad(verticalBarImage.get(), x, y, 0, 1.0f, height); + } + else + { + LOG ( "ERROR: Error trying to render vertical edge! "); + } + LOG(" DONE Drawing a horizontal border! "); } diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index 0b361ef2a..687834fdf 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -1094,13 +1094,13 @@ bool TypeTargetChooser::canTarget(Targetable * target,bool withoutProtections) return true; } - if(card->getLCName().size()) - { + if(card->getLCName().size()) + { if (MTGAllCards::findType(card->getLCName()) == types[i]) return true; if (MTGAllCards::findType(card->getName()) == types[i]) return true; - } + } } return false; } diff --git a/projects/mtg/src/TestSuiteAI.cpp b/projects/mtg/src/TestSuiteAI.cpp index 35bb7e60f..0a3df4796 100644 --- a/projects/mtg/src/TestSuiteAI.cpp +++ b/projects/mtg/src/TestSuiteAI.cpp @@ -347,7 +347,7 @@ void TestSuiteGame::assertGame() int error = 0; bool wasAI = false; - if (observer->getCurrentGamePhase() != endState.phase) + if (observer->getCurrentGamePhase() != endState.phase) { sprintf(result, "==phase problem. Expected [ %s ](%i), got [ %s ](%i)==
", Constants::MTGPhaseNames[endState.phase].c_str(),endState.phase, @@ -577,7 +577,7 @@ int TestSuite::loadNext() #elif defined(IOS) thread_count = 6; #else - thread_count = 4; + thread_count = 4; #endif for(size_t i = 0; i < (thread_count-1); i++) mWorkerThread.push_back(new boost::thread(ThreadProc, this)); diff --git a/projects/mtg/src/TextScroller.cpp b/projects/mtg/src/TextScroller.cpp index 17a984b27..1283f10a3 100644 --- a/projects/mtg/src/TextScroller.cpp +++ b/projects/mtg/src/TextScroller.cpp @@ -32,7 +32,7 @@ void TextScroller::setRandom(int mode) void TextScroller::Add(string text) { if (!strings.size()) - mText = text; + mText = text; strings.push_back(text); } @@ -67,21 +67,21 @@ void TextScroller::Update(float dt) void TextScroller::Render() { WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); - mFont->DrawString(mText.c_str(), mX, mY, JGETEXT_LEFT, start, mWidth); + mFont->DrawString(mText.c_str(), mX, mY, JGETEXT_LEFT, start, mWidth); } ostream& TextScroller::toString(ostream& out) const { return out << "TextScroller ::: mText : " << mText - << " ; tempText : " << tempText - << " ; mWidth : " << mWidth + << " ; tempText : " << tempText + << " ; mWidth : " << mWidth << " ; mSpeed : " << mScrollSpeed - << " ; mX,mY : " << mX << "," << mY - << " ; start : " << start - << " ; timer : " << timer - << " ; strings : ?" - << " ; currentId : " << currentId - << " ; mRandom : " << mRandom; + << " ; mX,mY : " << mX << "," << mY + << " ; start : " << start + << " ; timer : " << timer + << " ; strings : ?" + << " ; currentId : " << currentId + << " ; mRandom : " << mRandom; } @@ -93,28 +93,28 @@ ostream& TextScroller::toString(ostream& out) const VerticalTextScroller::VerticalTextScroller(int fontId, float x, float y, float width, float height, float scrollSpeed, size_t numItemsShown) : TextScroller( fontId, x, y, width, scrollSpeed) { - mHeight = height; - mNbItemsShown = numItemsShown; - mMarginX = 0; - timer=0; - WFont *mFont = WResourceManager::Instance()->GetWFont(fontId); - mOriginalY = mY; - mMarginY = mY - mFont->GetHeight(); - Add("\n"); // initialize the scroller with a blank line + mHeight = height; + mNbItemsShown = numItemsShown; + mMarginX = 0; + timer=0; + WFont *mFont = WResourceManager::Instance()->GetWFont(fontId); + mOriginalY = mY; + mMarginY = mY - mFont->GetHeight(); + Add("\n"); // initialize the scroller with a blank line } void VerticalTextScroller::Add( string text ) { - strings.push_back( text ); - string wrappedText = wordWrap(text, mWidth, fontId); - mText.append(wrappedText); + strings.push_back( text ); + string wrappedText = wordWrap(text, mWidth, fontId); + mText.append(wrappedText); } /* - Updates happen everytime the top line disappears from view. - The top line is then moved to the end of the file and the scrolling resumes where it left off + Updates happen everytime the top line disappears from view. + The top line is then moved to the end of the file and the scrolling resumes where it left off */ void VerticalTextScroller::Update(float dt) @@ -145,5 +145,5 @@ void VerticalTextScroller::Update(float dt) void VerticalTextScroller::Render() { WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); - mFont->DrawString(mText.c_str(), mX, mY); + mFont->DrawString(mText.c_str(), mX, mY); } diff --git a/projects/mtg/src/WCachedResource.cpp b/projects/mtg/src/WCachedResource.cpp index 849d5a119..45723f8d7 100644 --- a/projects/mtg/src/WCachedResource.cpp +++ b/projects/mtg/src/WCachedResource.cpp @@ -82,7 +82,7 @@ WCachedTexture::WCachedTexture() WCachedTexture::~WCachedTexture() { if (texture) - SAFE_DELETE(texture); + SAFE_DELETE(texture); } JTexture * WCachedTexture::Actual() @@ -113,27 +113,27 @@ JQuadPtr WCachedTexture::GetQuad(float offX, float offY, float width, float heig resource = kPlaceholderID; } - std::map::iterator iter = mTrackedQuads.find(resource); - if (iter != mTrackedQuads.end()) - return iter->second; + std::map::iterator iter = mTrackedQuads.find(resource); + if (iter != mTrackedQuads.end()) + return iter->second; - JQuadPtr quad(NEW JQuad(texture, offX, offY, width, height)); + JQuadPtr quad(NEW JQuad(texture, offX, offY, width, height)); //Update JQ's values to what we called this with. quad->SetTextureRect(offX, offY, width, height); - mTrackedQuads.insert(std::pair(resource, quad)); + mTrackedQuads.insert(std::pair(resource, quad)); return quad; } JQuadPtr WCachedTexture::GetQuad(const string& resname) { - JQuadPtr result; - std::map::iterator iter = mTrackedQuads.find(resname); - if (iter != mTrackedQuads.end()) - result = iter->second; + JQuadPtr result; + std::map::iterator iter = mTrackedQuads.find(resname); + if (iter != mTrackedQuads.end()) + result = iter->second; - return result; + return result; } JQuadPtr WCachedTexture::GetCard(float offX, float offY, float width, float height, const string& resname) @@ -192,7 +192,7 @@ bool WCachedTexture::Attempt(const string& filename, int submode, int & error) string realname = filename; //Form correct filename. - if (submode & TEXTURE_SUB_CARD) + if (submode & TEXTURE_SUB_CARD) { if (submode & TEXTURE_SUB_THUMB) { diff --git a/projects/mtg/src/WDataSrc.cpp b/projects/mtg/src/WDataSrc.cpp index 7b11e6d49..a29e13f34 100644 --- a/projects/mtg/src/WDataSrc.cpp +++ b/projects/mtg/src/WDataSrc.cpp @@ -56,13 +56,13 @@ WSrcCards::WSrcCards(float delay) JQuadPtr WSrcCards::getImage(int offset) { - if (!WResourceManager::Instance()->IsThreaded()) - { + if (!WResourceManager::Instance()->IsThreaded()) + { if (mDelay && mLastInput < mDelay) { return WResourceManager::Instance()->RetrieveCard(getCard(offset), RETRIEVE_EXISTING); } - } + } return WResourceManager::Instance()->RetrieveCard(getCard(offset)); } diff --git a/projects/mtg/src/WFont.cpp b/projects/mtg/src/WFont.cpp index 12ea2cd24..1de0133bd 100644 --- a/projects/mtg/src/WFont.cpp +++ b/projects/mtg/src/WFont.cpp @@ -359,7 +359,7 @@ int WFBFont::PreCacheChar(const u8 *ch) #else x = (int)mSprites[index]->mX; y = (int)mSprites[index]->mY; - mTexture->UpdateBits(x, y, mFontSize, mFontSize, mCharBuffer); + mTexture->UpdateBits(x, y, mFontSize, mFontSize, mCharBuffer); #endif return index; } @@ -758,7 +758,7 @@ int WGBKFont::PreCacheChar(const u8 *ch) #else x = (int)mSprites[index]->mX; y = (int)mSprites[index]->mY; - mTexture->UpdateBits(x, y, mFontSize, mFontSize, mCharBuffer); + mTexture->UpdateBits(x, y, mFontSize, mFontSize, mCharBuffer); #endif return index; } diff --git a/projects/mtg/src/WResourceManager.cpp b/projects/mtg/src/WResourceManager.cpp index bfd4570df..6f24c030b 100644 --- a/projects/mtg/src/WResourceManager.cpp +++ b/projects/mtg/src/WResourceManager.cpp @@ -37,18 +37,18 @@ WResourceManager* WResourceManager::sInstance = NULL; WResourceManager* WResourceManager::Instance() { - if (sInstance == NULL) - { - sInstance = NEW ResourceManagerImpl; - } + if (sInstance == NULL) + { + sInstance = NEW ResourceManagerImpl; + } - return sInstance; + return sInstance; } void WResourceManager::Terminate() { - if (sInstance) - SAFE_DELETE(sInstance); + if (sInstance) + SAFE_DELETE(sInstance); } @@ -1040,12 +1040,12 @@ cacheItem* WCache::AttemptNew(const string& filename, in SAFE_DELETE(item); return NULL; } - else + else { DebugTrace("AttemptNew failed to load (not a 404 error). Deleting cache item " << ToHex(item)); SAFE_DELETE(item); mError = CACHE_ERROR_BAD; - return NULL; + return NULL; } } diff --git a/projects/mtg/src/utils.cpp b/projects/mtg/src/utils.cpp index ce846d21c..544fb35ff 100644 --- a/projects/mtg/src/utils.cpp +++ b/projects/mtg/src/utils.cpp @@ -328,13 +328,13 @@ std::string wordWrap(const std::string& sentence, float width, int fontId) string currentSentence = sentence.substr(breakIdx, idx - breakIdx); float stringLength = mFont->GetStringWidth( currentSentence.c_str() ); if (stringLength >= width) - { + { if ( stringLength > width ) { while ( sentence[idx-1] != ' ' ) idx--; } - retVal[idx-1] = '\n'; + retVal[idx-1] = '\n'; breakIdx = idx; numLines++; } @@ -344,12 +344,12 @@ std::string wordWrap(const std::string& sentence, float width, int fontId) string currentSentence = sentence.substr(breakIdx, idx - breakIdx); float stringLength = mFont->GetStringWidth( currentSentence.c_str() ); if (stringLength >= width) - { + { if ( stringLength > width ) { while ( sentence[idx-1] != ' ' ) idx--; - retVal[idx-1] = '\n'; + retVal[idx-1] = '\n'; } numLines++; } From cccc21c035e1f2e79feb98264d7f3fd5d5945041 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 13 Nov 2015 05:45:17 +0800 Subject: [PATCH 15/22] changed alias --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 94 ++++++++++---------- projects/mtg/include/MTGRules.h | 10 +-- projects/mtg/src/AIPlayerBaka.cpp | 16 +--- projects/mtg/src/CardGui.cpp | 8 +- projects/mtg/src/MTGAbility.cpp | 2 +- projects/mtg/src/MTGGameZones.cpp | 2 +- projects/mtg/src/MTGRules.cpp | 46 +++++----- 7 files changed, 83 insertions(+), 95 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 3dc75140d..5b042f5fc 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -10934,7 +10934,7 @@ toughness=1 [/card] [card] name=Blustersquall -alias=110000 +alias=11000 other={3}{U} name(Overload) target=creature|opponentbattlefield auto=overload tap all(creature|opponentbattlefield) @@ -11599,7 +11599,7 @@ toughness=2 [/card] [card] name=Boneyard Wurm -alias=001100 +alias=1111 anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive text=Boneyard Wurm's power and toughness are each equal to the number of creature cards in your graveyard. mana={1}{G} @@ -14117,7 +14117,7 @@ type=Sorcery [/card] [card] name=Cantivore -alias=001100 +alias=1111 abilities=vigilance anyzone=type:enchantment:graveyard/type:enchantment:graveyard cdaactive text=Vigilance -- Cantivore's power and toughness are each equal to the number of enchantment cards in all graveyards. @@ -16266,7 +16266,7 @@ type=Sorcery [/card] [card] name=Chemister's Trick -alias=110000 +alias=11000 other={3}{U}{R} name(Overload) target=creature|opponentbattlefield auto=paidmana -2/0 @@ -16564,7 +16564,7 @@ toughness=2 [/card] [card] name=Cho-Manno's Blessing -alias=0000 +alias=1000 abilities=auraward target=creature abilities=flash @@ -18099,7 +18099,7 @@ type=Instant [/card] [card] name=Cognivore -alias=001100 +alias=1111 abilities=flying anyzone=type:instant:graveyard/type:instant:graveyard cdaactive text=Flying -- Cognivore's power and toughness are each equal to the number of instant cards in all graveyards. @@ -18159,7 +18159,7 @@ type=Artifact [/card] [card] name=Coldsteel Heart -alias=0000 +alias=1000 auto=tap auto=chooseacolor {T}:add{chosencolor} chooseend text=Coldsteel Heart enters the battlefield tapped. -- As Coldsteel Heart enters the battlefield, choose a color. -- {T}: Add one mana of the chosen color to your mana pool. @@ -19399,7 +19399,7 @@ type=Instant [/card] [card] name=Counterflux -alias=110000 +alias=11000 other={1}{U}{U}{R} name(Overload) abilities=nofizzle target=*|opponentstack @@ -21069,7 +21069,7 @@ subtype=Aura Curse [/card] [card] name=Curse of Wizardry -alias=0000 +alias=1000 auto=chooseacolor transforms((,newability[@movedto(*[chosencolor]|mystack):life:-1 controller],newability[@movedto(*[chosencolor]|opponentstack):life:-1 opponent])) chooseend text=As Curse of Wizardry enters the battlefield, choose a color. -- Whenever a player casts a spell of the chosen color, that player loses 1 life. mana={2}{B}{B} @@ -21207,7 +21207,7 @@ type=Instant [/card] [card] name=Cyclonic Rift -alias=110000 +alias=11000 other={6}{U} name(Overload) target=*[-land]|opponentbattlefield auto=overload moveto(ownerhand) all(*[-land]|opponentbattlefield) @@ -24429,7 +24429,7 @@ text=Destroy target artifact with converted mana cost X. It can't be regenerated [/card] [card] name=Detritivore -alias=001100 +alias=1111 anyzone=type:land[-basic]:opponentgraveyard/type:land[-basic]:opponentgraveyard cdaactive autoexile=@counterremoved(0/0,1,Time) from(sourcecard) suspended:destroy target(land[-basic]) suspend(0)={X}{3}{R} @@ -25994,7 +25994,7 @@ type=Instant [/card] [card] name=Downsize -alias=110000 +alias=11000 other={2}{U} name(Overload) target=creature|opponentbattlefield auto=overload -4/0 all(creature|opponentbattlefield) @@ -28284,7 +28284,7 @@ subtype=Aura [/card] [card] name=Dynacharge -alias=110000 +alias=11000 other={2}{R} name(Overload) target=creature|mybattlefield auto=paidmana 2/0 @@ -29044,7 +29044,7 @@ toughness=1 [/card] [card] name=Electrickery -alias=110000 +alias=11000 other={1}{R} name(Overload) target=creature|opponentbattlefield auto=paidmana damage:1 @@ -35188,7 +35188,7 @@ toughness=2 [/card] [card] name=Flickering Ward -alias=0000 +alias=1000 abilities=auraward target=creature auto=chooseacolor teach(creature) protection from(*[chosencolor]) chooseend @@ -35267,7 +35267,7 @@ toughness=2 [/card] [card] name=Floating Shield -alias=0000 +alias=1000 abilities=auraward target=creature auto=chooseacolor teach(creature) protection from(*[chosencolor]) chooseend @@ -43662,7 +43662,7 @@ toughness=3 [/card] [card] name=Hall of Triumph -alias=0000 +alias=1000 auto=activatechooseacolor transforms((,newability[lord(creature[chosencolor]|mybattlefield) 1/1])) forever activatechooseend text=As Hall of Triumph enters the battlefield, choose a color. -- Creatures you control of the chosen color get +1/+1. mana={3} @@ -49496,7 +49496,7 @@ type=Sorcery [/card] [card] name=Iona, Shield of Emeria -alias=0000 +alias=1000 abilities=flying auto=chooseacolor maxCast(*[chosencolor])0 opponent chooseend text=Flying -- As Iona, Shield of Emeria enters the battlefield, choose a color. -- Your opponents can't cast spells of the chosen color. @@ -50633,7 +50633,7 @@ toughness=3 [/card] [card] name=Jihad -alias=0000 +alias=1000 auto=chooseacolor transforms((,newability[aslongas(*[chosencolor]|opponentbattlefield) lord(creature[white]|mybattlefield) 2/1],newability[aslongas(*[chosencolor]|opponentbattlefield) sacrifice <1])) chooseend text=As Jihad enters the battlefield, choose a color and an opponent. -- White creatures get +2/+1 as long as the chosen player controls a nontoken permanent of the chosen color. -- When the chosen player controls no nontoken permanents of the chosen color, sacrifice Jihad. mana={W}{W}{W} @@ -56208,7 +56208,7 @@ toughness=5 [/card] [card] name=Lhurgoyf -alias=001100 +alias=1111 anyzone=type:creature:graveyard/plusonetype:creature:graveyard cdaactive text=Lhurgoyf's power is equal to the number of creature cards in all graveyards and its toughness is equal to that number plus 1. mana={2}{G}{G} @@ -57589,7 +57589,7 @@ toughness=2 [/card] [card] name=Lord of Extinction -alias=001100 +alias=1111 anyzone=type:*:graveyard/type:*:graveyard cdaactive text=Lord of Extinction's power and toughness are each equal to the number of cards in all graveyards. mana={3}{B}{G} @@ -58325,7 +58325,7 @@ type=Instant [/card] [card] name=Lurebound Scarecrow -alias=0000 +alias=1000 auto=chooseacolor aslongas(*[chosencolor]|myBattlefield) sacrifice <1 chooseend text=As Lurebound Scarecrow enters the battlefield, choose a color. -- When you control no permanents of the chosen color, sacrifice Lurebound Scarecrow. mana={3} @@ -58954,7 +58954,7 @@ toughness=6 [/card] [card] name=Magnivore -alias=001100 +alias=1111 abilities=haste anyzone=type:sorcery:graveyard/type:sorcery:graveyard cdaactive text=Haste (This creature can attack the turn it comes under your control.) -- Magnivore's power and toughness are each equal to the number of sorcery cards in all graveyards. @@ -63482,7 +63482,7 @@ toughness=4 [/card] [card] name=Mizzium Mortars -alias=110000 +alias=11000 other={3}{R}{R}{R} name(Overload) target=creature|opponentbattlefield auto=paidmana damage:4 @@ -63493,7 +63493,7 @@ type=Sorcery [/card] [card] name=Mizzium Skin -alias=110000 +alias=11000 other={1}{U} name(Overload) target=creature|mybattlefield auto=paidmana 0/1 @@ -64747,7 +64747,7 @@ toughness=2 [/card] [card] name=Mortivore -alias=001100 +alias=1111 auto={B}:regenerate anyzone=type:creature:graveyard/type:creature:graveyard cdaactive text=Mortivore's power and toughness are each equal to the number of creature cards in all graveyards. -- {B}: Regenerate Mortivore. (The next time this creature would be destroyed this turn, it isn't. Instead tap it, remove all damage from it, and remove it from combat.) @@ -70982,7 +70982,7 @@ subtype=Equipment [/card] [card] name=Paradise Plume -alias=0000 +alias=1000 auto=chooseacolor transforms((,newability[{T}:add{chosencolor}],newability[@movedto(*[chosencolor]|stack):life:1 controller])) forever chooseend text=As Paradise Plume enters the battlefield, choose a color. -- Whenever a player casts a spell of the chosen color, you may gain 1 life. -- {T}: Add one mana of the chosen color to your mana pool. mana={4} @@ -71774,7 +71774,7 @@ type=Artifact [/card] [card] name=Pentarch Paladin -alias=0000 +alias=1000 abilities=flanking auto=chooseacolor {W}{W}{T}:destroy target(*[chosencolor]) chooseend text=Flanking (Whenever a creature without flanking blocks this creature, the blocking creature gets -1/-1 until end of turn.) -- As Pentarch Paladin enters the battlefield, choose a color. -- {W}{W}, {T}: Destroy target permanent of the chosen color. @@ -71786,7 +71786,7 @@ toughness=3 [/card] [card] name=Pentarch Ward -alias=0000 +alias=1000 abilities=auraward target=creature auto=chooseacolor teach(creature) protection from(*[chosencolor]) chooseend @@ -74923,7 +74923,7 @@ toughness=4 [/card] [card] name=Prism Ring -alias=0000 +alias=1000 auto=activatechooseacolor transforms((,newability[@movedto(*[chosencolor]|mystack):life:1 controller])) forever activatechooseend text=As Prism Ring enters the battlefield, choose a color. -- Whenever you cast a spell of the chosen color, you gain 1 life. mana={1} @@ -75394,7 +75394,7 @@ toughness=2 [/card] [card] name=Psychic Allergy -alias=0000 +alias=1000 auto=upcost[{S(island|mybattlefield)}{S(island|mybattlefield)}] sacrifice auto=chooseacolor transforms((,newability[@each opponent upkeep:damage:type:*[-token&chosencolor]:opponentbattlefield opponent])) chooseend text=As Psychic Allergy enters the battlefield, choose a color. -- At the beginning of each opponent's upkeep, Psychic Allergy deals X damage to that player, where X is the number of nontoken permanents of the chosen color he or she controls. -- At the beginning of your upkeep, destroy Psychic Allergy unless you sacrifice two Islands. @@ -76490,7 +76490,7 @@ toughness=1 [/card] [card] name=Quirion Elves -alias=0000 +alias=1000 auto={T}:Add{G} auto=chooseacolor {T}:add{chosencolor} chooseend text=As Quirion Elves enters the battlefield, choose a color. -- {T}: Add {G} to your mana pool. -- {T}: Add one mana of the chosen color to your mana pool. @@ -79975,7 +79975,7 @@ type=Artifact [/card] [card] name=Revenant -alias=001100 +alias=1111 abilities=flying anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive text=Flying -- Revenant's power and toughness are each equal to the number of creature cards in your graveyard. @@ -87950,7 +87950,7 @@ toughness=2 [/card] [card] name=Shifting Sky -alias=0000 +alias=1000 auto=chooseacolor lord(*[-land]) becomes(,chosencolor) chooseend text=As Shifting Sky enters the battlefield, choose a color. -- All nonland permanents are the chosen color. mana={2}{U} @@ -89235,7 +89235,7 @@ toughness=1 [/card] [card] name=Silhana Starfletcher -alias=0000 +alias=1000 abilities=reach auto=activatechooseacolor {T}:add{chosencolor} activatechooseend text=Reach (This creature can block creatures with flying.) -- As Silhana Starfletcher enters the battlefield, choose a color. -- {T}: Add one mana of the chosen color to your mana pool. @@ -91122,7 +91122,7 @@ toughness=3 [/card] [card] name=Slag Fiend -alias=001100 +alias=1111 anyzone=type:artifact:graveyard/type:artifact:graveyard cdaactive text=Slag Fiend's power and toughness are each equal to the number of artifact cards in all graveyards. mana={R} @@ -92174,7 +92174,7 @@ toughness=3 [/card] [card] name=Sol Grail -alias=0000 +alias=1000 auto=chooseacolor transforms((,newability[{T}:add{chosencolor}])) forever chooseend text=As Sol Grail enters the battlefield, choose a color. -- {T}: Add one mana of the chosen color to your mana pool. mana={3} @@ -94828,7 +94828,7 @@ color=green [/card] [card] name=Splinterfright -alias=001100 +alias=1111 abilities=trample anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive auto=@each my upkeep:deplete:2 controller @@ -97060,7 +97060,7 @@ toughness=4 [/card] [card] name=Street Spasm -alias=110000 +alias=11000 other={X}{X}{R}{R} name(Overload) target=creature[-flying]|opponentbattlefield auto=paidmana damage:X @@ -100291,7 +100291,7 @@ type=Legendary Land [/card] [card] name=Teferi's Moat -alias=0000 +alias=1000 auto=chooseacolor lord(creature[chosencolor&-flying]|opponentBattlefield) cantattack chooseend text=As Teferi's Moat enters the battlefield, choose a color. -- Creatures of the chosen color without flying can't attack you. mana={3}{W}{U} @@ -100481,7 +100481,7 @@ type=Instant [/card] [card] name=Teleportal -alias=110000 +alias=11000 other={3}{U}{R} name(Overload) target=creature|mybattlefield auto=paidmana 1/0 @@ -101009,7 +101009,7 @@ type=Artifact [/card] [card] name=Terravore -alias=001100 +alias=1111 abilities=trample anyzone=type:land:graveyard/type:land:graveyard cdaactive text=Trample -- Terravore's power and toughness are each equal to the number of land cards in all graveyards. @@ -106235,7 +106235,7 @@ type=Artifact [/card] [card] name=Umbra Stalker -alias=001100 +alias=1111 anyzone=type:manab:mygraveyard/type:manab:mygraveyard cdaactive text=Chroma - Umbra Stalker's power and toughness are each equal to the number of black mana symbols in the mana costs of cards in your graveyard. mana={4}{B}{B}{B} @@ -107791,7 +107791,7 @@ subtype=Aura [/card] [card] name=Vandalblast -alias=110000 +alias=11000 other={4}{R} name(Overload) target=artifact|opponentbattlefield auto=overload destroy all(artifact|opponentbattlefield) @@ -110092,7 +110092,7 @@ toughness=2 [/card] [card] name=Voice of All -alias=0000 +alias=1000 abilities=flying auto=chooseacolor transforms((,newability[protection from(*[chosencolor])],newability[0/0])) forever chooseend text=Flying (This creature can't be blocked except by creatures with flying or reach.) -- As Voice of All enters the battlefield, choose a color. -- Voice of All has protection from the chosen color. (It can't be blocked, targeted, dealt damage, or enchanted by anything of the chosen color.) @@ -111899,7 +111899,7 @@ toughness=1 [/card] [card] name=Ward Sliver -alias=0000 +alias=1000 auto=chooseacolor transforms((,newability[lord(sliver) protection from(*[chosencolor])])) forever chooseend text=As Ward Sliver enters the battlefield, choose a color. -- All Slivers have protection from the chosen color. mana={4}{W} @@ -112493,7 +112493,7 @@ type=Artifact [/card] [card] name=Weapon Surge -alias=110000 +alias=11000 other={1}{R} name(Overload) target=creature|mybattlefield auto=paidmana 1/0 diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index fa8f59b63..f111efaf3 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -313,11 +313,11 @@ class MTGDredgeRule: public PermanentAbility, public ReplacementEffect public: //vectorsoulbonders; TargetChooser * tcb; - //MTGAbility * dredgeAbility; - //MTGAbility * targetAbility; - //MTGAbility * targetAbilityAdder; - //MTGAbility * targetAbility1; - //MTGAbility * mod; + MTGAbility * dredgeAbility; + MTGAbility * targetAbility; + MTGAbility * targetAbilityAdder; + MTGAbility * targetAbility1; + MTGAbility * mod; //MTGAbility * activateDredge; //vectorpairing; MTGDredgeRule(GameObserver* observer, int _id); diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index 84c294fe9..a2c237e6c 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -1834,10 +1834,6 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty { shouldPlayPercentage = 90; } - else if (!card->isLand() && card->has(Constants::PAYZERO)) - { - shouldPlayPercentage = 70; - } else { // shouldPlay == baka_effect_bad giving it a 1 for odd ball lottery chance. @@ -1986,10 +1982,6 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty { shouldPlayPercentage = 90; } - else if (!card->isLand() && card->has(Constants::PAYZERO)) - { - shouldPlayPercentage = 70; - } else { // shouldPlay == baka_effect_bad giving it a 1 for odd ball lottery chance. @@ -2137,10 +2129,6 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty { shouldPlayPercentage = 90; } - else if (!card->isLand() && card->has(Constants::PAYZERO)) - { - shouldPlayPercentage = 70; - } else { // shouldPlay == baka_effect_bad giving it a 1 for odd ball lottery chance. @@ -2447,7 +2435,7 @@ int AIPlayerBaka::computeActions() cd.SetExclusionColor(Constants::MTG_COLOR_LAND); MTGCardInstance *freecard = cd.match(game->graveyard); int canCastCard = game->playRestrictions->canPutIntoZone(freecard, game->inPlay); - if (freecard && (canCastCard == PlayRestriction::CAN_PLAY) && freecard->has(Constants::PAYZERO) && freecard->has(Constants::CANPLAYFROMGRAVEYARD) && (freecard->getIncreasedManaCost()->getConvertedCost() < 1) && (freecard->alias != 001100)) + if (freecard && (canCastCard == PlayRestriction::CAN_PLAY) && freecard->has(Constants::PAYZERO) && freecard->has(Constants::CANPLAYFROMGRAVEYARD) && (freecard->getIncreasedManaCost()->getConvertedCost() < 1) && (freecard->alias != 1111)) { MTGAbility * castFreeCard = observer->mLayers->actionLayer()->getAbility(MTGAbility::PAYZERO_COST); AIAction * aa = NEW AIAction(this, castFreeCard, freecard); //TODO putinplay action @@ -2462,7 +2450,7 @@ int AIPlayerBaka::computeActions() cd.SetExclusionColor(Constants::MTG_COLOR_LAND); MTGCardInstance *freecard = cd.match(game->exile); int canCastCard = game->playRestrictions->canPutIntoZone(freecard, game->inPlay); - if (freecard && (canCastCard == PlayRestriction::CAN_PLAY) && freecard->has(Constants::PAYZERO) && freecard->has(Constants::CANPLAYFROMEXILE) && (freecard->getIncreasedManaCost()->getConvertedCost() < 1) && (freecard->alias != 001100)) + if (freecard && (canCastCard == PlayRestriction::CAN_PLAY) && freecard->has(Constants::PAYZERO) && freecard->has(Constants::CANPLAYFROMEXILE) && (freecard->getIncreasedManaCost()->getConvertedCost() < 1) && (freecard->alias != 1111)) { MTGAbility * castFreeCard = observer->mLayers->actionLayer()->getAbility(MTGAbility::PAYZERO_COST); AIAction * aa = NEW AIAction(this, castFreeCard, freecard); //TODO putinplay action diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index 1049cd41b..4cdfecb12 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -348,7 +348,7 @@ void CardGui::Render() mFont->SetColor(ARGB(static_cast(actA),216,191,216));//thistle powered down else if(!card->wasDealtDamage && card->pbonus >= 3) mFont->SetColor(ARGB(static_cast(actA),255,255,0));//yellow buff - else if(card->hasType("legendary") && card->hasType("eldrazi")) + else if(card->hasType("legendary") && card->hasType("eldrazi") && !card->has(Constants::CHANGELING)) mFont->SetColor(ARGB(static_cast(actA),238,130,238));//violet legendary eldrazi else mFont->SetColor(ARGB(static_cast(actA),255,255,255));//white default @@ -365,9 +365,9 @@ void CardGui::Render() buff = "CT"; if(!card->isToken && card->isACopier) buff = "C"; - if(game && card->has(Constants::PAYZERO) && ((card->currentZone == card->controller()->game->hand) || (card->has(Constants::CANPLAYFROMGRAVEYARD) && card->currentZone == card->controller()->game->graveyard) || (card->has(Constants::CANPLAYFROMEXILE) && card->currentZone == card->controller()->game->exile))) + if(card->has(Constants::PAYZERO)) buff += "Z"; - if(card->alias == 0000) + if(card->alias == 1000) { if(card->chooseacolor == 1) buff += "\n-Green"; @@ -385,7 +385,7 @@ void CardGui::Render() mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); char buffer[200]; sprintf(buffer, "%s", buff.c_str()); - mFont->SetColor(ARGB(static_cast(actA),255,182,193));//Light Pink indicator + mFont->SetColor(ARGB(static_cast(actA),255,215,0));//Gold indicator mFont->SetScale(0.8f); mFont->DrawString(buffer, actX - 10 * actZ, actY - (16 * actZ)); mFont->SetScale(1); diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 16ffa9b41..7d14d4615 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -3092,7 +3092,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG { MTGAbility * a = NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true); a->forcedAlive = 1; - a->forceDestroy = -1; + //a->forceDestroy = -1; return a; //return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true); } diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index cfa757aa2..736c68e00 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -546,7 +546,7 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy copy->kicked = card->kicked; copy->storedCard = card->storedCard; copy->storedSourceCard = card->storedSourceCard; - for (int i = 0; i < ManaCost::MANA_PAID_WITH_BESTOW +1; i++) + for (int i = 0; i < ManaCost::MANA_PAID_WITH_OVERLOAD +1; i++) copy->alternateCostPaid[i] = card->alternateCostPaid[i]; //stupid bug with tokens... diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index eeb228e53..5972c999d 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -627,7 +627,7 @@ PermanentAbility(observer, _id) int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) { - if (card->alias == 110000) + if (card->alias == 11000) return 0;//overload has its own rule ManaCost * alternateCost = card->getManaCost()->getAlternative(); if (!game->currentlyActing()->game->hand->hasCard(card) && !game->currentlyActing()->game->graveyard->hasCard(card) && !game->currentlyActing()->game->exile->hasCard(card)) @@ -1165,6 +1165,8 @@ MTGAlternativeCostRule(observer, _id) int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) { + if(!card->has(Constants::PAYZERO)) + return 0; Player * player = game->currentlyActing(); ManaCost * cost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL)); if(card->getIncreasedManaCost()->getConvertedCost()) @@ -1174,8 +1176,6 @@ int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) if(card->isLand()) return 0; - if(!card->has(Constants::PAYZERO)) - return 0; if (!player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card)) return 0; if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card))) @@ -1225,7 +1225,7 @@ MTGAlternativeCostRule(observer, _id) int MTGOverloadRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) { - if (card->alias != 110000) + if (card->alias != 11000) return 0; Player * player = game->currentlyActing(); ManaCost * cost = NEW ManaCost(card->model->data->getManaCost()->getAlternative()); @@ -2255,9 +2255,9 @@ MTGDredgeRule::MTGDredgeRule(GameObserver* observer, int _id) : PermanentAbility(observer, _id) { tcb = NULL; - //dredgeAbility = NULL; - //targetAbility = NULL; - //mod = NULL; + dredgeAbility = NULL; + targetAbility = NULL; + mod = NULL; } ; @@ -2314,26 +2314,26 @@ WEvent * MTGDredgeRule::replace(WEvent * event) } //there is a memleak here that i have no idea what causes it. - dredgeCard *dc = NEW dredgeCard(game, game->mLayers->actionLayer()->getMaxId(), card,NULL); - dc->oneShot = true; - GenericTargetAbility *gta = NEW GenericTargetAbility(game, "Dredge A Card","",game->mLayers->actionLayer()->getMaxId(), card,tcb->clone(),dc->clone()); - gta->oneShot = true; - //SAFE_DELETE(dredgeAbility); + dredgeAbility = NEW dredgeCard(game, game->mLayers->actionLayer()->getMaxId(), card,NULL); + dredgeAbility->oneShot = true; + targetAbility = NEW GenericTargetAbility(game, "Dredge A Card","",game->mLayers->actionLayer()->getMaxId(), card,tcb->clone(),dredgeAbility->clone()); + targetAbility->oneShot = true; + SAFE_DELETE(dredgeAbility); - GenericAddToGame *gatg = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), card,NULL,gta->clone()); - gatg->oneShot = true; - //SAFE_DELETE(targetAbility); - //MTGAbility * setDredge = targetAbilityAdder->clone(); - //SAFE_DELETE(targetAbilityAdder); - //setDredge->oneShot = true; + targetAbilityAdder = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), card,NULL,targetAbility->clone()); + targetAbilityAdder->oneShot = true; + SAFE_DELETE(targetAbility); + MTGAbility * setDredge = targetAbilityAdder->clone(); + SAFE_DELETE(targetAbilityAdder); + setDredge->oneShot = true; - selection.push_back(gatg); - AADrawer *ad = NEW AADrawer(game, game->mLayers->actionLayer()->getMaxId(), card,card,NULL, "1",TargetChooser::CONTROLLER,true); - selection.push_back(ad); - MenuAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Dredge or Draw"); + selection.push_back(setDredge); + targetAbility1 = NEW AADrawer(game, this->GetId(), card,card,NULL, "1",TargetChooser::CONTROLLER,true); + selection.push_back(targetAbility1); + MTGAbility * menuChoice = NEW MenuAbility(game, this->GetId(), card, card,true,selection,card->controller(),"Dredge or Draw"); menuChoice->addToGame(); - //SAFE_DELETE(tcb); + SAFE_DELETE(tcb); } SAFE_DELETE(event); From 7a34543004e310342faade11befc4fac51715685 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 26 May 2016 09:42:17 +0800 Subject: [PATCH 16/22] Nasty memleak crashing devices and its fix. #664 thanks zethfox --- projects/mtg/src/GameObserver.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 0b1705378..0bbfd39d1 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -1157,6 +1157,11 @@ void GameObserver::Affinity() } } SAFE_DELETE(original); + + SAFE_DELETE(alternate); + SAFE_DELETE(buyback); + SAFE_DELETE(flashback); + SAFE_DELETE(retrace); }//end } } From 8a374f53bc24781b390cb4b2a9dd75210307726a Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 27 May 2016 10:59:31 +0800 Subject: [PATCH 17/22] Update appveyor.yml try to fix appveyor --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index b0a86032a..ea8ca42eb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,7 +22,7 @@ environment: # scripts that run after cloning repository install: - - ps: (new-object net.webclient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py', 'C:/get-pip.py') + - ps: (new-object net.webclient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', 'C:/get-pip.py') - "C:/Python27/python.exe C:/get-pip.py" - "C:/Python27/Scripts/pip.exe install pyjavaproperties" - "C:/Python27/Scripts/pip.exe install github3.py" From 18430dca25ff38c39455cc671a3a805d70a5d794 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 28 May 2016 13:47:03 +0800 Subject: [PATCH 18/22] Fix summoning sickness Cards like control magic (using alias=1194) always resets the summoning sickness, commenting this solves the problem... --- projects/mtg/src/MTGCardInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 6dfdb9add..d0504e207 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -573,7 +573,7 @@ MTGCardInstance * MTGCardInstance::changeController(Player * newController,bool } Player * originalOwner = controller(); MTGCardInstance * copy = originalOwner->game->putInZone(this, this->currentZone, newController->game->inPlay); - copy->summoningSickness = 1; + //copy->summoningSickness = 1; return copy; } From 95cec8874232c9f4df3b60d3da71b495ba67679b Mon Sep 17 00:00:00 2001 From: Xawotihs Date: Sat, 28 May 2016 19:13:45 +0200 Subject: [PATCH 19/22] Replaced Qt ppa --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9b360a1ba..3d8be06c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,9 @@ before_install: fi # Building for Qt here - if [ "$BUILD_Qt" == "YES" ]; then - sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa && +# sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa && + sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty universe" && + sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty main" && sudo apt-get update -qq && sudo apt-get install -qq qt5-qmake qtbase5-dev qtdeclarative5-dev qttools5-dev qtmultimedia5-dev pulseaudio libpulse-dev && export QMAKE="qmake -qt=qt5"; From d6ab2e15bf831bfb64c6af5a558ad907544c0424 Mon Sep 17 00:00:00 2001 From: Xawotihs Date: Sat, 28 May 2016 19:15:21 +0200 Subject: [PATCH 20/22] Removed comment --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3d8be06c0..68e575f56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,6 @@ before_install: fi # Building for Qt here - if [ "$BUILD_Qt" == "YES" ]; then -# sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa && sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty universe" && sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty main" && sudo apt-get update -qq && From 555cf9016f917b915eac2659f26228b29b5c63fd Mon Sep 17 00:00:00 2001 From: Xawotihs Date: Sat, 28 May 2016 19:47:33 +0200 Subject: [PATCH 21/22] Moved -qq options --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 68e575f56..f63cde744 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,8 @@ before_install: - if [ "$BUILD_Qt" == "YES" ]; then sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty universe" && sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty main" && - sudo apt-get update -qq && - sudo apt-get install -qq qt5-qmake qtbase5-dev qtdeclarative5-dev qttools5-dev qtmultimedia5-dev pulseaudio libpulse-dev && + sudo apt-get -qq update && + sudo apt-get -qq install qt5-qmake qtbase5-dev qtdeclarative5-dev qttools5-dev qtmultimedia5-dev pulseaudio libpulse-dev && export QMAKE="qmake -qt=qt5"; fi From e0cf5aa602daebbd71fa144a01b75044849217c8 Mon Sep 17 00:00:00 2001 From: Xawotihs Date: Sat, 28 May 2016 20:18:41 +0200 Subject: [PATCH 22/22] Reversed android and Qt apt stuff --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index f63cde744..00b5755cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,13 +16,6 @@ before_install: export PATH="$PATH:$PSPDEV/bin:$PSPSDK/bin" && wget -O sdk.lzma http://sourceforge.net/projects/minpspw/files/SDK%20%2B%20devpak/pspsdk%200.11.2/minpspw_0.11.2-amd64.tar.lzma/download; fi -# Building for Android here - - if [ "$BUILD_ANDROID" == "YES" ]; then - export ANDROID="android-sdk-linux/tools/android" && - if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch jq; fi && - wget http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2 -nv && - wget http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz -nv; - fi # Building for Qt here - if [ "$BUILD_Qt" == "YES" ]; then sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty universe" && @@ -31,7 +24,14 @@ before_install: sudo apt-get -qq install qt5-qmake qtbase5-dev qtdeclarative5-dev qttools5-dev qtmultimedia5-dev pulseaudio libpulse-dev && export QMAKE="qmake -qt=qt5"; fi - +# Building for Android here + - if [ "$BUILD_ANDROID" == "YES" ]; then + export ANDROID="android-sdk-linux/tools/android" && + if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch jq; fi && + wget http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2 -nv && + wget http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz -nv; + fi + install: - if [ "$BUILD_PSP" == "YES" ]; then tar -x --xz -f sdk.lzma;