extended countertrack and teach( to creatures for use with countertracking...isolated equipment rule that states it can't equip a card it can't target in testDestroy(we want the equipments to stay on a creature even after it's hands are full :)

I'll take a stab at coding the current cards for the mod this evening.
This commit is contained in:
omegablast2002@yahoo.com
2011-09-17 23:27:00 +00:00
parent c5203a9caf
commit 4ab6dfd3da
6 changed files with 81 additions and 30 deletions
+26 -5
View File
@@ -417,8 +417,8 @@ ACounterShroud::~ACounterShroud()
}
//sheild a card from a certain type of counter.
ACounterTracker::ACounterTracker(int id, MTGCardInstance * source, MTGCardInstance * target, Counter * counter) :
MTGAbility(id, source, target),counter(counter)
ACounterTracker::ACounterTracker(int id, MTGCardInstance * source, MTGCardInstance * target, string scounter) :
MTGAbility(id, source, target),scounter(scounter)
{
removed = 0;
}
@@ -426,6 +426,13 @@ MTGAbility(id, source, target),counter(counter)
int ACounterTracker::addToGame()
{
MTGCardInstance * _target = (MTGCardInstance*)target;
Counter * counter = NULL;
AbilityFactory af;
counter = af.parseCounter(scounter, _target, (Spell*)source);
if (!counter)
{
return 0;
}
if(_target && !removed)
{
if(_target->counters->hasCounter(counter->name.c_str(),counter->power,counter->toughness) && _target->counters->hasCounter(counter->name.c_str(),counter->power,counter->toughness)->nb >= counter->nb)
@@ -436,14 +443,23 @@ int ACounterTracker::addToGame()
removed++;
}
}
SAFE_DELETE(counter);
return 1;
}
SAFE_DELETE(counter);
return 0;
}
int ACounterTracker::destroy()
{
MTGCardInstance * _target = (MTGCardInstance*)target;
Counter * counter = NULL;
AbilityFactory af;
counter = af.parseCounter(scounter, _target, (Spell*)source);
if (!counter)
{
return 0;
}
if(_target)
{
if(removed == counter->nb)
@@ -454,20 +470,25 @@ int ACounterTracker::destroy()
}
}
}
removeFromGame();
SAFE_DELETE(counter);
return 1;
}
int ACounterTracker::testDestroy()
{
if(this->source->isInPlay())
return 0;
return 1;
}
ACounterTracker * ACounterTracker::clone() const
{
ACounterTracker * a = NEW ACounterTracker(*this);
a->counter = this->counter;
return a;
}
ACounterTracker::~ACounterTracker()
{
SAFE_DELETE(counter);
}
//removeall counters of a certain type or all.
+7 -3
View File
@@ -49,6 +49,7 @@ GameObserver::GameObserver(Player * _players[], int _nb_players)
replacementEffects = NEW ReplacementEffects();
combatStep = BLOCKERS;
mRules = NULL;
connectRule = false;
}
int GameObserver::getCurrentGamePhase()
@@ -473,10 +474,13 @@ void GameObserver::gameStateBasedEffects()
check = card->childrenCards[wC];
for(size_t wCC = 0; wCC < card->childrenCards.size();wCC++)
{
if(check->getName() == card->childrenCards[wCC]->getName() && check != card->childrenCards[wCC])
if(check->isInPlay())
{
card->isDualWielding = true;
matched = card->childrenCards[wCC];
if(check->getName() == card->childrenCards[wCC]->getName() && check != card->childrenCards[wCC])
{
card->isDualWielding = true;
matched = card->childrenCards[wCC];
}
}
}
if(matched)
+2 -8
View File
@@ -1913,14 +1913,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
if (splitCounterTracking.size())
{
string splitCounterTrack = splitCounterTracking[1];
Counter * counter = NULL;
counter = parseCounter(splitCounterTrack, target, spell);
if (!counter)
{
DebugTrace("MTGAbility: can't parse counter:" << s);
return NULL;
}
return NEW ACounterTracker(id, card, target,counter);
return NEW ACounterTracker(id, card, target,splitCounterTrack);
}
//removes all counters of the specifified type.
vector<string> splitRemoveCounter = parseBetween(s, "removeallcounters(", ")");
@@ -2286,6 +2279,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
{
GameObserver * game = GameObserver::GetInstance();
game->addObserver(NEW ParentChildRule(-1));
game->connectRule = true;
return NULL;
}
//create an association between cards.
+16 -4
View File
@@ -2337,12 +2337,22 @@ int ParentChildRule::receiveEvent(WEvent * event)
{
return 0;
}
if(!card->childrenCards.size())
return 0;
Player * p = card->controller();
if (z->from == p->game->inPlay)
{
for(unsigned int w = 0;w < card->childrenCards.size();w++)
for(size_t myChildCheck = 0;myChildCheck < card->parentCards.size();myChildCheck++)
{
MTGCardInstance * pCard = card->parentCards[myChildCheck];
for(size_t myC = 0;myC < pCard->childrenCards.size();myC++)
{
if(pCard->childrenCards[myC] == card)
{
pCard->childrenCards.erase(pCard->childrenCards.begin() + myC);
}
}
}
for(size_t w = 0;w < card->childrenCards.size();w++)
{
MTGCardInstance * child = card->childrenCards[w];
if(child == NULL)
@@ -2351,10 +2361,12 @@ int ParentChildRule::receiveEvent(WEvent * event)
child->controller()->game->putInGraveyard(child);
else//allows a card to declare 2 homes, as long as it has a home it can stay inplay.
{
for(unsigned int myParent = 0;myParent < child->parentCards.size();myParent++)
for(size_t myParent = 0;myParent < child->parentCards.size();myParent++)
{
if(child->parentCards[myParent] == card)
{
child->parentCards.erase(child->parentCards.begin() + myParent);
}
}
}
}