diff --git a/projects/mtg/include/AIHints.h b/projects/mtg/include/AIHints.h index bc4123877..e0411b64e 100644 --- a/projects/mtg/include/AIHints.h +++ b/projects/mtg/include/AIHints.h @@ -17,6 +17,7 @@ public: string mCondition; string mAction; string mCombatAttackTip; + vectorcastOrder; int mSourceId; AIHint(string line); }; @@ -38,6 +39,7 @@ public: AIHints (AIPlayerBaka * player); AIAction * suggestAbility(ManaCost * potentialMana); bool HintSaysDontAttack(GameObserver* observer,MTGCardInstance * card = NULL); + vector mCastOrder(); void add(string line); ~AIHints(); }; diff --git a/projects/mtg/src/AIHints.cpp b/projects/mtg/src/AIHints.cpp index c4f98c7e0..b4cc119a2 100644 --- a/projects/mtg/src/AIHints.cpp +++ b/projects/mtg/src/AIHints.cpp @@ -37,6 +37,12 @@ AIHint::AIHint(string _line) { mCombatAttackTip = splitDontAttack[1]; } + + vector splitCastOrder = parseBetween(action, "castpriority(", ")"); + if(splitCastOrder.size()) + { + castOrder = split(splitCastOrder[1],','); + } } AIHints::AIHints(AIPlayerBaka * player): mPlayer(player) @@ -88,6 +94,18 @@ bool AIHints::HintSaysDontAttack(GameObserver* observer,MTGCardInstance * card) return false; } +vectorAIHints::mCastOrder() +{ + for(unsigned int i = 0; i < hints.size();i++) + { + if (hints[i]->castOrder.size()) + { + return hints[i]->castOrder; + } + } + return vector(); +} + //return true if a given ability matches a hint's description //Eventually this will look awfully similar to the parser...any way to merge them somehow ? bool AIHints::abilityMatches(MTGAbility * ability, AIHint * hint) @@ -251,7 +269,7 @@ AIAction * AIHints::findAbilityRecursive(AIHint * hint, ManaCost * potentialMana } string s = constraintsNotFulfilled(a, hint, potentialMana); - if (hint->mCombatAttackTip.size()) + if (hint->mCombatAttackTip.size() || hint->castOrder.size()) return NULL; if (s.size()) { diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index f6d38f141..9b7aa5130 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -1910,19 +1910,37 @@ int AIPlayerBaka::computeActions() nextCardToPlay = FindCardToPlay(currentMana, "land"); //look for the most expensive creature we can afford. If not found, try enchantment, then artifact, etc... - const char* types[] = {"planeswalker","creature", "enchantment", "artifact", "sorcery", "instant"}; - int count = 0; - while (!nextCardToPlay && count < 6) + if(hints && hints->mCastOrder().size()) { - if(clickstream.size()) //don't find cards while we have clicking to do. + vectorfindType = hints->mCastOrder(); + for(unsigned int j = 0;j < findType.size();j++) { - SAFE_DELETE(currentMana); - return 0; + if(clickstream.size()) + { + SAFE_DELETE(currentMana); + return 0; + } + nextCardToPlay = FindCardToPlay(currentMana, findType[j].c_str()); + if (game->playRestrictions->canPutIntoZone(nextCardToPlay, game->stack) == PlayRestriction::CANT_PLAY) + nextCardToPlay = NULL; + } + } + else + { + const char* types[] = {"planeswalker","creature", "enchantment", "artifact", "sorcery", "instant"}; + int count = 0; + while (!nextCardToPlay && count < 6) + { + if(clickstream.size()) //don't find cards while we have clicking to do. + { + SAFE_DELETE(currentMana); + return 0; + } + nextCardToPlay = FindCardToPlay(currentMana, types[count]); + if (game->playRestrictions->canPutIntoZone(nextCardToPlay, game->stack) == PlayRestriction::CANT_PLAY) + nextCardToPlay = NULL; + count++; } - nextCardToPlay = FindCardToPlay(currentMana, types[count]); - if (game->playRestrictions->canPutIntoZone(nextCardToPlay, game->stack) == PlayRestriction::CANT_PLAY) - nextCardToPlay = NULL; - count++; } SAFE_DELETE(currentMana);