diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index bcc0ab4a7..b293b3086 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -10070,6 +10070,17 @@ power=2 toughness=2 [/card] [card] +name=Bear Umbra +abilities=totemarmor +target=creature +auto=teach(creature) 2/2 +auto=teach(creature) transforms((,newability[@combat(attacking) source(this):untap all(land|mybattlefield)])) +text=Enchant creature -- Enchanted creature gets +2/+2 and has "Whenever this creature attacks, untap all lands you control." -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) +mana={2}{G}{G} +type=Enchantment +subtype=Aura +[/card] +[card] name=Bearer of Overwhelming Truths auto=@movedto(*[-creature|mystack):1/1 ueot auto=@combatdamaged(player) from(this):token(Clue,Artifact Clue,0/0) and!( transforms((,newability[{S}{2}:draw:1])) forever )! controller @@ -12980,6 +12991,16 @@ power=3 toughness=3 [/card] [card] +name=Boar Umbra +abilities=totemarmor +target=creature +auto=teach(creature) 3/3 +text=Enchant creature -- Enchanted creature gets +3/+3. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) +mana={2}{G} +type=Enchantment +subtype=Aura +[/card] +[card] name=Boartusk Liege abilities=trample auto=lord(other creature[red]|myBattlefield) 1/1 @@ -23206,6 +23227,16 @@ power=6 toughness=6 [/card] [card] +name=Crab Umbra +abilities=totemarmor +target=creature +auto={2}{U}:untap(mytgt) +text=Enchant creature -- {2}{U}: Untap enchanted creature. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) +mana={U} +type=Enchantment +subtype=Aura +[/card] +[card] name=Crabapple Cohort auto=aslongas(other creature[green]|myBattlefield) 1/1 != 0 text=Crabapple Cohort gets +1/+1 as long as you control another green creature. @@ -31510,6 +31541,17 @@ power=1 toughness=3 [/card] [card] +name=Drake Umbra +abilities=totemarmor +target=creature +auto=teach(creature) 3/3 +auto=teach(creature) flying +text=Enchant creature -- Enchanted creature gets +3/+3 and has flying. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) +mana={4}{U} +type=Enchantment +subtype=Aura +[/card] +[card] name=Drake-Skull Cameo auto={T}:Add{U} auto={T}:Add{B} @@ -34000,6 +34042,16 @@ power=2 toughness=2 [/card] [card] +name=Eel Umbra +abilities=flash,totemarmor +target=creature +auto=teach(creature) 1/1 +text=Flash (You may cast this spell any time you could cast an instant.) -- Enchant creature -- Enchanted creature gets +1/+1. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) +mana={1}{U} +type=Enchantment +subtype=Aura +[/card] +[card] name=Eerie Interlude target=creature|mybattlefield auto=(blink) @@ -34180,6 +34232,16 @@ mana={G} type=Enchantment [/card] [card] +name=Eland Umbra +abilities=totemarmor +target=creature +auto=teach(creature) 0/4 +text=Enchant creature -- Enchanted creature gets +0/+4. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) +mana={1}{W} +type=Enchantment +subtype=Aura +[/card] +[card] name=Elbrus, the Binding Blade auto={1}:equip auto=teach(creature) 1/0 @@ -39643,6 +39705,17 @@ power=4 toughness=6 [/card] [card] +name=Felidar Umbra +abilities=totemarmor +target=creature +auto=teach(creature) lifelink +auto={1}{W}:rehook target(creature|mybattlefield) +text=Enchant creature -- Enchanted creature has lifelink. -- {1}{W}: Attach Felidar Umbra to target creature you control. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) +mana={1}{W} +type=Enchantment +subtype=Aura +[/card] +[card] name=Fell Shepherd auto=@combatdamaged(player) from(this):may name(Get All Creatures) moveto(myhand) all(creature[fresh]|mygraveyard) auto={b}{s(creature|mybattlefield)}:target(creature) -2/-2 ueot @@ -56591,6 +56664,17 @@ mana={U} type=Instant [/card] [card] +name=Hyena Umbra +abilities=totemarmor +target=creature +auto=teach(creature) 1/1 +auto=teach(creature) first strike +text=Enchant creature -- Enchanted creature gets +1/+1 and has first strike. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) +mana={W} +type=Enchantment +subtype=Aura +[/card] +[card] name=Hymn of Rebirth target=creature|graveyard auto=moveTo(myBattlefield) @@ -57941,6 +58025,18 @@ power=4 toughness=4 [/card] [card] +name=Indrik Umbra +abilities=totemarmor +target=creature +auto=teach(creature) 4/4 +auto=teach(creature) first strike +auto=teach(creature) lure +text=Enchant creature -- Enchanted creature gets +4/+4 and has first strike, and all creatures able to block it do so. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) +mana={4}{G}{W} +type=Enchantment +subtype=Aura +[/card] +[card] name=Induce Paranoia target=*|stack auto=if spent({B}) then transforms((,newability[deplete:manacost],newability[fizzle])) else fizzle @@ -70370,6 +70466,17 @@ type=Enchantment subtype=Aura [/card] [card] +name=Mammoth Umbra +abilities=totemarmor +target=creature +auto=teach(creature) 3/3 +auto=teach(creature) vigilance +text=Enchant creature -- Enchanted creature gets +3/+3 and has vigilance. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) +mana={4}{W} +type=Enchantment +subtype=Aura +[/card] +[card] name=Mana Bloom auto=counter(0/0,X,Charge) auto={C(0/0,-1,Charge)}:Add{G} limit:1 @@ -108618,6 +108725,17 @@ mana={3}{G} type=Enchantment [/card] [card] +name=Snake Umbra +abilities=totemarmor +target=creature +auto=teach(creature) 1/1 +auto=teach(creature) transforms((,newability[@damagefoeof(player) from(this):may draw:1 controller])) +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.) +mana={2}{G} +type=Enchantment +subtype=Aura +[/card] +[card] name=Snakeform target=creature auto=ueot loseabilities @@ -110992,6 +111110,17 @@ mana={4}{G} type=Sorcery [/card] [card] +name=Spider Umbra +abilities=totemarmor +target=creature +auto=teach(creature) 1/1 +auto=teach(creature) reach +text=Enchant creature -- Enchanted creature gets +1/+1 and has reach. (It can block creatures with flying.) -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) +mana={G} +type=Enchantment +subtype=Aura +[/card] +[card] name=Spidersilk Armor auto=lord(creature|myBattlefield) 0/1 auto=lord(creature|myBattlefield) reach @@ -122685,7 +122814,7 @@ toughness=5 [card] name=Tormented Hero auto=tap(noevent) -auto=@targeted(this) from(*|nonbattlezone):lifeleech:-1 opponent +auto=@targeted(this) from(*|mycastingzone):lifeleech:-1 opponent text=Tormented Hero enters the battlefield tapped. -- Heroic - Whenever you cast a spell that targets Tormented Hero, each opponent loses 1 life. You gain life equal to the life lost this way. mana={B} type=Creature diff --git a/projects/mtg/bin/Res/sets/primitives/unsupported.txt b/projects/mtg/bin/Res/sets/primitives/unsupported.txt index e2bd26d26..071d63df8 100644 --- a/projects/mtg/bin/Res/sets/primitives/unsupported.txt +++ b/projects/mtg/bin/Res/sets/primitives/unsupported.txt @@ -1018,13 +1018,6 @@ power=1 toughness=3 [/card] [card] -name=Bear Umbra -text=Enchant creature -- Enchanted creature gets +2/+2 and has "Whenever this creature attacks, untap all lands you control." -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) -mana={2}{G}{G} -type=Enchantment -subtype=Aura -[/card] -[card] name=Bearer of Silence text=Devoid (This card has no color.) -- When you cast Bearer of Silence, you may pay {1}{C}. If you do, target opponent sacrifices a creature. ({C} represents colorless mana.) -- Flying -- Bearer of Silence can't block. mana={1}{B} @@ -1294,13 +1287,6 @@ mana={2}{R} type=Enchantment [/card] [card] -name=Boar Umbra -text=Enchant creature -- Enchanted creature gets +3/+3. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) -mana={2}{G} -type=Enchantment -subtype=Aura -[/card] -[card] name=Bog Hoodlums text=Bog Hoodlums can't block. -- When Bog Hoodlums enters the battlefield, clash with an opponent. If you win, put a +1/+1 counter on Bog Hoodlums. (Each clashing player reveals the top card of his or her library, then puts that card on the top or bottom. A player wins if his or her card had a higher converted mana cost.) mana={5}{B} @@ -2864,13 +2850,6 @@ type=Enchantment subtype=Aura [/card] [card] -name=Crab Umbra -text=Enchant creature -- {2}{U}: Untap enchanted creature. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) -mana={U} -type=Enchantment -subtype=Aura -[/card] -[card] name=Cragganwick Cremator text=When Cragganwick Cremator enters the battlefield, discard a card at random. If you discard a creature card this way, Cragganwick Cremator deals damage equal to that card's power to target player. mana={2}{R}{R} @@ -3978,13 +3957,6 @@ mana={U}{U} type=Sorcery [/card] [card] -name=Drake Umbra -text=Enchant creature -- Enchanted creature gets +3/+3 and has flying. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) -mana={4}{U} -type=Enchantment -subtype=Aura -[/card] -[card] name=Dralnu, Lich Lord text=If damage would be dealt to Dralnu, Lich Lord, sacrifice that many permanents instead. -- {T}: Target instant or sorcery card in your graveyard gains flashback until end of turn. The flashback cost is equal to its mana cost. (You may cast that card from your graveyard for its flashback cost. Then exile it.) mana={3}{U}{B} @@ -4162,20 +4134,6 @@ type=Plane subtype=Belenon [/card] [card] -name=Eel Umbra -text=Flash (You may cast this spell any time you could cast an instant.) -- Enchant creature -- Enchanted creature gets +1/+1. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) -mana={1}{U} -type=Enchantment -subtype=Aura -[/card] -[card] -name=Eland Umbra -text=Enchant creature -- Enchanted creature gets +0/+4. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) -mana={1}{W} -type=Enchantment -subtype=Aura -[/card] -[card] name=Elderwood Scion text=Trample, lifelink -- Spells you cast that target Elderwood Scion cost {2} less to cast. -- Spells your opponents cast that target Elderwood Scion cost {2} more to cast. mana={3}{G}{W} @@ -4803,13 +4761,6 @@ mana={R} type=Instant [/card] [card] -name=Felidar Umbra -text=Enchant creature -- Enchanted creature has lifelink. -- {1}{W}: Attach Felidar Umbra to target creature you control. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) -mana={1}{W} -type=Enchantment -subtype=Aura -[/card] -[card] name=Fell the Mighty text=Destroy all creatures with power greater than target creature's power. mana={4}{W} @@ -6943,13 +6894,6 @@ power=3 toughness=3 [/card] [card] -name=Hyena Umbra -text=Enchant creature -- Enchanted creature gets +1/+1 and has first strike. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) -mana={W} -type=Enchantment -subtype=Aura -[/card] -[card] name=Hymn of the Wilds text=(Start the game with this conspiracy face up in the command zone.) -- The first creature spell you cast each turn costs {1} less to cast. -- You can't cast instant or sorcery spells. type=Conspiracy @@ -7253,13 +7197,6 @@ mana={3}{G}{G} type=Sorcery [/card] [card] -name=Indrik Umbra -text=Enchant creature -- Enchanted creature gets +4/+4 and has first strike, and all creatures able to block it do so. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) -mana={4}{G}{W} -type=Enchantment -subtype=Aura -[/card] -[card] name=Induce Despair text=As an additional cost to cast Induce Despair, reveal a creature card from your hand. -- Target creature gets -X/-X until end of turn, where X is the revealed card's converted mana cost. mana={2}{B} @@ -8966,13 +8903,6 @@ power=* toughness=* [/card] [card] -name=Mammoth Umbra -text=Enchant creature -- Enchanted creature gets +3/+3 and has vigilance. -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) -mana={4}{W} -type=Enchantment -subtype=Aura -[/card] -[card] name=Mana Cache text=At the beginning of each player's end step, put a charge counter on Mana Cache for each untapped land that player controls. -- Remove a charge counter from Mana Cache: Add {1} to your mana pool. Any player may activate this ability but only during his or her turn before the end step. mana={1}{R}{R} @@ -14358,13 +14288,6 @@ power=2 toughness=2 [/card] [card] -name=Snake Umbra -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.) -mana={2}{G} -type=Enchantment -subtype=Aura -[/card] -[card] name=Snow Mercy text=Whenever a creature deals damage to you, put a globe counter on it. -- {T}, {untap}, {T}, {untap}, {T}: Tap all creatures with globe counters on them. mana={2}{W}{W} @@ -14811,13 +14734,6 @@ type=Enchantment subtype=Aura [/card] [card] -name=Spider Umbra -text=Enchant creature -- Enchanted creature gets +1/+1 and has reach. (It can block creatures with flying.) -- Totem armor (If enchanted creature would be destroyed, instead remove all damage from it and destroy this Aura.) -mana={G} -type=Enchantment -subtype=Aura -[/card] -[card] name=Spike Cannibal text=Spike Cannibal enters the battlefield with a +1/+1 counter on it. -- When Spike Cannibal enters the battlefield, move all +1/+1 counters from all creatures onto it. mana={1}{B}{B} diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index fafcad398..d25fa0615 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -7253,6 +7253,90 @@ public: } }; //------------------ +//trigger regen +class ATriggerRegen: public InstantAbility +{ +public: + ATriggerRegen(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target) : + InstantAbility(observer, _id, _source) + { + target = _target; + } + + int resolve() + { + MTGCardInstance * card = (MTGCardInstance *) target; + if (card) + { + if (!card->regenerateTokens) + return 0; + if (card->has(Constants::CANTREGEN)) + return 0; + card->regenerateTokens--; + card->tap(); + if(card->isCreature()) + { + card->life = card->toughness; + card->initAttackersDefensers(); + if (card->life < 1) + return 0; //regeneration didn't work (wither ?) + } + } + return 1; + } + const string getMenuText() + { + return "Regenerate"; + } + virtual ostream& toString(ostream& out) const + { + out << "AATriggerRegen ::: ("; + return InstantAbility::toString(out) << ")"; + } + ATriggerRegen * clone() const + { + return NEW ATriggerRegen(*this); + } +}; +//trigger totem +class ATriggerTotem: public InstantAbility +{ +public: + ATriggerTotem(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target) : + InstantAbility(observer, _id, _source) + { + target = _target; + } + + int resolve() + { + MTGCardInstance * card = (MTGCardInstance *) target; + if (card) + { + card->destroy(); + if(source->isCreature()) + { + source->life = source->toughness; + if (source->life < 1) + return 0; //regeneration didn't work (wither ?) + } + } + return 1; + } + const string getMenuText() + { + return "Totem Armor"; + } + virtual ostream& toString(ostream& out) const + { + out << "AATriggerTotem ::: ("; + return InstantAbility::toString(out) << ")"; + } + ATriggerTotem * clone() const + { + return NEW ATriggerTotem(*this); + } +}; // utility functions void PopulateColorIndexVector(list& colors, const string& colorsString, char delimiter = ','); diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 38a64ebb7..63beac0fb 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -139,6 +139,7 @@ public: ManaCost * getReducedManaCost(); ManaCost * getIncreasedManaCost(); bool matchesCastFilter(int castMethod); + bool hasTotemArmor(); // The recommended method to test for summoning Sickness ! int hasSummoningSickness(); @@ -203,8 +204,10 @@ public: Player * controller(); virtual ~MTGCardInstance(); - int bury(); + int totem( bool noregen = false ); + int toGrave( bool forced = false ); int destroy(); + int destroyNoRegen(); int addToToughness(int value); int setToughness(int value); diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index b1119ca81..4cd71346d 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -274,7 +274,8 @@ class Constants CANPLAYINSTANTSORCERYTOPLIBRARY = 152,//instantorsorcery SHOWFROMTOPLIBRARY = 153, SHOWOPPONENTTOPLIBRARY = 154, - NB_BASIC_ABILITIES = 155, + TOTEMARMOR = 155, + NB_BASIC_ABILITIES = 156, RARITY_S = 'S', //Special Rarity RARITY_M = 'M', //Mythics diff --git a/projects/mtg/include/TargetChooser.h b/projects/mtg/include/TargetChooser.h index 1313a3b90..b516b17bd 100644 --- a/projects/mtg/include/TargetChooser.h +++ b/projects/mtg/include/TargetChooser.h @@ -377,4 +377,24 @@ public: virtual bool equals(TargetChooser * tc); ~ChildrenChooser(); }; + +class TotemChooser: public TypeTargetChooser +{ +public: + bool withoutProtections; + TotemChooser(GameObserver *observer, int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false) : + TypeTargetChooser(observer, "*",_zones, _nbzones, card, _maxtargets, other, targetMin) + { + } + ; + TotemChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false,bool targetMin = false) : + TypeTargetChooser(observer, "*", card, _maxtargets, other,targetMin) + { + } + ; + virtual bool canTarget(Targetable * target, bool withoutProtections = false); + virtual TotemChooser * clone() const; + virtual bool equals(TargetChooser * tc); + ~TotemChooser(); +}; #endif diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 89b6a2b15..35551c229 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2855,7 +2855,13 @@ int AABuryCard::resolve() MTGCardInstance * _target = (MTGCardInstance *) target; if (_target) { - _target->bury(); + //Bury (Obsolete) + //A term that meant “put [a permanent] into its owner’s graveyard.” + //In general, cards that were printed with the term “bury” have received errata + //in the Oracle card reference to read, “Destroy [a permanent]. It can’t be regenerated,” + //or “Sacrifice [a permanent].” + //_target->bury(); + _target->destroyNoRegen();//so totem armor will take effect on wrath effects since totem armor is not regeneration.. while(_target->next) _target = _target->next; if(andAbility) @@ -3221,6 +3227,10 @@ int AANewTarget::resolve() while (_target->next) _target = _target->next; } + if(_target->hasSubtype(Subtypes::TYPE_AURA)) + { + _target->target = source; + } if(_target->hasSubtype(Subtypes::TYPE_EQUIPMENT)) { for (size_t i = 1; i < game->mLayers->actionLayer()->mObjects.size(); i++) diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 754446146..1b395a834 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -445,7 +445,51 @@ int MTGCardInstance::afterDamage() return 0; } -int MTGCardInstance::bury() +int MTGCardInstance::totem(bool noregen) +{ + int testToughness = toughness; + testToughness += tbonus; + if(testToughness < 1) + { + if(noregen) + return toGrave(); + else if (!triggerRegenerate()) + return toGrave(); + return 0; + } + bool canregen = (regenerateTokens && !has(Constants::CANTREGEN) && !noregen); + vectorselection; + TargetChooserFactory tf(getObserver()); + TargetChooser * tcb = tf.createTargetChooser("mytotem",this); + tcb->targetter = NULL; + tcb->maxtargets = 1; + MTGAbility * destroyTotem = NEW ATriggerTotem(getObserver(), getObserver()->mLayers->actionLayer()->getMaxId(),this,NULL); + destroyTotem->oneShot = true; + destroyTotem->canBeInterrupted = false; + MTGAbility * dtTarget = NEW GenericTargetAbility(getObserver(), "","",getObserver()->mLayers->actionLayer()->getMaxId(), this,tcb->clone(), destroyTotem->clone()); + SAFE_DELETE(destroyTotem); + dtTarget->oneShot = true; + dtTarget->canBeInterrupted = false; + MTGAbility * addTotemtoGame = NEW GenericAddToGame(getObserver(), getObserver()->mLayers->actionLayer()->getMaxId(), this,NULL,dtTarget->clone()); + SAFE_DELETE(dtTarget); + addTotemtoGame->oneShot = true; + addTotemtoGame->canBeInterrupted = false; + selection.push_back(addTotemtoGame->clone()); + SAFE_DELETE(addTotemtoGame); + SAFE_DELETE(tcb); + if(canregen) + { + MTGAbility * triggerRegen = NEW ATriggerRegen(getObserver(), getObserver()->mLayers->actionLayer()->getMaxId(), this, this); + triggerRegen->oneShot = true; + triggerRegen->canBeInterrupted = false; + selection.push_back(triggerRegen->clone()); + SAFE_DELETE(triggerRegen); + } + MTGAbility * menuChoice = NEW MenuAbility(getObserver(), getObserver()->mLayers->actionLayer()->getMaxId(), NULL, this,true,selection,this->controller(),""); + menuChoice->addToGame(); + return 1; +} +int MTGCardInstance::toGrave( bool forced ) { Player * p = controller(); if (basicAbilities[(int)Constants::EXILEDEATH]) @@ -458,15 +502,29 @@ int MTGCardInstance::bury() p->game->putInZone(this, p->game->inPlay, owner->game->graveyard); return 1; } + if (forced) + { + p->game->putInZone(this, p->game->inPlay, owner->game->graveyard); + return 1; + } return 0; } int MTGCardInstance::destroy() { - if (!triggerRegenerate()) - return bury(); + if (hasTotemArmor()) + return totem(); + else if (!triggerRegenerate()) + return toGrave(); + return 0; +} +int MTGCardInstance::destroyNoRegen() +{ + if (hasTotemArmor()) + return totem(true); + else + return toGrave(); return 0; } - MTGGameZone * MTGCardInstance::getCurrentZone() { return currentZone; @@ -1525,6 +1583,32 @@ bool MTGCardInstance::matchesCastFilter(int castFilter) { return (castFilter == castMethod); }; +bool MTGCardInstance::hasTotemArmor() +{ + int count = 0; + if(observer) + { + for (int i = 0; i < 2; i++) + { + int nb_cards = observer->players[i]->game->battlefield->nb_cards; + for(int x = 0; x < nb_cards; x++) + { + if(observer->players[i]->game->battlefield->cards[x]->auraParent) + { + if(observer->players[i]->game->battlefield->cards[x]->auraParent == this && + observer->players[i]->game->battlefield->cards[x]->has(Constants::TOTEMARMOR)) + count+=1; + } + } + } + } + + if(count) + return true; + + return false; +} + int MTGCardInstance::addProtection(TargetChooser * tc) { tc->targetter = NULL; diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index 9a3284af9..507032e8b 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -185,7 +185,8 @@ const char* Constants::MTGBasicAbilities[] = { "canplayartifactlibrarytop",//artifact "canplayinstantsorcerylibrarytop",//instant or sorcery "showfromtoplibrary", - "showopponenttoplibrary" + "showopponenttoplibrary", + "totemarmor" }; map Constants::MTGBasicAbilitiesMap; diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 8c8fb423f..a4930645c 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -3741,7 +3741,7 @@ int MTGPlaneswalkerDamage::receiveEvent(WEvent * event) if(removel->removed && removel->targetCard && removel->targetCard->hasType(Subtypes::TYPE_PLANESWALKER)) if(!removel->targetCard->counters->hasCounter("loyalty",0,0)) { - removel->targetCard->bury(); + removel->targetCard->toGrave(true); return 1; } diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index 91c966c1d..951722a5f 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -55,6 +55,13 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta return NEW ChildrenChooser(observer, card, maxtargets); }; + found = s.find("mytotem"); + if (found == 0) + { + int maxtargets = 1; + return NEW TotemChooser(observer, card, maxtargets); + }; + found = s.find("targetedplayer"); if (found == 0) { @@ -220,6 +227,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta zones[nbzones++] = MTGGameZone::MY_LIBRARY; zones[nbzones++] = MTGGameZone::MY_HAND; zones[nbzones++] = MTGGameZone::MY_EXILE; + zones[nbzones++] = MTGGameZone::MY_SIDEBOARD; } else if (zoneName.compare("opponentcastingzone") == 0) { @@ -2061,3 +2069,42 @@ bool ChildrenChooser::equals(TargetChooser * tc) ChildrenChooser::~ChildrenChooser() { } + +//totem armor chooser +bool TotemChooser::canTarget(Targetable * target,bool withoutProtections) +{ + if (MTGCardInstance * card = dynamic_cast(target)) + { + if(card == source) + return false; + if(!card->isInPlay(observer)) + return false; + if(card->auraParent) + { + if((card->auraParent) == source && (card->has(Constants::TOTEMARMOR))) + return true; + } + return false; + } + return false; +} + +TotemChooser* TotemChooser::clone() const +{ + TotemChooser * a = NEW TotemChooser(*this); + return a; +} + +bool TotemChooser::equals(TargetChooser * tc) +{ + + TotemChooser * dtc = dynamic_cast (tc); + if (!dtc) + return false; + + return TypeTargetChooser::equals(tc); +} + +TotemChooser::~TotemChooser() +{ +}