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
+22 -3
View File
@@ -2249,8 +2249,20 @@ public:
{ {
if(card->isPhased || source->isPhased) if(card->isPhased || source->isPhased)
return 0; return 0;
if(tc->canTarget(card) && card != tc->source)
{
if ((tc->source->hasSubtype(Subtypes::TYPE_AURA) || tc->source->hasSubtype(Subtypes::TYPE_EQUIPMENT) || tc->source->hasSubtype("instant") if ((tc->source->hasSubtype(Subtypes::TYPE_AURA) || tc->source->hasSubtype(Subtypes::TYPE_EQUIPMENT) || tc->source->hasSubtype("instant")
|| tc->source->hasSubtype("sorcery")) && tc->canTarget(card) && card == tc->source->target && card != tc->source) return 1; || tc->source->hasSubtype("sorcery")) && card == tc->source->target )
return 1;
if(tc->source->hasSubtype(Subtypes::TYPE_CREATURE))
{
for(size_t myChild = 0; myChild < tc->source->parentCards.size();++myChild)
{
if(tc->source->parentCards[myChild] == card)
return 1;
}
}
}
return 0; return 0;
} }
@@ -2289,6 +2301,9 @@ public:
} }
else else
{ {
if(tc->source->hasSubtype(Subtypes::TYPE_CREATURE))
a->target = d;
else
return 0; return 0;
} }
@@ -2426,8 +2441,11 @@ public:
{ {
if (source->target && !game->isInPlay(source->target)) if (source->target && !game->isInPlay(source->target))
unequip(); unequip();
if(!game->connectRule)
{
if (source->target && TargetAbility::tc && !TargetAbility::tc->canTarget((Targetable *)source->target,true)) if (source->target && TargetAbility::tc && !TargetAbility::tc->canTarget((Targetable *)source->target,true))
unequip(); unequip();
}
return TargetAbility::testDestroy(); return TargetAbility::testDestroy();
} }
@@ -3543,11 +3561,12 @@ public:
class ACounterTracker: public MTGAbility class ACounterTracker: public MTGAbility
{ {
public: public:
Counter * counter; string scounter;
int removed; int removed;
ACounterTracker(int id, MTGCardInstance * source, MTGCardInstance * target, Counter * counter = NULL); ACounterTracker(int id, MTGCardInstance * source, MTGCardInstance * target, string scounter = "");
int addToGame(); int addToGame();
int destroy(); int destroy();
int testDestroy();
ACounterTracker * clone() const; ACounterTracker * clone() const;
~ACounterTracker(); ~ACounterTracker();
}; };
+1
View File
@@ -88,6 +88,7 @@ class GameObserver{
void ButtonPressed(PlayGuiObject*); void ButtonPressed(PlayGuiObject*);
int receiveEvent(WEvent * event); int receiveEvent(WEvent * event);
bool connectRule;
}; };
#endif #endif
+26 -5
View File
@@ -417,8 +417,8 @@ ACounterShroud::~ACounterShroud()
} }
//sheild a card from a certain type of counter. //sheild a card from a certain type of counter.
ACounterTracker::ACounterTracker(int id, MTGCardInstance * source, MTGCardInstance * target, Counter * counter) : ACounterTracker::ACounterTracker(int id, MTGCardInstance * source, MTGCardInstance * target, string scounter) :
MTGAbility(id, source, target),counter(counter) MTGAbility(id, source, target),scounter(scounter)
{ {
removed = 0; removed = 0;
} }
@@ -426,6 +426,13 @@ MTGAbility(id, source, target),counter(counter)
int ACounterTracker::addToGame() int ACounterTracker::addToGame()
{ {
MTGCardInstance * _target = (MTGCardInstance*)target; 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 && !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) 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++; removed++;
} }
} }
SAFE_DELETE(counter);
return 1; return 1;
} }
SAFE_DELETE(counter);
return 0; return 0;
} }
int ACounterTracker::destroy() int ACounterTracker::destroy()
{ {
MTGCardInstance * _target = (MTGCardInstance*)target; MTGCardInstance * _target = (MTGCardInstance*)target;
Counter * counter = NULL;
AbilityFactory af;
counter = af.parseCounter(scounter, _target, (Spell*)source);
if (!counter)
{
return 0;
}
if(_target) if(_target)
{ {
if(removed == counter->nb) 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; return 1;
} }
ACounterTracker * ACounterTracker::clone() const ACounterTracker * ACounterTracker::clone() const
{ {
ACounterTracker * a = NEW ACounterTracker(*this); ACounterTracker * a = NEW ACounterTracker(*this);
a->counter = this->counter;
return a; return a;
} }
ACounterTracker::~ACounterTracker() ACounterTracker::~ACounterTracker()
{ {
SAFE_DELETE(counter);
} }
//removeall counters of a certain type or all. //removeall counters of a certain type or all.
+4
View File
@@ -49,6 +49,7 @@ GameObserver::GameObserver(Player * _players[], int _nb_players)
replacementEffects = NEW ReplacementEffects(); replacementEffects = NEW ReplacementEffects();
combatStep = BLOCKERS; combatStep = BLOCKERS;
mRules = NULL; mRules = NULL;
connectRule = false;
} }
int GameObserver::getCurrentGamePhase() int GameObserver::getCurrentGamePhase()
@@ -472,6 +473,8 @@ void GameObserver::gameStateBasedEffects()
{ {
check = card->childrenCards[wC]; check = card->childrenCards[wC];
for(size_t wCC = 0; wCC < card->childrenCards.size();wCC++) for(size_t wCC = 0; wCC < card->childrenCards.size();wCC++)
{
if(check->isInPlay())
{ {
if(check->getName() == card->childrenCards[wCC]->getName() && check != card->childrenCards[wCC]) if(check->getName() == card->childrenCards[wCC]->getName() && check != card->childrenCards[wCC])
{ {
@@ -479,6 +482,7 @@ void GameObserver::gameStateBasedEffects()
matched = card->childrenCards[wCC]; matched = card->childrenCards[wCC];
} }
} }
}
if(matched) if(matched)
wC = card->childrenCards.size(); wC = card->childrenCards.size();
} }
+2 -8
View File
@@ -1913,14 +1913,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
if (splitCounterTracking.size()) if (splitCounterTracking.size())
{ {
string splitCounterTrack = splitCounterTracking[1]; string splitCounterTrack = splitCounterTracking[1];
Counter * counter = NULL; return NEW ACounterTracker(id, card, target,splitCounterTrack);
counter = parseCounter(splitCounterTrack, target, spell);
if (!counter)
{
DebugTrace("MTGAbility: can't parse counter:" << s);
return NULL;
}
return NEW ACounterTracker(id, card, target,counter);
} }
//removes all counters of the specifified type. //removes all counters of the specifified type.
vector<string> splitRemoveCounter = parseBetween(s, "removeallcounters(", ")"); vector<string> splitRemoveCounter = parseBetween(s, "removeallcounters(", ")");
@@ -2286,6 +2279,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
{ {
GameObserver * game = GameObserver::GetInstance(); GameObserver * game = GameObserver::GetInstance();
game->addObserver(NEW ParentChildRule(-1)); game->addObserver(NEW ParentChildRule(-1));
game->connectRule = true;
return NULL; return NULL;
} }
//create an association between cards. //create an association between cards.
+16 -4
View File
@@ -2337,12 +2337,22 @@ int ParentChildRule::receiveEvent(WEvent * event)
{ {
return 0; return 0;
} }
if(!card->childrenCards.size())
return 0;
Player * p = card->controller(); Player * p = card->controller();
if (z->from == p->game->inPlay) 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]; MTGCardInstance * child = card->childrenCards[w];
if(child == NULL) if(child == NULL)
@@ -2351,14 +2361,16 @@ int ParentChildRule::receiveEvent(WEvent * event)
child->controller()->game->putInGraveyard(child); child->controller()->game->putInGraveyard(child);
else//allows a card to declare 2 homes, as long as it has a home it can stay inplay. 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) if(child->parentCards[myParent] == card)
{
child->parentCards.erase(child->parentCards.begin() + myParent); child->parentCards.erase(child->parentCards.begin() + myParent);
} }
} }
} }
} }
}
return 1; return 1;
} }
return 0; return 0;