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

View File

@@ -2245,14 +2245,26 @@ public:
aType = MTGAbility::STANDARD_TEACH;
}
int canBeInList(MTGCardInstance * card)
{
if(card->isPhased || source->isPhased)
int canBeInList(MTGCardInstance * card)
{
if(card->isPhased || source->isPhased)
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")
|| 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;
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;
return 0;
}
}
int resolve()
{
@@ -2289,7 +2301,10 @@ public:
}
else
{
return 0;
if(tc->source->hasSubtype(Subtypes::TYPE_CREATURE))
a->target = d;
else
return 0;
}
if (a->oneShot)
@@ -2426,8 +2441,11 @@ public:
{
if (source->target && !game->isInPlay(source->target))
unequip();
if(!game->connectRule)
{
if (source->target && TargetAbility::tc && !TargetAbility::tc->canTarget((Targetable *)source->target,true))
unequip();
}
return TargetAbility::testDestroy();
}
@@ -3543,11 +3561,12 @@ public:
class ACounterTracker: public MTGAbility
{
public:
Counter * counter;
string scounter;
int removed;
ACounterTracker(int id, MTGCardInstance * source, MTGCardInstance * target, Counter * counter = NULL);
ACounterTracker(int id, MTGCardInstance * source, MTGCardInstance * target, string scounter = "");
int addToGame();
int destroy();
int testDestroy();
ACounterTracker * clone() const;
~ACounterTracker();
};

View File

@@ -88,6 +88,7 @@ class GameObserver{
void ButtonPressed(PlayGuiObject*);
int receiveEvent(WEvent * event);
bool connectRule;
};
#endif

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.

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)

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.

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);
}
}
}
}