[CODE] Bestow

All code submission.
Locked
excessum
Posts: 220
Joined: Wed Jan 16, 2013 5:03 am
Contact:

[CODE] Bestow

Post by excessum »

This is a full implementation of the Bestow mechanic, including putting the creature into play if its target is destroyed while casting or when it is in the battlefield as an aura. It is slightly annoying to always have to select a target when casting, even when casting as a creature to ensure that the cast as aura part works. I allowed targeting the player so that it can be casted as a creature when no creature targets are available.

The other issue is with creature ETB effects triggers even when casting the Bestow as an aura. I doubt this can be solved since it requires the spell type to transform before placing on stack.

Code: Select all

Index: mtg/include/MTGDefinitions.h
===================================================================
--- mtg/include/MTGDefinitions.h	(revision 4869)
+++ mtg/include/MTGDefinitions.h	(working copy)
@@ -218,7 +218,8 @@
       soulbond = 100,
       LURE = 101,
       NOLEGEND = 102,
-      NB_BASIC_ABILITIES = 103,
+	  BESTOW = 103,
+      NB_BASIC_ABILITIES = 104,
 
 
     RARITY_S = 'S',   //Special Rarity
Index: mtg/src/GameObserver.cpp
===================================================================
--- mtg/src/GameObserver.cpp	(revision 4869)
+++ mtg/src/GameObserver.cpp	(working copy)
@@ -617,6 +617,17 @@
                 card->myPair->myPair = NULL;
                 card->myPair = NULL;
             }
+			if ( card->has ( Constants::BESTOW ) ) {
+				if ( card->hasSubtype( Subtypes::TYPE_AURA ) ) {
+					if ( ( card->target &&  !isInPlay( card->target ) ) || card->playerTarget ) {
+						card->addType( Subtypes::TYPE_CREATURE );
+						card->removeType( Subtypes::TYPE_AURA );
+						card->target = NULL;
+					}
+				} else {
+					card->target = NULL;
+				}
+			}
             ///////////////////////////////////////////////////////
             //Remove auras that don't have a valid target anymore//
             ///////////////////////////////////////////////////////
Index: mtg/src/MTGDefinitions.cpp
===================================================================
--- mtg/src/MTGDefinitions.cpp	(revision 4869)
+++ mtg/src/MTGDefinitions.cpp	(working copy)
@@ -131,7 +131,8 @@
     "poisondamager",//deals damage to players as poison counters.
     "soulbond",
     "lure",
-    "nolegend"
+    "nolegend",
+	"bestow"
 };
 
 map<string,int> Constants::MTGBasicAbilitiesMap;

Code: Select all

[card]
name=Boon Satyr
other={3}{G}{G} name(Bestow)
abilities=flash,bestow
target=creature,player
auto=if paid(alternative) then all(this) transforms((removetypes)) forever && all(this) transforms((Aura Enchantment,newability[teach(creature) 4/2])) forever
text=Flash -- Bestow {3}{G}{G} (If you cast this card for its bestow cost, it's an Aura spell with enchant creature. It becomes a creature again if it's not attached to a creature.) -- Enchanted creature gets +4/+2.
mana={1}{G}{G}
type=Enchantment Creature
subtype=Satyr
power=4
toughness=2
[/card]

[card]
name=Nimbus Naiad
other={4}{U} name(Bestow)
abilities=flying,bestow
target=creature,player
auto=if paid(alternative) then all(this) transforms((removetypes)) forever && all(this) transforms((Aura Enchantment,newability[teach(creature) 2/2],newability[teach(creature) flying])) forever
text=Bestow 4{U} (If you cast this card for its bestow cost, it's an Aura spell with enchant creature. It becomes a creature again if it's not attached to a creature.) -- Flying -- Enchanted creature gets +2/+2 and has flying.
mana={2}{U}{U}
type=Enchantment Creature
subtype=Nymph
power=2
toughness=2
[/card]
Locked