added countertrack(counterstring) MTGAbility

what this does currently is remove a counter of the type counterstring and when the ability is destroyed it puts the counter back for us.
meant for weapons used as follows.
auto=teach(creature) countertrack(0/0,1,hand)

when the creature is equipped with this weapon it will remove a hand counter from the creature, when you remove the weapon, or the weapon is destroyed or whatever...it will put a hand counter back on the creature.

added dualwielding thisdescriptor...
auto=this(dualwielding) 2/2
auto=this(dualwielding) firststrike

enabled "restriction{" on phasebased triggers @next and @each...

i will work more on countertrack to extend it to domains if it currently isnt possible to use it in this case(haven't tested it on domains)....
This commit is contained in:
omegablast2002@yahoo.com
2011-09-13 14:33:13 +00:00
parent 713cb2aa45
commit 6ea7e00803
8 changed files with 158 additions and 3 deletions

View File

@@ -2271,7 +2271,8 @@ public:
{ {
if (skills.find(card) != skills.end()) if (skills.find(card) != skills.end())
{ {
game->removeObserver(skills[card]); if(!game->removeObserver(skills[card]))
skills[card]->destroy();
skills.erase(card); skills.erase(card);
} }
return 1; return 1;
@@ -3538,6 +3539,18 @@ public:
ACounterShroud * clone() const; ACounterShroud * clone() const;
~ACounterShroud(); ~ACounterShroud();
}; };
//track an effect using counters.
class ACounterTracker: public MTGAbility
{
public:
Counter * counter;
int removed;
ACounterTracker(int id, MTGCardInstance * source, MTGCardInstance * target, Counter * counter = NULL);
int addToGame();
int destroy();
ACounterTracker * clone() const;
~ACounterTracker();
};
//Remove all abilities from target //Remove all abilities from target
class ALoseAbilities: public MTGAbility class ALoseAbilities: public MTGAbility
{ {

View File

@@ -91,6 +91,7 @@ public:
int fresh; int fresh;
int MaxLevelUp; int MaxLevelUp;
int kicked; int kicked;
bool isDualWielding;
Player * lastController; Player * lastController;
MTGGameZone * getCurrentZone(); MTGGameZone * getCurrentZone();
MTGGameZone * previousZone; MTGGameZone * previousZone;

View File

@@ -133,6 +133,14 @@ class ThisDamaged:public ThisDescriptor{
ThisDamaged * clone() const; ThisDamaged * clone() const;
}; };
class ThisDualWield:public ThisDescriptor{
public:
virtual int match(MTGCardInstance * card);
ThisDualWield(int dualWield);
ThisDualWield * clone() const;
};
class ThisPower:public ThisDescriptor{ class ThisPower:public ThisDescriptor{
public: public:
virtual int match(MTGCardInstance * card); virtual int match(MTGCardInstance * card);

View File

@@ -416,6 +416,60 @@ ACounterShroud::~ACounterShroud()
SAFE_DELETE(counter); SAFE_DELETE(counter);
} }
//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)
{
removed = 0;
}
int ACounterTracker::addToGame()
{
MTGCardInstance * _target = (MTGCardInstance*)target;
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)
{
for(int nb = 0;nb < counter->nb;nb++)
{
_target->counters->removeCounter(counter->name.c_str(),counter->power,counter->toughness);
removed++;
}
}
return 1;
}
return 0;
}
int ACounterTracker::destroy()
{
MTGCardInstance * _target = (MTGCardInstance*)target;
if(_target)
{
if(removed == counter->nb)
{
for(int nb = 0;nb < counter->nb;nb++)
{
_target->counters->addCounter(counter->name.c_str(),counter->power,counter->toughness);
}
}
}
removeFromGame();
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. //removeall counters of a certain type or all.
AARemoveAllCounter::AARemoveAllCounter(int id, MTGCardInstance * source, MTGCardInstance * target, const char * _name, int power, int toughness, AARemoveAllCounter::AARemoveAllCounter(int id, MTGCardInstance * source, MTGCardInstance * target, const char * _name, int power, int toughness,
int nb,bool all, ManaCost * cost) : int nb,bool all, ManaCost * cost) :

View File

@@ -462,6 +462,29 @@ void GameObserver::gameStateBasedEffects()
card->graveEffects = false; card->graveEffects = false;
card->exileEffects = false; card->exileEffects = false;
} }
if(card->childrenCards.size())
{
MTGCardInstance * check = NULL;
MTGCardInstance * matched = NULL;
sort(card->childrenCards.begin(),card->childrenCards.end());
for(unsigned int wC = 0; wC < int(card->childrenCards.size());wC++)
{
check = card->childrenCards[wC];
for(unsigned int wCC = 0; wCC < int(card->childrenCards.size());wCC++)
{
if(check->getName() == card->childrenCards[wCC]->getName() && check != card->childrenCards[wCC])
{
card->isDualWielding = true;
matched = card->childrenCards[wCC];
}
}
if(matched)
wC = card->childrenCards.size();
}
if(!matched)
card->isDualWielding = false;
}
} }
} }
//------------------------------------- //-------------------------------------
@@ -539,7 +562,6 @@ void GameObserver::gameStateBasedEffects()
c->wasDealtDamage = false; c->wasDealtDamage = false;
c->damageToController = false; c->damageToController = false;
c->damageToOpponent = false; c->damageToOpponent = false;
} }
for (int t = 0; t < nbcards; t++) for (int t = 0; t < nbcards; t++)
{ {

View File

@@ -2062,7 +2062,20 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
MTGAbility * a = NEW ACounterShroud(id, card, target,counter); MTGAbility * a = NEW ACounterShroud(id, card, target,counter);
return a; return a;
} }
//use counters to track by counters to track an efect by counter name.
vector<string> splitCounterTracking = parseBetween(s, "countertrack(", ")");
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);
}
//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(", ")");
if (splitRemoveCounter.size()) if (splitRemoveCounter.size())
@@ -4293,9 +4306,20 @@ TriggerAtPhase::TriggerAtPhase(int id, MTGCardInstance * source, Targetable * ta
result = 1; result = 1;
break; break;
} }
if(castRestriction.size())
{
if(!source)
result = 1;//can't check these restrictions without a source aka:in a rule.txt
AbilityFactory af;
int checkCond = af.parseCastRestrictions(source,source->controller(),castRestriction);
if(!checkCond)
result = 0;
}
} }
if(once && activeTrigger) if(once && activeTrigger)
activeTrigger = false; activeTrigger = false;
return result; return result;
} }

