added HINT:alwaysattackwith(targetchooser) and HINT:alwaysblockwith(targetchooser)
This commit is contained in:
@@ -19,6 +19,8 @@ public:
|
||||
string mAction;
|
||||
string mCombatAttackTip;
|
||||
string mCombatBlockTip;
|
||||
string mCombatAlwaysBlockTip;
|
||||
string mCombatAlwaysAttackTip;
|
||||
vector<string>castOrder;
|
||||
vector<string>combos;
|
||||
//for preformance we disect the combo on first run.
|
||||
@@ -50,7 +52,9 @@ public:
|
||||
AIHints (AIPlayerBaka * player);
|
||||
AIAction * suggestAbility(ManaCost * potentialMana);
|
||||
bool HintSaysDontAttack(GameObserver* observer,MTGCardInstance * card = NULL);
|
||||
bool HintSaysAlwaysAttack(GameObserver* observer,MTGCardInstance * card = NULL);
|
||||
bool HintSaysDontBlock(GameObserver* observer,MTGCardInstance * card = NULL);
|
||||
bool HintSaysAlwaysBlock(GameObserver* observer,MTGCardInstance * card = NULL);
|
||||
bool HintSaysItsForCombo(GameObserver* observer,MTGCardInstance * card = NULL);
|
||||
bool canWeCombo(GameObserver* observer,MTGCardInstance * card = NULL,AIPlayerBaka * Ai = NULL);
|
||||
vector<string> mCastOrder();
|
||||
|
||||
@@ -36,12 +36,24 @@ AIHint::AIHint(string _line)
|
||||
mCombatAttackTip = splitDontAttack[1];
|
||||
}
|
||||
|
||||
vector<string> splitAlwaysAttack = parseBetween(action, "alwaysattackwith(", ")");
|
||||
if(splitAlwaysAttack.size())
|
||||
{
|
||||
mCombatAlwaysAttackTip = splitAlwaysAttack[1];
|
||||
}
|
||||
|
||||
vector<string> splitDontBlock = parseBetween(action, "dontblockwith(", ")");
|
||||
if(splitDontBlock.size())
|
||||
{
|
||||
mCombatBlockTip = splitDontBlock[1];
|
||||
}
|
||||
|
||||
vector<string> splitAlwaysBlock = parseBetween(action, "alwaysblockwith(", ")");
|
||||
if(splitAlwaysBlock.size())
|
||||
{
|
||||
mCombatAlwaysBlockTip = splitAlwaysBlock[1];
|
||||
}
|
||||
|
||||
vector<string> splitCastOrder = parseBetween(action, "castpriority(", ")");
|
||||
if(splitCastOrder.size())
|
||||
{
|
||||
@@ -106,6 +118,26 @@ bool AIHints::HintSaysDontAttack(GameObserver* observer,MTGCardInstance * card)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AIHints::HintSaysAlwaysAttack(GameObserver* observer,MTGCardInstance * card)
|
||||
{
|
||||
TargetChooserFactory tfc(observer);
|
||||
TargetChooser * hintTc = NULL;
|
||||
for(unsigned int i = 0; i < hints.size();i++)
|
||||
{
|
||||
if (hints[i]->mCombatAlwaysAttackTip.size())
|
||||
{
|
||||
hintTc = tfc.createTargetChooser(hints[i]->mCombatAlwaysAttackTip,card);
|
||||
if(hintTc && hintTc->canTarget(card,true))
|
||||
{
|
||||
SAFE_DELETE(hintTc);
|
||||
return true;
|
||||
}
|
||||
SAFE_DELETE(hintTc);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AIHints::HintSaysDontBlock(GameObserver* observer,MTGCardInstance * card)
|
||||
{
|
||||
TargetChooserFactory tfc(observer);
|
||||
@@ -126,6 +158,26 @@ bool AIHints::HintSaysDontBlock(GameObserver* observer,MTGCardInstance * card)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AIHints::HintSaysAlwaysBlock(GameObserver* observer,MTGCardInstance * card)
|
||||
{
|
||||
TargetChooserFactory tfc(observer);
|
||||
TargetChooser * hintTc = NULL;
|
||||
for(unsigned int i = 0; i < hints.size();i++)
|
||||
{
|
||||
if (hints[i]->mCombatAlwaysBlockTip.size())
|
||||
{
|
||||
hintTc = tfc.createTargetChooser(hints[i]->mCombatAlwaysBlockTip,card);
|
||||
if(hintTc && hintTc->canTarget(card,true))
|
||||
{
|
||||
SAFE_DELETE(hintTc);
|
||||
return true;
|
||||
}
|
||||
SAFE_DELETE(hintTc);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AIHints::HintSaysItsForCombo(GameObserver* observer,MTGCardInstance * card)
|
||||
{
|
||||
TargetChooserFactory tfc(observer);
|
||||
|
||||
@@ -2219,6 +2219,17 @@ int AIPlayerBaka::chooseAttackers()
|
||||
|| (myForce > opponentForce) || (myForce > opponent()->life);
|
||||
}
|
||||
printf("Choose attackers : %i %i %i %i -> %i\n", opponentForce, opponentCreatures, myForce, myCreatures, attack);
|
||||
|
||||
CardDescriptor cd;
|
||||
cd.init();
|
||||
cd.setType("creature");
|
||||
MTGCardInstance * card = NULL;
|
||||
while ((card = cd.nextmatch(game->inPlay, card)))
|
||||
{
|
||||
if(hints && hints->HintSaysAlwaysAttack(observer,card))
|
||||
observer->cardClick(card, MTGAbility::MTG_ATTACK_RULE);
|
||||
}
|
||||
|
||||
if (attack)
|
||||
{
|
||||
CardDescriptor cd;
|
||||
@@ -2238,6 +2249,8 @@ int AIPlayerBaka::chooseAttackers()
|
||||
/* Can I first strike my oponent and get away with murder ? */
|
||||
int AIPlayerBaka::canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy)
|
||||
{
|
||||
if(hints && hints->HintSaysAlwaysBlock(observer,ennemy))
|
||||
return 1;
|
||||
if (ennemy->has(Constants::FIRSTSTRIKE) || ennemy->has(Constants::DOUBLESTRIKE))
|
||||
return 0;
|
||||
if (!(card->has(Constants::FIRSTSTRIKE) || card->has(Constants::DOUBLESTRIKE)))
|
||||
|
||||
Reference in New Issue
Block a user