added a new aihint #HINT:dontattackwith(targetchooser)
which tells the ai not to use the targetible cards as attackers, this can be card names, and CD modes.
modified the way ai handles multikicker. it will not be casting 1/1 joragas anymore :D
made WParsedInt ignore "+" signs....
added a new affinity ability...autohand=affinity(creature[vampire]|mygraveyard) ....
this is essentially affinity for creatures in your grave.
added supkeyword to clone clone addtype(zombie)....it adds the type listed to the cards types on clone...
reparse PT bonus on resolve.
reworked bushido, it should now work correctly...aside from that it now excepts word variables...fumiko is now bushido(type:creature[attacking]:battlefield/type:creature[attacking]:battlefield)
added a keyword to access acontrolsteal..the keyword is "steal"
auto=ueot steal target(creature)
reworked persist to handle undying..added the new counter handling rules intruduced by wotc in ISD
added a vector cardsAbilities to mtgcardinstance...this keeps the abilities added to the game for a card to use stored where we can easly alter or remove them.
added an automatic increase to geteff return if the ability is a putinplay ability.
finished coding support for flip and double sided cards, though viewing the "other side" is still not possible yet.
the ability follows the mtg rules.
the ability syntax is flip(card name)...a card can flip into any other card by name...even flip into itself.
added a "canPay() call for Ninja cost...to prevent it from coming up in a menu unless you're in blockers....
added 3 new restriction types that work very similar to type(
thisturn(tc)~morethan~2
lastturn(tc)~lessthan~thisturn(tc)
compare(wordvarible)~equalto~compare(wordvarible)
these are pretty self explanitory.
moved "&&" ability parsing below "this(" allowing "this(" to grant abilities now which contain &&...enclave egologist bug is fixed by this.
fixed an issue with combatspirit link for some reason the way i was doing the bool was not always working.
took care of the todo for AProtectionFrom...you can now give a protection from(blah) in a instant or ueot ability.
added altho very limited right now a "targetedplayer" tc word. i hope to increase this with time.
as always my sidekick doc already has some cards coded for this and test will follow the addition of the cards.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "GuiCombat.h"
|
||||
#include "AIHints.h"
|
||||
#include "ManaCostHybrid.h"
|
||||
#include "MTGRules.h"
|
||||
|
||||
//
|
||||
// AIAction
|
||||
@@ -602,7 +603,10 @@ int OrderedAIAction::getEfficiency()
|
||||
//Decrease chance of using ability if there is an extra cost to use the ability, ignore tap
|
||||
}
|
||||
}
|
||||
|
||||
if (MTGPutInPlayRule * pip = dynamic_cast<MTGPutInPlayRule *>(a))
|
||||
{
|
||||
efficiency += 65;
|
||||
}
|
||||
return efficiency;
|
||||
}
|
||||
|
||||
@@ -714,7 +718,7 @@ bool AIPlayerBaka::payTheManaCost(ManaCost * cost, MTGCardInstance * target,vect
|
||||
}
|
||||
if(k == gotPayments.size()-1)//only add it once, and at the end.
|
||||
paid->add(this->getManaPool());//incase some of our payments were mana already in the pool/.
|
||||
if(paid->canAfford(cost) && (!cost->hasX() || k == gotPayments.size()-1))
|
||||
if(paid->canAfford(cost) && (!cost->hasX() && !cost->hasAnotherCost()) || k == gotPayments.size()-1)
|
||||
{
|
||||
SAFE_DELETE(paid);
|
||||
for(size_t clicking = 0; clicking < clicks.size(); ++clicking)
|
||||
@@ -830,12 +834,12 @@ ManaCost * AIPlayerBaka::getPotentialMana(MTGCardInstance * target)
|
||||
return result;
|
||||
}
|
||||
|
||||
vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost * cost)
|
||||
vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost * cost, map<MTGCardInstance*,bool>usedCards )
|
||||
{
|
||||
if(!cost || (cost && !cost->getConvertedCost()))
|
||||
return vector<MTGAbility*>();
|
||||
ManaCost * result = NEW ManaCost();
|
||||
map<MTGCardInstance *, bool> used;
|
||||
map<MTGCardInstance *, bool> used = usedCards;
|
||||
vector<MTGAbility*>payments = vector<MTGAbility*>();
|
||||
if (this->getManaPool()->getConvertedCost())
|
||||
{
|
||||
@@ -1003,6 +1007,34 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
return payments;//we didn't meet one of the color cost requirements.
|
||||
}
|
||||
}
|
||||
if(cost->kicker && !usedCards.size())
|
||||
{
|
||||
|
||||
ManaCost * withKickerCost= NEW ManaCost(cost->kicker);
|
||||
int canKick = 0;
|
||||
vector<MTGAbility*>kickerPayment;
|
||||
bool keepLooking = true;
|
||||
while(keepLooking)
|
||||
{
|
||||
kickerPayment = canPayMana(target,withKickerCost,used);
|
||||
if(kickerPayment.size())
|
||||
{
|
||||
for(unsigned int w = 0;w < kickerPayment.size();++w)
|
||||
{
|
||||
if(!used[kickerPayment[w]->source])
|
||||
{
|
||||
payments.push_back(kickerPayment[w]);
|
||||
used[kickerPayment[w]->source] = true;
|
||||
}
|
||||
}
|
||||
canKick += 1;
|
||||
keepLooking = cost->kicker->isMulti;
|
||||
}
|
||||
else
|
||||
keepLooking = false;
|
||||
}
|
||||
SAFE_DELETE(withKickerCost);
|
||||
}
|
||||
SAFE_DELETE(check);
|
||||
SAFE_DELETE(checkResult);
|
||||
}
|
||||
@@ -1612,7 +1644,7 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
int currentCost = card->getManaCost()->getConvertedCost();
|
||||
int hasX = card->getManaCost()->hasX();
|
||||
gotPayments.clear();
|
||||
if(!pMana->canAfford(card->getManaCost()))
|
||||
if((!pMana->canAfford(card->getManaCost()) || card->getManaCost()->kicker))
|
||||
gotPayments = canPayMana(card,card->getManaCost());
|
||||
//for preformence reason we only look for specific mana if the payment couldn't be made with pmana.
|
||||
if ((currentCost > maxCost || hasX) && (gotPayments.size() || pMana->canAfford(card->getManaCost())))
|
||||
@@ -1671,8 +1703,6 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
// shouldPlay == baka_effect_bad giving it a 1 for odd ball lottery chance.
|
||||
shouldPlayPercentage = 1;
|
||||
}
|
||||
DebugTrace("Should I play " << (card ? card->name : "Nothing" ) << "?" << endl
|
||||
<<"shouldPlayPercentage = "<< shouldPlayPercentage);
|
||||
|
||||
}
|
||||
//Reduce the chances of playing a spell with X cost if available mana is low
|
||||
@@ -1685,18 +1715,12 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
}
|
||||
if(card->getManaCost() && card->getManaCost()->kicker && card->getManaCost()->kicker->isMulti)
|
||||
{
|
||||
|
||||
ManaCost * withKickerCost= NEW ManaCost(card->getManaCost());
|
||||
withKickerCost->add(withKickerCost->kicker);
|
||||
int canKick = 0;
|
||||
while(pMana->canAfford(withKickerCost))
|
||||
{
|
||||
withKickerCost->add(withKickerCost->kicker);
|
||||
canKick += 1;
|
||||
}
|
||||
SAFE_DELETE(withKickerCost);
|
||||
shouldPlayPercentage = 10*canKick;
|
||||
shouldPlayPercentage = 10* size_t(gotPayments.size())/int(1+(card->getManaCost()->getConvertedCost()+card->getManaCost()->kicker->getConvertedCost()));
|
||||
if(shouldPlayPercentage < 40)
|
||||
shouldPlayPercentage = shouldPlayPercentage/3;
|
||||
}
|
||||
DebugTrace("Should I play " << (card ? card->name : "Nothing" ) << "?" << endl
|
||||
<<"shouldPlayPercentage = "<< shouldPlayPercentage);
|
||||
if(card->getRestrictions().size())
|
||||
{
|
||||
AbilityFactory af(observer);
|
||||
@@ -1708,7 +1732,7 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
int chance = randomChance % 100;
|
||||
if (chance > shouldPlayPercentage)
|
||||
continue;
|
||||
if(shouldPlayPercentage < 10)
|
||||
if(shouldPlayPercentage <= 10)
|
||||
{
|
||||
DebugTrace("shouldPlayPercentage was less than 10 this was a lottery roll on RNG");
|
||||
}
|
||||
@@ -1720,7 +1744,7 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
}
|
||||
if(nextCardToPlay)
|
||||
{
|
||||
if(!pMana->canAfford(nextCardToPlay->getManaCost()))
|
||||
if(!pMana->canAfford(nextCardToPlay->getManaCost()) || nextCardToPlay->getManaCost()->kicker)
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost());
|
||||
DebugTrace(" AI wants to play card." << endl
|
||||
<< "- Next card to play: " << (nextCardToPlay ? nextCardToPlay->name : "None" ) << endl );
|
||||
@@ -2002,6 +2026,8 @@ int AIPlayerBaka::chooseAttackers()
|
||||
MTGCardInstance * card = NULL;
|
||||
while ((card = cd.nextmatch(game->inPlay, card)))
|
||||
{
|
||||
if(hints && hints->HintSaysDontAttack(observer,card))
|
||||
continue;
|
||||
observer->cardClick(card, MTGAbility::MTG_ATTACK_RULE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user