diff --git a/projects/mtg/bin/Res/sets/primitives/borderline.txt b/projects/mtg/bin/Res/sets/primitives/borderline.txt index c90eeef70..6e37b9424 100644 --- a/projects/mtg/bin/Res/sets/primitives/borderline.txt +++ b/projects/mtg/bin/Res/sets/primitives/borderline.txt @@ -1,7 +1,7 @@ grade=borderline #Bordeline Primitives Pack for Wagic the Homebrew. #Please keep these card alphabetized, and try to have the "name=" line at the top of each card -#I sorted this programmatically - Thanks to Vitty85 20-05-2023 +#I sorted this programmatically - Thanks to Vitty85 21-05-2023 [card] name=+2 Mace auto={3}:equip @@ -8584,24 +8584,27 @@ toughness=4 [card] name=Bloated Processor auto={S(other *[phyrexian]|mybattlefield)}:name(Put 1/1 counter) counter(1/1) -auto=_DIES_this(counter{1/1}=0) transforms((,newability[name(Incubate 3) name(Incubate 3) activate castcard(noevent costx!:3:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=1) transforms((,newability[name(Incubate 4) name(Incubate 4) activate castcard(noevent costx!:4:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=2) transforms((,newability[name(Incubate 5) name(Incubate 5) activate castcard(noevent costx!:5:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=3) transforms((,newability[name(Incubate 6) name(Incubate 6) activate castcard(noevent costx!:6:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=4) transforms((,newability[name(Incubate 7) name(Incubate 7) activate castcard(noevent costx!:7:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=5) transforms((,newability[name(Incubate 8) name(Incubate 8) activate castcard(noevent costx!:8:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=6) transforms((,newability[name(Incubate 9) name(Incubate 9) activate castcard(noevent costx!:9:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=7) transforms((,newability[name(Incubate 10) name(Incubate 10) activate castcard(noevent costx!:10:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=8) transforms((,newability[name(Incubate 11) name(Incubate 11) activate castcard(noevent costx!:11:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=9) transforms((,newability[name(Incubate 12) name(Incubate 12) activate castcard(noevent costx!:12:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=10) transforms((,newability[name(Incubate 13) name(Incubate 13) activate castcard(noevent costx!:13:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=11) transforms((,newability[name(Incubate 14) name(Incubate 14) activate castcard(noevent costx!:14:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=12) transforms((,newability[name(Incubate 15) name(Incubate 15) activate castcard(noevent costx!:15:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=13) transforms((,newability[name(Incubate 16) name(Incubate 16) activate castcard(noevent costx!:16:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=14) transforms((,newability[name(Incubate 17) name(Incubate 17) activate castcard(noevent costx!:17:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=15) transforms((,newability[name(Incubate 18) name(Incubate 18) activate castcard(noevent costx!:18:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}=16) transforms((,newability[name(Incubate 19) name(Incubate 19) activate castcard(noevent costx!:19:! named!:Incubator:!)])) oneshot -auto=_DIES_this(counter{1/1}>=17) transforms((,newability[name(Incubate 20) name(Incubate 20) activate castcard(noevent costx!:20:! named!:Incubator:!)])) oneshot +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~0}:name(Incubate 0) name(Incubate 0) activate castcard(noevent costx!:0:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~1}:name(Incubate 1) name(Incubate 1) activate castcard(noevent costx!:1:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~2}:name(Incubate 2) name(Incubate 2) activate castcard(noevent costx!:2:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~3}:name(Incubate 3) name(Incubate 3) activate castcard(noevent costx!:3:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~4}:name(Incubate 4) name(Incubate 4) activate castcard(noevent costx!:4:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~5}:name(Incubate 5) name(Incubate 5) activate castcard(noevent costx!:5:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~6}:name(Incubate 6) name(Incubate 6) activate castcard(noevent costx!:6:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~7}:name(Incubate 7) name(Incubate 7) activate castcard(noevent costx!:7:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~8}:name(Incubate 8) name(Incubate 8) activate castcard(noevent costx!:8:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~9}:name(Incubate 9) name(Incubate 9) activate castcard(noevent costx!:9:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~10}:name(Incubate 10) name(Incubate 10) activate castcard(noevent costx!:10:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~11}:name(Incubate 11) name(Incubate 11) activate castcard(noevent costx!:11:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~12}:name(Incubate 12) name(Incubate 12) activate castcard(noevent costx!:12:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~13}:name(Incubate 13) name(Incubate 13) activate castcard(noevent costx!:13:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~14}:name(Incubate 14) name(Incubate 14) activate castcard(noevent costx!:14:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~15}:name(Incubate 15) name(Incubate 15) activate castcard(noevent costx!:15:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~16}:name(Incubate 16) name(Incubate 16) activate castcard(noevent costx!:16:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~17}:name(Incubate 17) name(Incubate 17) activate castcard(noevent costx!:17:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~18}:name(Incubate 18) name(Incubate 18) activate castcard(noevent costx!:18:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~equalto~19}:name(Incubate 19) name(Incubate 19) activate castcard(noevent costx!:19:! named!:Incubator:!) +auto=@movedto(this|graveyard) from(battlefield) restriction{compare(power)~morethan~19}:name(Incubate 20) name(Incubate 20) activate castcard(noevent costx!:20:! named!:Incubator:!) text=Sacrifice another Phyrexian: Put a +1/+1 counter on Bloated Processor. -- When Bloated Processor dies, incubate X, where X is its power. (Create an Incubator token with X +1/+1 counters on it and "{2}: Transform this artifact." It transforms into a 0/0 Phyrexian artifact creature.) mana={2}{B} type=Creature @@ -16559,7 +16562,7 @@ toughness=2 [/card] [card] name=Conclave Mentor -auto=@counteradded(1/1) from(creature|mybattlefield) except(Conclave Mentor):may counter(1/1) target(creature[counter{1/1.1}]|myBattlefield) +auto=@totalcounteradded(1/1) from(creature|mybattlefield) plus(1):ability$!name(That many plus 1) donothing!$ controller auto=_DIES_life:power controller text=If one or more +1/+1 counters would be put on a creature you control, that many plus one +1/+1 counters are put on that creature instead. -- When Conclave Mentor dies, you gain life equal to its power. mana={G}{W} @@ -17106,6 +17109,17 @@ power=1 toughness=3 [/card] [card] +name=Coppercoat Vanguard +auto=lord(other *[human]|myBattlefield) 1/0 +auto=@targeted(other *[human]|myBattlefield) from(*|opponentzones):choice name(This spell costs 1 more) name(This spell costs 1 more) target(*|opponentzones) transforms((,newability[pay[[{1}]] name(pay 1 mana) donothing?fizzle])) oneshot +text=Each other Human you control gets +1/+0 and has ward {1}. (Whenever it becomes the target of a spell or ability an opponent controls, counter it unless that player pays {1}.) +mana={1}{W} +type=Creature +subtype=Human Soldier +power=2 +toughness=2 +[/card] +[card] name=Copy Enchantment auto=may copy target(enchantment|battlefield) text=You may have Copy Enchantment enter the battlefield as a copy of any enchantment on the battlefield. @@ -30093,6 +30107,13 @@ power=1 toughness=1 [/card] [card] +name=Filter Out +auto=all(*[-creature&-land]|battlefield) moveTo(ownerHand) +text=Return all noncreature, nonland permanents to their owners' hands. +mana={1}{U}{U} +type=Instant +[/card] +[card] name=Fin-Clade Fugitives auto=cantbeblockedby(creature[power<=2]) autograveyard={4}{G}:name(Activate Encore) name(Activate Encore) moveto(exile) and!(clone with(treason,haste,mustattack))! asSorcery @@ -38838,7 +38859,7 @@ toughness=2 [/card] [card] name=Hardened Scales -auto=@counteradded(1/1) from(creature|mybattlefield) except(Hardened Scales):may counter(1/1) target(creature[counter{1/1.1}]|myBattlefield) +auto=@totalcounteradded(1/1) from(creature|mybattlefield) plus(1):ability$!name(That many plus 1) donothing!$ controller text=If one or more +1/+1 counters would be placed on a creature you control, that many plus one +1/+1 counters are placed on it instead. mana={G} type=Enchantment @@ -46833,8 +46854,7 @@ auto={T}:name(Add white mana) thisforeach(variable{power}>0) add{W} auto={T}:name(Add blue mana) thisforeach(variable{power}>0) add{U} auto={T}:name(Add black mana) thisforeach(variable{power}>0) add{B} auto={T}:name(Add green mana) thisforeach(variable{power}>0) add{G} -auto=@counteradded(1/1) from(*|myBattlefield) except(Kami of Whispered Hopes):may name(Add counter) all(trigger[from]) counter(1/1) -auto=@counteradded(1/1) from(this):may name(Add counter) all(trigger[from]) counter(1/1) +auto=@totalcounteradded(1/1) from(*|mybattlefield) plus(1):ability$!name(That many plus 1) donothing!$ controller text=If one or more +1/+1 counters would be put on a permanent you control, that many plus one +1/+1 counters are put on that permanent instead. -- {T}: Add X mana of any one color, where X is Kami of Whispered Hopes's power. mana={2}{G} type=Creature @@ -56739,7 +56759,7 @@ type=Sorcery [card] name=Mowu, Loyal Companion abilities=vigilance,trample -auto=@counteradded(1/1) from(this) except(Mowu, Loyal Companion):may counter(1/1) +auto=@totalcounteradded(1/1) from(this) plus(1):ability$!name(That many plus 1) donothing!$ controller text=Trample, vigilance -- If one or more +1/+1 counters would be put on Mowu, Loyal Companion, that many plus one +1/+1 counters are put on it instead. mana={3}{G} type=Legendary Creature @@ -62039,8 +62059,7 @@ abilities=cycling autohand=__CYCLING__({2}) auto={1}{G}{T}:name(Put 1/1 counter on other target) counter(1/1,2) target(other *[artifact;creature]|myBattlefield) asSorcery auto={1}{G}{T}:name(Put 1/1 counter on this artifact) counter(1/1) asSorcery -auto=@counteradded(1/1) from(*[creature;artifact]|myBattlefield) except(Ozolith, the Shattered Spire):may name(Add counter) all(trigger[from]) counter(1/1) -auto=@counteradded(1/1) from(this):may name(Add counter) all(trigger[from]) counter(1/1) +auto=@totalcounteradded(1/1) from(*[creature;artifact]|mybattlefield) plus(1):ability$!name(That many plus 1) donothing!$ controller text=If one or more +1/+1 counters would be put on an artifact or creature you control, that many plus one +1/+1 counters are put on it instead. -- {1}{G}, {T}: Put a +1/+1 counter on target artifact or creature you control. Activate only as a sorcery. -- Cycling {2} ({2}, Discard this card: Draw a card.) mana={1}{G} type=Legendary Artifact @@ -81312,6 +81331,15 @@ power=2 toughness=3 [/card] [card] +name=Spark Rupture +auto=draw:1 controller +auto=lord(planeswalker[counter{0/0.1.Loyatly}]|battlefield) loseabilities +auto=lord(planeswalker[counter{0/0.1.Loyatly}]|battlefield) transforms((Creature,setpower=hascntloyalty,settoughness=hascntloyalty)) +text=When Spark Rupture enters the battlefield, draw a card. -- Each planeswalker with one or more loyalty counters on it loses all abilities and is a creature with power and toughness each equal to the number of loyalty counters on it. +mana={2}{W} +type=Enchantment +[/card] +[card] name=Sparkhunter Masticore auto=protection from(planeswalker) auto={1}:damage:1 target(planeswalker) @@ -98417,6 +98445,19 @@ mana={3}{B}{G} type=Instant [/card] [card] +name=Winding Constrictor +auto=@totalcounteradded(any) from(*[creature;artifact]|mybattlefield) plus(1):ability$!name(That many plus 1) donothing!$ controller +auto=@energizedof(player) plus(1):ability$!name(That many plus 1) donothing!$ controller +auto=@poisonedof(player) plus(1):ability$!name(That many plus 1) donothing!$ controller +auto=@experiencedof(player) plus(1):ability$!name(That many plus 1) donothing!$ controller +text=If one or more counters would be placed on an artifact or creature you control, that many plus one of each of those kinds of counters are placed on that permanent instead. -- If you would get one or more counters, you get that many plus one of each of those kinds of counters instead. +mana={B}{G} +type=Creature +subtype=Snake +power=2 +toughness=3 +[/card] +[card] name=Winding Way auto=choice name(Creature) reveal:4 optionone name(Get Creature) target(creature|reveal) moveto(myhand) and!( all(creature|reveal) moveto(myhand) )! optiononeend optiontwo name(put in grave) target(<1>*|reveal) moveto(mygraveyard) and!( all(*|reveal) moveto(mygraveyard) )! optiontwoend revealend auto=choice name(Land) reveal:4 optionone name(Get Land) target(land|reveal) moveto(myhand) and!( all(land|reveal) moveto(myhand) )! optiononeend optiontwo name(put in grave) target(<1>*|reveal) moveto(mygraveyard) and!( all(*|reveal) moveto(mygraveyard) )! optiontwoend revealend @@ -100127,7 +100168,7 @@ modular=1 auto=_DIES_may thisforeach(counter{1/1.1}) counter(1/1) target(creature[artifact]) auto={R}:name(Destroy artifact) target(artifact|myBattlefield) auto={W}:name(Gains flying) transforms((,newability[flying])) ueot -auto=@counteradded(1/1) from(*[modular]|myBattlefield) except(Zabaz, the Glimmerwasp):may name(Trigger modular) counter(1/1) target(creature[counter{1/1.1}]|myBattlefield) +auto=@totalcounteradded(1/1) from(*[modular]|mybattlefield) plus(1):ability$!name(That many plus 1) donothing!$ controller text=Modular 1 -- If a modular triggered ability would put one or more +1/+1 counters on a creature you control, that many plus one +1/+1 counters are put on it instead. -- {R}: Destroy target artifact you control. -- {W}: Zabaz, the Glimmerwasp gains flying until end of turn. mana={1} type=Legendary Artifact Creature diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index b642ba755..a97e72c9f 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -1,6 +1,6 @@ #Primitives Pack for Wagic the Homebrew. #Please keep these card alphabetized, and try to have the "name=" line at the top of each card -#I sorted this programatically so the other comments are removed except for AUTO_DEFINE - Vitty85 20-05-2023 +#I sorted this programatically so the other comments are removed except for AUTO_DEFINE - Vitty85 21-05-2023 [card] name=Abandon Reason target=creature @@ -59808,7 +59808,7 @@ toughness=2 [/card] [card] name=Jaddi Lifestrider -auto=tap target(creature[-tapped]|mybattlefield) && life:2 +auto=may name(Tap creatures) target(creature[-tapped]|mybattlefield) tap && life:2 controller text=tap any amount of creatures and gain 2 life for each creature tapped this way mana={4}{G} type=Creature diff --git a/projects/mtg/bin/Res/sets/primitives/unsupported.txt b/projects/mtg/bin/Res/sets/primitives/unsupported.txt index ac8fd85dc..47f951d79 100644 --- a/projects/mtg/bin/Res/sets/primitives/unsupported.txt +++ b/projects/mtg/bin/Res/sets/primitives/unsupported.txt @@ -12000,15 +12000,6 @@ power=1 toughness=2 [/card] [card] -name=Winding Constrictor -text=If one or more counters would be placed on an artifact or creature you control, that many plus one of each of those kinds of counters are placed on that permanent instead. -- If you would get one or more counters, you get that many plus one of each of those kinds of counters instead. -mana={B}{G} -type=Creature -subtype=Snake -power=2 -toughness=3 -[/card] -[card] name=Windriddle Palaces text=Players play with the top card of their libraries revealed. -- You may play the top card of any player's library. -- Whenever you roll {K}, each player puts the top card of his or her library into his or her graveyard. type=Plane diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 6e453a6c0..8e31178e8 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -495,8 +495,9 @@ class TrplayerPoisoned: public Trigger { public: bool thiscontroller, thisopponent; - TrplayerPoisoned(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) + int plus; + TrplayerPoisoned(GameObserver* observer, int id, MTGCardInstance * source, TargetChooser * tc, bool once = false, bool thiscontroller = false, bool thisopponent = false, int plus = 0) : + Trigger(observer, id, source, once, tc),thiscontroller(thiscontroller),thisopponent(thisopponent),plus(plus) { } @@ -511,6 +512,8 @@ public: if(thisopponent) if(e->player == source->controller()) return 0; + if(plus > 0) + e->player->poisonCount++; return 1; } @@ -524,8 +527,9 @@ class TrplayerEnergized: public Trigger { public: bool thiscontroller, thisopponent; - TrplayerEnergized(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) + int plus; + TrplayerEnergized(GameObserver* observer, int id, MTGCardInstance * source, TargetChooser * tc, bool once = false, bool thiscontroller = false, bool thisopponent = false, int plus = 0) : + Trigger(observer, id, source, once, tc),thiscontroller(thiscontroller),thisopponent(thisopponent),plus(plus) { } @@ -540,6 +544,8 @@ public: if(thisopponent) if(e->player == source->controller()) return 0; + if(plus > 0) + e->player->energyCount++; return 1; } @@ -553,8 +559,9 @@ class TrplayerExperienced: public Trigger { public: bool thiscontroller, thisopponent; - TrplayerExperienced(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) + int plus; + TrplayerExperienced(GameObserver* observer, int id, MTGCardInstance * source, TargetChooser * tc, bool once = false, bool thiscontroller = false, bool thisopponent = false, int plus = 0) : + Trigger(observer, id, source, once, tc),thiscontroller(thiscontroller),thisopponent(thisopponent),plus(plus) { } @@ -569,6 +576,8 @@ public: if(thisopponent) if(e->player == source->controller()) return 0; + if(plus > 0) + e->player->experienceCount++; return 1; } @@ -1430,6 +1439,70 @@ public: } }; +//counter trigger +class TrTotalCounter: public Trigger +{ +public: + Counter * counter; + int type; + bool duplicate; + int plus; + bool limitOnceATurn; + int triggeredTurn; + MTGCardInstance * counterException; //added exception to avid a counter loop (eg. Doubling Season) + TrTotalCounter(GameObserver* observer, int id, MTGCardInstance * source, Counter * counter, TargetChooser * tc, int type = 0, bool once = false, bool duplicate = false, int plus = 0, bool limitOnceATurn = false, MTGCardInstance * counterException = NULL) : + Trigger(observer, id, source, once, tc), counter(counter), type(type), duplicate(duplicate), plus(plus), limitOnceATurn(limitOnceATurn), counterException(counterException) + { + triggeredTurn = -1; + } + + int triggerOnEventImpl(WEvent * event) + { + WEventTotalCounters * e = dynamic_cast (event); + if (!e) return 0; + if (limitOnceATurn && triggeredTurn == game->turn) + return 0; + if (type == 0 && !e->removed) return 0; + if (type == 1 && !e->added) return 0; + if (counterException && e->source && !strcmp(counterException->data->name.c_str(), e->source->data->name.c_str())) return 0; //If the source of counter gain/loss it's the exception card it doesn't have effect (loop avoidance); + if (counter && !(e->power == counter->power && e->toughness == counter->toughness && e->name == counter->name)) return 0; + if (tc && !tc->canTarget(e->targetCard)) return 0; + if (plus > 0){ + if(type == 1){ + for(int i = 0; i < plus; i++) + e->targetCard->counters->addCounter(e->name.c_str(),e->power,e->toughness,true,true,e->source); + } + else { + for(int i = 0; i < plus; i++) + e->targetCard->counters->removeCounter(e->name.c_str(),e->power,e->toughness,true,true,e->source); + } + } + else if (duplicate){ + if(type == 1) { + for(int i = 0; i < e->totalamount; i++) + e->targetCard->counters->addCounter(e->name.c_str(),e->power,e->toughness,true,true,e->source); + } else { + for(int i = 0; i < e->totalamount; i++) + e->targetCard->counters->removeCounter(e->name.c_str(),e->power,e->toughness,true,true,e->source); + } + } + triggeredTurn = game->turn; + return 1; + } + + ~TrTotalCounter() + { + SAFE_DELETE(counter); + } + + TrTotalCounter * clone() const + { + TrTotalCounter * mClone = NEW TrTotalCounter(*this); + mClone->counter = NEW Counter(*this->counter); + return mClone; + } +}; + //Tutorial Messaging class ATutorialMessage: public MTGAbility, public IconButtonsController { diff --git a/projects/mtg/include/WEvent.h b/projects/mtg/include/WEvent.h index b123fc93d..c12fcb2b6 100644 --- a/projects/mtg/include/WEvent.h +++ b/projects/mtg/include/WEvent.h @@ -69,6 +69,21 @@ struct WEventCounters : public WEvent { virtual Targetable * getTarget(int target); }; +struct WEventTotalCounters : public WEvent { + MTGCardInstance * targetCard; + Counters * counter; + string name; + int power; + int toughness; + bool added; + bool removed; + int totalamount; + MTGCardInstance * source; + WEventTotalCounters(Counters *counter,string name,int power, int toughness,bool added = false, bool removed = false, int totalamount = 0, MTGCardInstance * source = NULL); + using WEvent::getTarget; + virtual Targetable * getTarget(int target); +}; + struct WEventLife : public WEvent { Player * player; int amount; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 0f6705f6e..100b3975a 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2599,6 +2599,7 @@ AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, M nb = checkcounter->nb; delete checkcounter; } + int totalcounters = 0; if (nb > 0) { if(_target->has(Constants::COUNTERSHROUD)) // Added to avoid the counter increasement (e.g. "Solemnity"). @@ -2631,8 +2632,15 @@ AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, M if(!maxNb || (maxNb && currentAmount < maxNb)) { _target->counters->addCounter(name.c_str(), power, toughness, noevent, false, source); + totalcounters++; } } + if (!noevent) + { + WEvent * w = NEW WEventTotalCounters(_target->counters, name.c_str(), power, toughness, true, false, totalcounters, source); + dynamic_cast(w)->targetCard = _target->counters->target; + _target->getObserver()->receiveEvent(w); + } } else { @@ -2641,6 +2649,13 @@ AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, M while (_target->next) _target = _target->next; _target->counters->removeCounter(name.c_str(), power, toughness, noevent, false, source); + totalcounters++; + } + if (!noevent) + { + WEvent * e = NEW WEventTotalCounters(_target->counters, name.c_str(), power, toughness, false, true, totalcounters, source); + dynamic_cast(e)->targetCard = _target->counters->target; + _target->getObserver()->receiveEvent(e); } } @@ -4535,6 +4550,7 @@ int AANewTarget::resolve() source->types[0] = 7; source->types[1] = 1; } + source->mPropertiesChangedSinceLastUpdate = false; if(source->hasType(Subtypes::TYPE_LEGENDARY)){ // Check if the mutated card is a duplicated legendary card MTGNewLegend *testlegend = NEW MTGNewLegend(source->getObserver(),source->getObserver()->mLayers->actionLayer()->getMaxId()); testlegend->CheckLegend(source); @@ -4825,7 +4841,6 @@ int AATurnSide::resolve() _target->magicText = sideCard->magicText; _target->colors = sideCard->colors; _target->isFlipped = (_target->isFlipped > 0)?0:1; - _target->mPropertiesChangedSinceLastUpdate = true; SAFE_DELETE(sideCard); return 1; } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 3c4bc376c..e7433cd99 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -274,7 +274,11 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe int Turn = 0; size_t start = restriction[i].find(":", check); size_t end = restriction[i].find(" ", check); - Turn = atoi(restriction[i].substr(start + 1, end - start - 1).c_str()); + WParsedInt* parser = NEW WParsedInt(restriction[i].substr(start + 1, end - start - 1), card); + if(parser){ + Turn = parser->intValue; + SAFE_DELETE(parser); + } if(observer->turn < Turn-1) return 0; } @@ -1343,28 +1347,100 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell } //poisoned player - controller of card - if (TargetChooser * tc = parseSimpleTC(s, "poisonedof", card)) - return NEW TrplayerPoisoned(observer, id, card, tc, once, true, false); + if (TargetChooser * tc = parseSimpleTC(s, "poisonedof", card)){ + int plus = 0; + if(s.find("plus(1)") != string::npos) + plus = 1; + else if(s.find("plus(2)") != string::npos) + plus = 2; + else if(s.find("plus(3)") != string::npos) + plus = 3; + else if(s.find("plus(4)") != string::npos) + plus = 4; + else if(s.find("plus(5)") != string::npos) + plus = 5; + return NEW TrplayerPoisoned(observer, id, card, tc, once, true, false, plus); + } //poisoned player - opponent of card controller - if (TargetChooser * tc = parseSimpleTC(s, "poisonedfoeof", card)) - return NEW TrplayerPoisoned(observer, id, card, tc, once, false, true); + if (TargetChooser * tc = parseSimpleTC(s, "poisonedfoeof", card)){ + int plus = 0; + if(s.find("plus(1)") != string::npos) + plus = 1; + else if(s.find("plus(2)") != string::npos) + plus = 2; + else if(s.find("plus(3)") != string::npos) + plus = 3; + else if(s.find("plus(4)") != string::npos) + plus = 4; + else if(s.find("plus(5)") != string::npos) + plus = 5; + return NEW TrplayerPoisoned(observer, id, card, tc, once, false, true, plus); + } //energized player - controller of card - if (TargetChooser * tc = parseSimpleTC(s, "energizedof", card)) - return NEW TrplayerEnergized(observer, id, card, tc, once, true, false); + if (TargetChooser * tc = parseSimpleTC(s, "energizedof", card)){ + int plus = 0; + if(s.find("plus(1)") != string::npos) + plus = 1; + else if(s.find("plus(2)") != string::npos) + plus = 2; + else if(s.find("plus(3)") != string::npos) + plus = 3; + else if(s.find("plus(4)") != string::npos) + plus = 4; + else if(s.find("plus(5)") != string::npos) + plus = 5; + return NEW TrplayerEnergized(observer, id, card, tc, once, true, false, plus); + } //energized player - opponent of card controller - if (TargetChooser * tc = parseSimpleTC(s, "energizedfoeof", card)) - return NEW TrplayerEnergized(observer, id, card, tc, once, false, true); + if (TargetChooser * tc = parseSimpleTC(s, "energizedfoeof", card)){ + int plus = 0; + if(s.find("plus(1)") != string::npos) + plus = 1; + else if(s.find("plus(2)") != string::npos) + plus = 2; + else if(s.find("plus(3)") != string::npos) + plus = 3; + else if(s.find("plus(4)") != string::npos) + plus = 4; + else if(s.find("plus(5)") != string::npos) + plus = 5; + return NEW TrplayerEnergized(observer, id, card, tc, once, false, true, plus); + } //experienced player - controller of card - if (TargetChooser * tc = parseSimpleTC(s, "experiencedof", card)) - return NEW TrplayerExperienced(observer, id, card, tc, once, true, false); + if (TargetChooser * tc = parseSimpleTC(s, "experiencedof", card)){ + int plus = 0; + if(s.find("plus(1)") != string::npos) + plus = 1; + else if(s.find("plus(2)") != string::npos) + plus = 2; + else if(s.find("plus(3)") != string::npos) + plus = 3; + else if(s.find("plus(4)") != string::npos) + plus = 4; + else if(s.find("plus(5)") != string::npos) + plus = 5; + return NEW TrplayerExperienced(observer, id, card, tc, once, true, false, plus); + } //experienced player - opponent of card controller - if (TargetChooser * tc = parseSimpleTC(s, "experiencedfoeof", card)) - return NEW TrplayerExperienced(observer, id, card, tc, once, false, true); + if (TargetChooser * tc = parseSimpleTC(s, "experiencedfoeof", card)){ + int plus = 0; + if(s.find("plus(1)") != string::npos) + plus = 1; + else if(s.find("plus(2)") != string::npos) + plus = 2; + else if(s.find("plus(3)") != string::npos) + plus = 3; + else if(s.find("plus(4)") != string::npos) + plus = 4; + else if(s.find("plus(5)") != string::npos) + plus = 5; + return NEW TrplayerExperienced(observer, id, card, tc, once, false, true, plus); + } //becomes monarch - controller of card if (TargetChooser * tc = parseSimpleTC(s, "becomesmonarchof", card)) @@ -1658,6 +1734,62 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell return NEW TrTargeted(observer, id, card, tc, fromTc, 0, once, limitOnceATurn); } + if (s.find("totalcounteradded(") != string::npos) + { + vectorsplitCounter = parseBetween(s,"totalcounteradded(",")"); + Counter * counter = NULL; + bool duplicate = false; + int plus = 0; + if(s.find("plus(1)") != string::npos) + plus = 1; + else if(s.find("plus(2)") != string::npos) + plus = 2; + else if(s.find("plus(3)") != string::npos) + plus = 3; + else if(s.find("plus(4)") != string::npos) + plus = 4; + else if(s.find("plus(5)") != string::npos) + plus = 5; + else if(s.find("(duplicateall)") != string::npos) + duplicate = true; + else if(s.find("(any)") == string::npos) + counter = parseCounter(splitCounter[1],card,NULL); + TargetChooser * tc = parseSimpleTC(s, "from", card); + TargetChooser *exception = parseSimpleTC(s, "except", card); // Added a new keyword except to specify a counter add/remove exception in order to avoid counter loop (eg. Doubling Season) + if(exception) + return NEW TrTotalCounter(observer, id, card, counter, tc, 1, once, duplicate, plus, limitOnceATurn, exception->source); + else + return NEW TrTotalCounter(observer, id, card, counter, tc, 1, once, duplicate, plus, limitOnceATurn); + } + + if (s.find("totalcounterremoved(") != string::npos) + { + vectorsplitCounter = parseBetween(s,"totalcounterremoved(",")"); + Counter * counter = NULL; + bool duplicate = false; + int plus = 0; + if(s.find("plus(1)") != string::npos) + plus = 1; + else if(s.find("plus(2)") != string::npos) + plus = 2; + else if(s.find("plus(3)") != string::npos) + plus = 3; + else if(s.find("plus(4)") != string::npos) + plus = 4; + else if(s.find("plus(5)") != string::npos) + plus = 5; + else if(s.find("(duplicateall)") != string::npos) + duplicate = true; + else if(s.find("(any)") == string::npos) + counter = parseCounter(splitCounter[1],card,NULL); + TargetChooser * tc = parseSimpleTC(s, "from", card); + TargetChooser *exception = parseSimpleTC(s, "except", card); // Added a new keyword except to specify a counter add/remove exception in order to avoid counter loop (eg. Doubling Season) + if(exception) + return NEW TrTotalCounter(observer, id, card, counter, tc, 0, once, duplicate, plus, limitOnceATurn, exception->source); + else + return NEW TrTotalCounter(observer, id, card, counter, tc, 0, once, duplicate, plus, limitOnceATurn); + } + if (s.find("counteradded(") != string::npos) { vectorsplitCounter = parseBetween(s,"counteradded(",")"); @@ -3491,8 +3623,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitPlaceFromTop = parseBetween(s, "placefromthetop(", ")"); if (splitPlaceFromTop.size()) { + int position = 0; WParsedInt* parser = NEW WParsedInt(splitPlaceFromTop[1], card); - int position = parser->intValue; + if(parser){ + position = parser->intValue; + SAFE_DELETE(parser); + } MTGAbility * a = NEW AALibraryPosition(observer, id, card, target, NULL, position); a->oneShot = 1; //andability @@ -3967,7 +4103,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitPoison = parseBetween(s, "alterpoison:", " ", false); if (splitPoison.size()) { - int poison = atoi(splitPoison[1].c_str()); + int poison = 0; + WParsedInt* parser = NEW WParsedInt(splitPoison[1], card); + if(parser){ + poison = parser->intValue; + SAFE_DELETE(parser); + } Targetable * t = spell ? spell->getNextTarget() : NULL; MTGAbility * a = NEW AAAlterPoison(observer, id, card, t, poison, NULL, who); a->oneShot = 1; @@ -3978,7 +4119,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitEnergy = parseBetween(s, "alterenergy:", " ", false); if (splitEnergy.size()) { - int energy = atoi(splitEnergy[1].c_str()); + int energy = 0; + WParsedInt* parser = NEW WParsedInt(splitEnergy[1], card); + if(parser){ + energy = parser->intValue; + SAFE_DELETE(parser); + } Targetable * t = spell ? spell->getNextTarget() : NULL; MTGAbility * a = NEW AAAlterEnergy(observer, id, card, t, energy, NULL, who); a->oneShot = 1; @@ -3989,7 +4135,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitExperience = parseBetween(s, "alterexperience:", " ", false); if (splitExperience.size()) { - int exp = atoi(splitExperience[1].c_str()); + int exp = 0; + WParsedInt* parser = NEW WParsedInt(splitExperience[1], card); + if(parser){ + exp = parser->intValue; + SAFE_DELETE(parser); + } Targetable * t = spell ? spell->getNextTarget() : NULL; MTGAbility * a = NEW AAAlterExperience(observer, id, card, t, exp, NULL, who); a->oneShot = 1; @@ -4000,7 +4151,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitDungeonCompleted = parseBetween(s, "completedungeon:", " ", false); if (splitDungeonCompleted.size()) { - int dungeoncompleted = atoi(splitDungeonCompleted[1].c_str()); + int dungeoncompleted = 0; + WParsedInt* parser = NEW WParsedInt(splitDungeonCompleted[1], card); + if(parser){ + dungeoncompleted = parser->intValue; + SAFE_DELETE(parser); + } Targetable * t = spell ? spell->getNextTarget() : NULL; MTGAbility * a = NEW AAAlterDungeonCompleted(observer, id, card, t, dungeoncompleted, NULL, who); a->oneShot = 1; @@ -4011,7 +4167,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitYidaroCounter = parseBetween(s, "alteryidarocount:", " ", false); if (splitYidaroCounter.size()) { - int yidarocount = atoi(splitYidaroCounter[1].c_str()); + int yidarocount = 0; + WParsedInt* parser = NEW WParsedInt(splitYidaroCounter[1], card); + if(parser){ + yidarocount = parser->intValue; + SAFE_DELETE(parser); + } Targetable * t = spell ? spell->getNextTarget() : NULL; MTGAbility * a = NEW AAAlterYidaroCount(observer, id, card, t, yidarocount, NULL, who); a->oneShot = 1; @@ -4042,7 +4203,11 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitMutated = parseBetween(s, "altermutationcounter:", " ", false); if (splitMutated.size()) { - card->mutation += atoi(splitMutated[1].c_str()); + WParsedInt* parser = NEW WParsedInt(splitMutated[1], card); + if(parser){ + card->mutation += parser->intValue; + SAFE_DELETE(parser); + } WEvent * e = NEW WEventCardMutated(card); card->getObserver()->receiveEvent(e); } @@ -4051,12 +4216,20 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitMutatedOver = parseBetween(s, "mutationover:", " ", false); if (splitMutatedOver.size()) { - card->mutation += atoi(splitMutatedOver[1].c_str()); + WParsedInt* parser = NEW WParsedInt(splitMutated[1], card); + if(parser){ + card->mutation += parser->intValue; + SAFE_DELETE(parser); + } } vector splitMutatedUnder = parseBetween(s, "mutationunder:", " ", false); if (splitMutatedUnder.size()) { - card->mutation += atoi(splitMutatedUnder[1].c_str()); + WParsedInt* parser = NEW WParsedInt(splitMutated[1], card); + if(parser){ + card->mutation += parser->intValue; + SAFE_DELETE(parser); + } } //perform boast @@ -4093,7 +4266,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitSurveilOffset = parseBetween(s, "altersurvoffset:", " ", false); if (splitSurveilOffset.size()) { - int surveilOffset = atoi(splitSurveilOffset[1].c_str()); + int surveilOffset = 0; + WParsedInt* parser = NEW WParsedInt(splitSurveilOffset[1], card); + if(parser){ + surveilOffset = parser->intValue; + SAFE_DELETE(parser); + } Targetable * t = spell ? spell->getNextTarget() : NULL; MTGAbility * a = NEW AAAlterSurveilOffset(observer, id, card, t, surveilOffset, NULL, who); a->oneShot = 1; @@ -4104,7 +4282,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitDevotionOffset = parseBetween(s, "alterdevoffset:", " ", false); if (splitDevotionOffset.size()) { - int devotionOffset = atoi(splitDevotionOffset[1].c_str()); + int devotionOffset = 0; + WParsedInt* parser = NEW WParsedInt(splitDevotionOffset[1], card); + if(parser){ + devotionOffset = parser->intValue; + SAFE_DELETE(parser); + } Targetable * t = spell ? spell->getNextTarget() : NULL; MTGAbility * a = NEW AAAlterDevotionOffset(observer, id, card, t, devotionOffset, NULL, who); a->oneShot = 1; @@ -4115,7 +4298,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitPrevent = parseBetween(s, "prevent:", " ", false); if (splitPrevent.size()) { - int preventing = atoi(splitPrevent[1].c_str()); + int preventing = 0; + WParsedInt* parser = NEW WParsedInt(splitPrevent[1], card); + if(parser){ + preventing = parser->intValue; + SAFE_DELETE(parser); + } Targetable * t = spell ? spell->getNextTarget() : NULL; MTGAbility * a = NEW AADamagePrevent(observer, id, card, t, preventing, NULL, who); a->oneShot = 1; @@ -4139,7 +4327,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG { Damageable * t = spell ? spell->getNextDamageableTarget() : NULL; vector ccParameters = split( splitAuraIncreaseReduce[1], ':'); - int amount = atoi(ccParameters[1].c_str()); + int amount = 0; + WParsedInt* parser = NEW WParsedInt(ccParameters[1], card); + if(parser){ + amount = parser->intValue; + SAFE_DELETE(parser); + } int color = Constants::GetColorStringIndex(ccParameters[0]); if(ccParameters[0] == "colorless") color = 0; @@ -4155,7 +4348,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitSetHand = parseBetween(s, "sethand:", " ", false); if (splitSetHand.size()) { - int hand = atoi(splitSetHand[1].c_str()); + int hand = 0; + WParsedInt* parser = NEW WParsedInt(splitSetHand[1], card); + if(parser){ + hand = parser->intValue; + SAFE_DELETE(parser); + } Damageable * t = spell ? spell->getNextDamageableTarget() : NULL; MTGAbility * a = NEW AASetHand(observer, id, card, t, hand, NULL, who); a->oneShot = 1; @@ -4364,7 +4562,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG DebugTrace("MTGAbility Parse error in rampage" << s); return NULL; } - int MaxOpponent = atoi(rampageParameters[1].c_str()); + int MaxOpponent = 0; + WParsedInt* parser = NEW WParsedInt(rampageParameters[1], card); + if(parser){ + MaxOpponent = parser->intValue; + SAFE_DELETE(parser); + } return NEW ARampageAbility(observer, id, card, power, toughness, MaxOpponent); } @@ -4546,8 +4749,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitRemoveSpecificCounters = parseBetween(s, "removesinglecountertype(", ")"); if (splitRemoveSpecificCounters.size()) { + int nb = 0; WParsedInt* parser = NEW WParsedInt(splitRemoveSpecificCounters[1], card); - int nb = parser->intValue; + if(parser){ + nb = parser->intValue; + SAFE_DELETE(parser); + } MTGAbility * a = NEW AARemoveSingleCounter(observer, id, card, target, NULL, nb); a->oneShot = 1; a->canBeInterrupted = false; @@ -4656,8 +4863,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitBloodthirst = parseBetween(s, "bloodthirst:", " ", false); if (splitBloodthirst.size()) { + int nb = 0; WParsedInt* parser = NEW WParsedInt(splitBloodthirst[1], card); - int nb = parser->intValue; + if(parser){ + nb = parser->intValue; + SAFE_DELETE(parser); + } return NEW ABloodThirst(observer, id, card, target, nb); } @@ -4665,8 +4876,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitVanishing = parseBetween(s, "vanishing:", " ", false); if (splitVanishing.size()) { + int nb = 0; WParsedInt* parser = NEW WParsedInt(splitVanishing[1], card); - int nb = parser->intValue; + if(parser){ + nb = parser->intValue; + SAFE_DELETE(parser); + } return NEW AVanishing(observer, id, card, NULL, restrictions, nb, "time"); } @@ -4674,8 +4889,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitFading = parseBetween(s, "fading:", " ", false); if (splitFading.size()) { + int nb = 0; WParsedInt* parser = NEW WParsedInt(splitFading[1], card); - int nb = parser->intValue; + if(parser){ + nb = parser->intValue; + SAFE_DELETE(parser); + } return NEW AVanishing(observer, id, card, NULL, restrictions, nb, "fade"); } @@ -4863,8 +5082,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG if(splitChangeCost[1].size()) { vector ccParameters = split( splitChangeCost[1], ':'); - WParsedInt * value = NEW WParsedInt(ccParameters[1].c_str(), NULL, card); - int amount = value->getValue(); + int amount = 0; + WParsedInt * value = NEW WParsedInt(ccParameters[1], NULL, card); + if(value){ + amount = value->getValue(); + SAFE_DELETE(value); + } int color = Constants::GetColorStringIndex(ccParameters[0]); if(ccParameters[0] == "colorless") color = 0; @@ -5120,7 +5343,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitMaxlevel = parseBetween(s, "maxlevel:", " ", false); if (splitMaxlevel.size()) { - MTGAbility * a = NEW AAWhatsMax(observer, id, card, card, NULL, atoi(splitMaxlevel[1].c_str())); + int level = 0; + WParsedInt* parser = NEW WParsedInt(splitMaxlevel[1], card); + if(parser){ + level = parser->intValue; + SAFE_DELETE(parser); + } + MTGAbility * a = NEW AAWhatsMax(observer, id, card, card, NULL, level); a->oneShot = 1; return a; } @@ -6508,8 +6737,12 @@ MTGAbility * AbilityFactory::getManaReduxAbility(string s, int id, Spell *, MTGC return NULL; } // figure out the mana cost - WParsedInt * value = NEW WParsedInt(manaCost.c_str(), NULL, card); - int amount = value->getValue(); + int amount = 0; + WParsedInt * value = NEW WParsedInt(manaCost, NULL, card); + if(value){ + amount = value->getValue(); + SAFE_DELETE(value); + } return NEW AAlterCost(observer, id, card, target, amount, color); } diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 02177f822..a2d071a26 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -577,18 +577,22 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone if(card->name == copy->name && !card->hasType(Subtypes::TYPE_LEGENDARY) && copy->hasType(Subtypes::TYPE_LEGENDARY)) // This fix issue when cloning a card with nolegend option (e.g. Double Major) copy->removeType(Subtypes::TYPE_LEGENDARY); + // This fix issue types problem when card change zone with different card types than its original version (e.g. double face cards). std::vector realTypes; - if(card->name == copy->backSide){ // This fix issue types problem when card dies as its backside (e.g. "Incubator" and "Phyrexian"). + string originame = copy->name; + if(doCopy && !asCopy && !inplaytoinplay){ for (int i = ((int)copy->types.size())-1; i >= 0; --i){ realTypes.push_back(copy->types[i]); copy->removeType(copy->types[i]); } + copy->name = originame; for (int i = 0; i < ((int)card->types.size()); i++) copy->addType(card->types[i]); if(copy->types[0] == 1 && copy->types[1] == 7){ // Fix order for Legendary Creatures copy->types[0] = 7; copy->types[1] = 1; } + copy->mPropertiesChangedSinceLastUpdate = false; } // Copy all the counters of the original card... (solving the bug on comparison cards with counter before zone changing events) @@ -802,14 +806,18 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone if(doCopy && !inplaytoinplay && copy->has(Constants::ISPREY)) copy->basicAbilities[Constants::ISPREY] = 0; - if(realTypes.size() && card->name == copy->backSide){ // Reset original types when card dies as its backside (e.g. "Incubator" and "Phyrexian"). + // Reset original types when card change zone with different card types than its original version (e.g. double face cards). + if(doCopy && !inplaytoinplay && realTypes.size()){ copy->types.clear(); - for (int i = 0; i < ((int)realTypes.size()); i++) + for (int i = ((int)realTypes.size())-1; i >= 0; i--) copy->addType(realTypes[i]); if(copy->types[0] == 1 && copy->types[1] == 7){ // Fix order for Legendary Creatures copy->types[0] = 7; copy->types[1] = 1; } + copy->name = originame; + copy->mPropertiesChangedSinceLastUpdate = false; + realTypes.clear(); } // Erasing counters from copy after the event has been triggered (no counter can survive to a zone changing except the perpetual ones) diff --git a/projects/mtg/src/ManaCost.cpp b/projects/mtg/src/ManaCost.cpp index 550eba4a0..e3a5e69c0 100644 --- a/projects/mtg/src/ManaCost.cpp +++ b/projects/mtg/src/ManaCost.cpp @@ -170,9 +170,11 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan size_t var_start = value.find("("); size_t var_end = value.find(")", var_start); string varString = value.substr(var_start + 1, var_end - var_start - 1); - WParsedInt * value = NEW WParsedInt(varString.c_str(),NULL,c); - if(value) + WParsedInt * value = NEW WParsedInt(varString,NULL,c); + if(value){ manaCost->add(Constants::MTG_COLOR_ARTIFACT, value->getValue()); + SAFE_DELETE(value); + } else break; } @@ -329,7 +331,7 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan else if(value == "chosencolor") { if(c) - manaCost->add(c->chooseacolor, 1); + manaCost->add(c->chooseacolor, 1); } else if(value == "cycle") { diff --git a/projects/mtg/src/WEvent.cpp b/projects/mtg/src/WEvent.cpp index c50f1e3e0..2fd691e81 100644 --- a/projects/mtg/src/WEvent.cpp +++ b/projects/mtg/src/WEvent.cpp @@ -43,11 +43,16 @@ WEventCardUpdate::WEventCardUpdate(MTGCardInstance * card) : } ; -WEventCounters::WEventCounters(Counters *counter,string name,int power,int toughness,bool added,bool removed, MTGCardInstance* source) : +WEventCounters::WEventCounters(Counters *counter, string name, int power, int toughness, bool added, bool removed, MTGCardInstance* source) : WEvent(),counter(counter),name(name),power(power),toughness(toughness),added(added),removed(removed),source(source) { } +WEventTotalCounters::WEventTotalCounters(Counters *counter, string name, int power, int toughness, bool added, bool removed, int totalamount, MTGCardInstance* source) : +WEvent(),counter(counter),name(name),power(power),toughness(toughness),added(added),removed(removed),totalamount(totalamount),source(source) +{ +} + WEventPhaseChange::WEventPhaseChange(Phase * from, Phase * to) : WEvent(CHANGE_PHASE), from(from), to(to) { @@ -409,6 +414,11 @@ Targetable * WEventCounters::getTarget(int target) return targetCard; } +Targetable * WEventTotalCounters::getTarget(int target) +{ + return targetCard; +} + Targetable * WEventVampire::getTarget(int target) { switch (target) diff --git a/projects/mtg/src/WParsedInt.cpp b/projects/mtg/src/WParsedInt.cpp index 30131c157..9745a2765 100644 --- a/projects/mtg/src/WParsedInt.cpp +++ b/projects/mtg/src/WParsedInt.cpp @@ -735,8 +735,12 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card) } else if (s.find("genrand") != string::npos) //Return a random value between 0 and a specific number (minus 1); { + intValue = 0; WParsedInt * value = NEW WParsedInt(s.substr(7).c_str(), NULL, card); - intValue = std::rand() % value->getValue(); + if(value){ + intValue = std::rand() % value->getValue(); + SAFE_DELETE(value); + } } else if (s == "manacost") //Return the converted manacost {