changes:
added abilities:
proliferate
ProliferateChooser:new targetchooser for cards with counter and poison counters "proliferation".
MenuAbility:new internal ability to create custom menus of abilities which can be activated in sequence one after another.
multikicker, syntax kicker=multi{b}
works with variable word "kicked", the amount of times it was kicked.
target=<number>tc,target=<upto:>tc,target=<anyamount>tc,target(<number>tc),target(<upto:>tc),target(<anynumber>tc);
multitarget is now supported with the exception of "devided any way you choose" which can not be supported becuase we allow detoggling of targeted cards with a "second" click....so you can not click the same card 2 times to add it to the targets list twice for example.
this is minor, as the bulk of multitarget is not "devided"
removed 's' parsing for multitarget, added a limit of 1000 to "unlimited" for easier handling; we currently can't handle activation of an ability on a 1000 cards very well on any platform(infact i don't suggest it)
Countershroud(counterstring), this MTGAbility allows you to denote that a card can not have counters of the type "counterstring" put on it.
"any" is for no counters allowed at all. this is a replacement effect. cards state that they can still be the targets of counter effects, however on resolve nothing is placed on them instead.
@counteradded(counterstring) from(target):,@counterremoved(counterstring) from(target):: these are triggers for cards which state "whenever you add a counter of "counterstring" to "target"; added counterEvents struct;
other changes:
added support for ai handling of multitargeted spells.
changed a few of delete( into SAFE_DELETE(, safed up a couple areas where they did not seem safe to me;
added better handling of menus presented to ai, it will try to select the best based on eff returns.
added varible lastactioncontroller for ai use, it keeps it truely from ever tripping over itself and brings ai more inline with MTG rules.
converted TC into a protected member.
added "abilitybelongsto" string to tc, and set "owner" of the tc. a tc should never belong to "no one" it should always have a owner.
abilitybelongs to string is solely for easier debugging, i found it was a pain to never know what ability created a tc while i coded multitarget. the owner of the tc is the only one that should be using it, if an ability needs to declare the opponent as the owner (choose discard which is currently unsupported for example) this will allow us to better handle that situation by setting the tc owner in the ability which called it.
rewrote the logic of "checkonly" in ai choose targets, the only time it is "checkonly" is when it is trying to see if it had a target for a spell before it cast it, i now set this in the actual function call instead, the old method was far to error prone.
wrote logic for ai checking of menu objects presented to it,
ai will now make better choices when a menu is presented to it based on what it already knows. this changes it from it's old method of "just click the first option".
taught ai how to use multi-mana producers such as birds and duel lands by adding a method for it to find it's mana for a payment. it can effectively use cards like birds of paradise and sol ring(without locking up). It's primary method of pMana searching was maintain for performance(no need to deep search if we have it in pMana).
added a vector to actionlayer to store mana abilities for pMana. this provides us with a dramatic improvement when mana lords are present by reducing the amount of objects that need checking when ai checks pMana.
with 80 mana objects and a ton of lords one instance i checked went from 8000ish checks down to 80<===big difference.
added "tapped" green coloring(sorry i missed that!)...added red coloring to current actionLayers current action card (usually the source).
changed "type(" restrictions second amount from atoi into wparsedint for more flexiable coding.
add "&" parsing to CD targetchooser, removed "iscolorandcolor" variables and functions becuase they were a hack the real fix was this.
cretaure[dragon&black&blue] a creature that is a dragon, and black and also blue.
changed some of the ai computeactions and
removed unneeded gaurds in ai chooseblockers, they did more harm then good.
This commit is contained in:
@@ -166,7 +166,11 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card,Player * player
|
||||
}
|
||||
}
|
||||
else if (i == 2)
|
||||
secondAmount = atoi(comparasion[2].c_str());
|
||||
{
|
||||
WParsedInt * secondA = NEW WParsedInt(comparasion[2].c_str(),(Spell*)card,card);
|
||||
secondAmount = secondA->getValue();
|
||||
SAFE_DELETE(secondA);
|
||||
}
|
||||
}
|
||||
if(firstAmount < secondAmount && !less && !more && !equal)
|
||||
return 0;
|
||||
@@ -599,7 +603,23 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string magicText, int
|
||||
TargetChooser *fromTc = parseSimpleTC(s, "from", card);
|
||||
return NEW TrTargeted(id, card, tc, fromTc, 0,once);
|
||||
}
|
||||
|
||||
|
||||
if (s.find("counteradded(") != string::npos)
|
||||
{
|
||||
vector<string>splitCounter = parseBetween(s,"counteradded(",")");
|
||||
Counter * counter = parseCounter(splitCounter[1],card,NULL);
|
||||
TargetChooser * tc = parseSimpleTC(s, "from", card);
|
||||
return NEW TrCounter(id, card, counter, tc, 1,once);
|
||||
}
|
||||
|
||||
if (s.find("counterremoved(") != string::npos)
|
||||
{
|
||||
vector<string>splitCounter = parseBetween(s,"counterremoved(",")");
|
||||
Counter * counter = parseCounter(splitCounter[1],card,NULL);
|
||||
TargetChooser * tc = parseSimpleTC(s, "from", card);
|
||||
return NEW TrCounter(id, card, counter, tc, 0,once);
|
||||
}
|
||||
|
||||
int who = 0;
|
||||
if (s.find("my") != string::npos)
|
||||
who = 1;
|
||||
@@ -699,7 +719,8 @@ MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a)
|
||||
//only atempt to return a nestedability if it contains a valid ability. example where this causes a bug otherwise. AEquip is considered nested, but contains no ability.
|
||||
return getCoreAbility(na->ability);
|
||||
}
|
||||
|
||||
if (MenuAbility * ma = dynamic_cast<MenuAbility*>(a))
|
||||
return ma->abilities[0];
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -878,11 +899,14 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
TargetChooserFactory tcf;
|
||||
tc = tcf.createTargetChooser("creature|mybattlefield", card);
|
||||
}
|
||||
ae->tc = tc;
|
||||
ae->setActionTC(tc);
|
||||
return ae;
|
||||
}
|
||||
if (tc)
|
||||
{
|
||||
tc->belongsToAbility = sWithoutTc;
|
||||
return NEW GenericTargetAbility(newName,id, card, tc, a, cost, limit,sideEffect,usesBeforeSideEffect, restrictions, dest);
|
||||
}
|
||||
return NEW GenericActivatedAbility(newName,id, card, a, cost, limit,sideEffect,usesBeforeSideEffect,restrictions, dest);
|
||||
}
|
||||
SAFE_DELETE(cost);
|
||||
@@ -915,7 +939,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
{
|
||||
string cond = sWithoutTc.substr(ifKeywords[i].length(),ifKeywords[i].length() + sWithoutTc.find(" then ")-6);
|
||||
string s1 = s.substr(s.find(" then ")+6);
|
||||
MTGAbility * a = NEW IfThenAbility(id, s1, card,checkIf[i],cond);
|
||||
MTGAbility * a1 = parseMagicLine(s1, id, spell, card);
|
||||
MTGAbility * a = NEW IfThenAbility(id, a1, card,checkIf[i],cond);
|
||||
a->canBeInterrupted = false;
|
||||
a->oneShot = true;
|
||||
if(tc)
|
||||
@@ -1977,7 +2002,30 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
a->oneShot = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
//no counters on target of optional type
|
||||
vector<string> splitCounterShroud = parseBetween(s, "countershroud(", ")");
|
||||
if (splitCounterShroud.size())
|
||||
{
|
||||
string counterShroudString = splitCounterShroud[1];
|
||||
Counter * counter = NULL;
|
||||
if(splitCounterShroud[1] == "any")
|
||||
{
|
||||
counter = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
counter = parseCounter(counterShroudString, target, spell);
|
||||
if (!counter)
|
||||
{
|
||||
DebugTrace("MTGAbility: can't parse counter:" << s);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
MTGAbility * a = NEW ACounterShroud(id, card, target,counter);
|
||||
return a;
|
||||
}
|
||||
|
||||
//removes all counters of the specifified type.
|
||||
vector<string> splitRemoveCounter = parseBetween(s, "removeallcounters(", ")");
|
||||
if (splitRemoveCounter.size())
|
||||
@@ -2226,6 +2274,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return NULL; //TODO
|
||||
}
|
||||
|
||||
//proliferate
|
||||
found = s.find("proliferate");
|
||||
if (found != string::npos)
|
||||
{
|
||||
MTGAbility * a = NEW AAProliferate(id, card, target);
|
||||
a->oneShot = 1;
|
||||
a->canBeInterrupted = false;
|
||||
return a;
|
||||
}
|
||||
|
||||
//frozen, next untap this does not untap.
|
||||
found = s.find("frozen");
|
||||
if (found != string::npos)
|
||||
@@ -2340,7 +2398,7 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ
|
||||
{
|
||||
if (mode == MODE_PUTINTOPLAY)
|
||||
return BAKA_EFFECT_GOOD;
|
||||
return abilityEfficiency(abi->ability, p, mode, abi->tc);
|
||||
return abilityEfficiency(abi->ability, p, mode, abi->getActionTc());
|
||||
}
|
||||
if (GenericActivatedAbility * abi = dynamic_cast<GenericActivatedAbility*>(a))
|
||||
{
|
||||
@@ -2354,8 +2412,8 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ
|
||||
return abilityEfficiency(abi->ability, p, mode, tc);
|
||||
if (ALord * abi = dynamic_cast<ALord *>(a))
|
||||
{
|
||||
int myCards = countCards(abi->tc, p);
|
||||
int theirCards = countCards(abi->tc, p->opponent());
|
||||
int myCards = countCards(abi->getActionTc(), p);
|
||||
int theirCards = countCards(abi->getActionTc(), p->opponent());
|
||||
int efficiency = abilityEfficiency(abi->ability, p, mode, tc);
|
||||
if ( ((myCards < theirCards) && efficiency == BAKA_EFFECT_GOOD) || ((myCards > theirCards) && efficiency == BAKA_EFFECT_BAD) )
|
||||
return efficiency;
|
||||
@@ -2379,6 +2437,8 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ
|
||||
return BAKA_EFFECT_GOOD;
|
||||
if (dynamic_cast<AATapper *> (a))
|
||||
return BAKA_EFFECT_BAD;
|
||||
if (dynamic_cast<AManaProducer *> (a))
|
||||
return BAKA_EFFECT_GOOD;
|
||||
if (AACounter * ac = dynamic_cast<AACounter *>(a))
|
||||
{
|
||||
bool negative_effect = ac->power < 0 || ac->toughness < 0;
|
||||
@@ -2634,6 +2694,12 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card, int
|
||||
for (size_t i = 0; i < v.size(); ++i)
|
||||
{
|
||||
MTGAbility * a = v[i];
|
||||
if (!a)
|
||||
{
|
||||
DebugTrace("ABILITYFACTORY ERROR: Parser returned NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dryMode)
|
||||
{
|
||||
result = abilityEfficiency(a, card->controller(), mode, tc);
|
||||
@@ -2641,8 +2707,44 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card, int
|
||||
SAFE_DELETE(v[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (a)
|
||||
if(spell && spell->tc && spell->tc->targets.size() > 1 && spell->getNextTarget())
|
||||
a->target = spell->getNextTarget();
|
||||
if(a && a->target && spell && spell->tc && spell->tc->targets.size() > 1)
|
||||
{
|
||||
while(a && a->target)
|
||||
{
|
||||
if(a->oneShot)
|
||||
{
|
||||
a->resolve();
|
||||
}
|
||||
else if(!dynamic_cast<MayAbility*>(a))
|
||||
{
|
||||
MTGAbility * mClone = a->clone();
|
||||
mClone->target = a->target;
|
||||
MTGAbility * core = getCoreAbility(mClone);
|
||||
if (dynamic_cast<AManaProducer*> (core))
|
||||
mClone->canBeInterrupted = false;
|
||||
mClone->addToGame();
|
||||
}
|
||||
else if(dynamic_cast<MayAbility*>(a) && a->target == spell->tc->targets[0])
|
||||
{
|
||||
//only add may/choice/target( menu ability for the first card,
|
||||
//no point in adding "discard" 3 times to a menu, as you can only choose the effect once
|
||||
MTGAbility * mClone = a->clone();
|
||||
mClone->target = a->target;
|
||||
MTGAbility * core = getCoreAbility(mClone);
|
||||
if (dynamic_cast<AManaProducer*> (core))
|
||||
mClone->canBeInterrupted = false;
|
||||
mClone->addToGame();
|
||||
}
|
||||
a->target = spell->getNextTarget(a->target);
|
||||
if(!a->target)
|
||||
{
|
||||
SAFE_DELETE(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a->oneShot)
|
||||
{
|
||||
@@ -2651,18 +2753,9 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card, int
|
||||
}
|
||||
else
|
||||
{
|
||||
// Anything involving Mana Producing abilities cannot be interrupted
|
||||
MTGAbility * core = getCoreAbility(a);
|
||||
if (dynamic_cast<AManaProducer*> (core))
|
||||
a->canBeInterrupted = false;
|
||||
|
||||
a->addToGame();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugTrace("ABILITYFACTORY ERROR: Parser returned NULL");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -3045,13 +3138,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1480: //Energy Tap
|
||||
{
|
||||
card->target->tap();
|
||||
int mana = card->target->getManaCost()->getConvertedCost();
|
||||
game->currentlyActing()->getManaPool()->add(Constants::MTG_COLOR_ARTIFACT, mana);
|
||||
}
|
||||
|
||||
//Addons ICE-AGE Cards
|
||||
|
||||
case 2474: //Minion of Leshrac
|
||||
@@ -3771,9 +3857,28 @@ int TargetAbility::resolve()
|
||||
if (t->typeAsTarget() == TARGET_CARD && ((MTGCardInstance*)t)->isPhased)
|
||||
return 0;
|
||||
if (ability->oneShot)
|
||||
return ability->resolve();
|
||||
MTGAbility * a = ability->clone();
|
||||
return a->addToGame();
|
||||
{
|
||||
while(t)
|
||||
{
|
||||
ability->resolve();
|
||||
t = tc->getNextTarget(t);
|
||||
ability->target = t;
|
||||
}
|
||||
tc->targets.clear();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(t)
|
||||
{
|
||||
MTGAbility * a = ability->clone();
|
||||
a->addToGame();
|
||||
t = tc->getNextTarget(t);
|
||||
ability->target = t;
|
||||
}
|
||||
tc->targets.clear();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -3984,6 +4089,58 @@ void ListMaintainerAbility::updateTargets()
|
||||
|
||||
}
|
||||
|
||||
void ListMaintainerAbility::checkTargets()
|
||||
{
|
||||
//remove invalid ones
|
||||
map<MTGCardInstance *, bool> tempCheck;
|
||||
for (map<MTGCardInstance *, bool>::iterator it = checkCards.begin(); it != checkCards.end(); ++it)
|
||||
{
|
||||
MTGCardInstance * card = (*it).first;
|
||||
if (!canBeInList(card) || card->mPropertiesChangedSinceLastUpdate)
|
||||
{
|
||||
tempCheck[card] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (map<MTGCardInstance *, bool>::iterator it = tempCheck.begin(); it != tempCheck.end(); ++it)
|
||||
{
|
||||
MTGCardInstance * card = (*it).first;
|
||||
checkCards.erase(card);
|
||||
}
|
||||
|
||||
tempCheck.clear();
|
||||
|
||||
//add New valid ones
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Player * p = game->players[i];
|
||||
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library };
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
MTGGameZone * zone = zones[k];
|
||||
if (canTarget(zone))
|
||||
{
|
||||
for (int j = 0; j < zone->nb_cards; j++)
|
||||
{
|
||||
MTGCardInstance * card = zone->cards[j];
|
||||
if (canBeInList(card))
|
||||
{
|
||||
if (checkCards.find(card) == checkCards.end())
|
||||
{
|
||||
tempCheck[card] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (map<MTGCardInstance *, bool>::iterator it = tempCheck.begin(); it != tempCheck.end(); ++it)
|
||||
{
|
||||
MTGCardInstance * card = (*it).first;
|
||||
checkCards[card] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ListMaintainerAbility::Update(float dt)
|
||||
{
|
||||
updateTargets();
|
||||
@@ -4142,7 +4299,7 @@ int GenericTriggeredAbility::triggerOnEvent(WEvent * e)
|
||||
|
||||
Targetable * GenericTriggeredAbility::getTriggerTarget(WEvent * e, MTGAbility * a)
|
||||
{
|
||||
TriggerTargetChooser * ttc = dynamic_cast<TriggerTargetChooser *> (a->tc);
|
||||
TriggerTargetChooser * ttc = dynamic_cast<TriggerTargetChooser *> (a->getActionTc());
|
||||
if (ttc)
|
||||
return e->getTarget(ttc->triggerTarget);
|
||||
|
||||
@@ -4164,7 +4321,7 @@ Targetable * GenericTriggeredAbility::getTriggerTarget(WEvent * e, MTGAbility *
|
||||
|
||||
void GenericTriggeredAbility::setTriggerTargets(Targetable * ta, MTGAbility * a)
|
||||
{
|
||||
TriggerTargetChooser * ttc = dynamic_cast<TriggerTargetChooser *> (a->tc);
|
||||
TriggerTargetChooser * ttc = dynamic_cast<TriggerTargetChooser *> (a->getActionTc());
|
||||
if (ttc)
|
||||
{
|
||||
a->target = ta;
|
||||
@@ -4266,7 +4423,7 @@ int AManaProducer::isReactingToClick(MTGCardInstance * _card, ManaCost * mana)
|
||||
&& (source->hasType(Subtypes::TYPE_LAND) || !tap || !source->hasSummoningSickness()) && !source->isPhased)
|
||||
{
|
||||
ManaCost * cost = getCost();
|
||||
if (!cost || mana->canAfford(cost))
|
||||
if (!cost || (mana->canAfford(cost) && (!cost->extraCosts || cost->extraCosts->canPay())))/*counter cost bypass react to click*/
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user