View File

@@ -138,6 +138,7 @@ void MTGCardInstance::initMTGCI()
damageToOpponent = false; damageToOpponent = false;
damageToController = false; damageToController = false;
wasDealtDamage = false; wasDealtDamage = false;
isDualWielding = false;
suspended = false; suspended = false;
castMethod = Constants::NOT_CAST; castMethod = Constants::NOT_CAST;
mPropertiesChangedSinceLastUpdate = false; mPropertiesChangedSinceLastUpdate = false;

View File

@@ -253,6 +253,19 @@ ThisDescriptor * ThisDescriptorFactory::createThisDescriptor(string s)
return NULL; return NULL;
} }
//this creature has 2 of the same weapons in its children vector
found = s.find("dualwielding");
if (found != string::npos)
{
ThisDualWield * td = NEW ThisDualWield(criterion);
if (td)
{
td->comparisonMode = mode;
return td;
}
return NULL;
}
//controller life //controller life
found = s.find("opponentlife"); found = s.find("opponentlife");
if (found != string::npos) if (found != string::npos)
@@ -561,6 +574,25 @@ ThisDamaged* ThisDamaged::clone() const
return NEW ThisDamaged(*this); return NEW ThisDamaged(*this);
} }
ThisDualWield::ThisDualWield(int dualWield)
{
comparisonCriterion = dualWield;
}
int ThisDualWield::match(MTGCardInstance * card)
{
int result = 0;
if(card->isDualWielding)
result = 1;
return matchValue(result);
}
ThisDualWield* ThisDualWield::clone() const
{
return NEW ThisDualWield(*this);
}
ThisToughness::ThisToughness(int toughness) ThisToughness::ThisToughness(int toughness)
{ {
comparisonCriterion = toughness; comparisonCriterion = toughness;