Moved "reset damage on creatures at cleanup phase" outside of the engine and made it an ability. This is mostly because I need this for the mod I'm working on, but I hope it can be used by others

This commit is contained in:
wagic.the.homebrew
2011-05-02 14:02:12 +00:00
parent 53f45a8b8e
commit b7cc42ed67
6 changed files with 54 additions and 4 deletions
+4
View File
@@ -1,3 +1,4 @@
#If you change this file, be sure to report your changes into testsuite.txt!
name=Classic name=Classic
[INIT] [INIT]
mode=mtg mode=mtg
@@ -7,3 +8,6 @@ auto=shuffle
auto=draw:7 auto=draw:7
auto=@each my draw:draw:1 auto=@each my draw:draw:1
auto=maxPlay(land)1 auto=maxPlay(land)1
[Player1]
#This is a trick, we put this in player 1's rules so that they most likely won't see that this can be interrupted. Kind of a hack until we can get "noninterruptible" events
auto=@each cleanup:all(*|Battlefield) resetDamage
+3
View File
@@ -6,3 +6,6 @@ mode=mtg
life:20 life:20
auto=@each my draw:draw:1 auto=@each my draw:draw:1
auto=maxPlay(land)1 auto=maxPlay(land)1
[Player1]
#This is a trick, we put this in player 1's rules so that they most likely won't see that this can be interrupted. Kind of a hack until we can get "noninterruptible" events
auto=@each cleanup:all(*|Battlefield) resetDamage
+9
View File
@@ -865,6 +865,15 @@ public:
}; };
class AAResetDamage: public ActivatedAbility
{
public:
AAResetDamage(int id, MTGCardInstance * source, MTGCardInstance * target, ManaCost * cost = NULL);
int resolve();
const char* getMenuText();
AAResetDamage * clone() const;
};
class AAFizzler: public ActivatedAbility class AAFizzler: public ActivatedAbility
{ {
+26
View File
@@ -463,6 +463,32 @@ AARemoveAllCounter * AARemoveAllCounter::clone() const
return a; return a;
} }
//Reset Damage on creatures
AAResetDamage::AAResetDamage(int id, MTGCardInstance * source, MTGCardInstance * _target, ManaCost * cost):
ActivatedAbility(id, source, cost, 0)
{
this->target = _target;
}
int AAResetDamage::resolve()
{
MTGCardInstance * _target = (MTGCardInstance *)target;
_target->life = _target->toughness;
return 1;
}
const char* AAResetDamage::getMenuText()
{
return "Reset Damages";
}
AAResetDamage * AAResetDamage::clone() const
{
AAResetDamage * a = NEW AAResetDamage(*this);
a->isClone = 1;
return a;
}
// Fizzler // Fizzler
AAFizzler::AAFizzler(int _id, MTGCardInstance * card, Spell * _target, ManaCost * _cost) : AAFizzler::AAFizzler(int _id, MTGCardInstance * card, Spell * _target, ManaCost * _cost) :
ActivatedAbility(_id, card, _cost, 0) ActivatedAbility(_id, card, _cost, 0)
+9
View File
@@ -1700,6 +1700,15 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
} }
} }
//Reset damages on cards
found = s.find("resetdamage");
if (found != string::npos)
{
MTGAbility * a = NEW AAResetDamage(id, card, target);
a->oneShot = 1;
return a;
}
//Damage //Damage
vector<string> splitDamage = parseBetween(s, "damage:", " ", false); vector<string> splitDamage = parseBetween(s, "damage:", " ", false);
if (splitDamage.size()) if (splitDamage.size())
+1 -2
View File
@@ -468,11 +468,10 @@ int MTGCardInstance::initAttackersDefensers()
return 1; return 1;
} }
//Function to call to remove all damages, etc to a card (generally at the end of the turn) //Function to cleanup flags on a card (generally at the end of the turn)
int MTGCardInstance::cleanup() int MTGCardInstance::cleanup()
{ {
initAttackersDefensers(); initAttackersDefensers();
life = toughness;
GameObserver * game = GameObserver::GetInstance(); GameObserver * game = GameObserver::GetInstance();
if (!game || game->currentPlayer == controller()) if (!game || game->currentPlayer == controller())
{ {