Erwan
- Fixed a bug with "must" abilities and the AI, such as Noggle Bridgebreaker
This commit is contained in:
@@ -74,7 +74,7 @@ class AIPlayer: public Player{
|
||||
AIPlayer(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
|
||||
virtual ~AIPlayer();
|
||||
virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0);
|
||||
virtual int chooseTarget(TargetChooser * tc = NULL);
|
||||
virtual int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget =NULL);
|
||||
virtual int Act(float dt);
|
||||
virtual int affectCombatDamages(CombatStep);
|
||||
int isAI(){return 1;};
|
||||
|
||||
@@ -313,8 +313,9 @@ int AIPlayer::effectBadOrGood(MTGCardInstance * card, int mode, TargetChooser *
|
||||
|
||||
|
||||
|
||||
int AIPlayer::chooseTarget(TargetChooser * tc){
|
||||
int AIPlayer::chooseTarget(TargetChooser * _tc, Player * forceTarget){
|
||||
vector<Targetable *>potentialTargets;
|
||||
TargetChooser * tc = _tc;
|
||||
int nbtargets = 0;
|
||||
GameObserver * gameObs = GameObserver::GetInstance();
|
||||
int checkOnly = 0;
|
||||
@@ -325,10 +326,14 @@ int AIPlayer::chooseTarget(TargetChooser * tc){
|
||||
}
|
||||
if (!tc) return 0;
|
||||
if (!(gameObs->currentlyActing() == this)) return 0;
|
||||
Player * target = this;
|
||||
int cardEffect = effectBadOrGood(tc->source, MODE_TARGET, tc);
|
||||
if (cardEffect != BAKA_EFFECT_GOOD){
|
||||
target = this->opponent();
|
||||
Player * target = forceTarget;
|
||||
|
||||
if (!target){
|
||||
target = this;
|
||||
int cardEffect = effectBadOrGood(tc->source, MODE_TARGET, tc);
|
||||
if (cardEffect != BAKA_EFFECT_GOOD){
|
||||
target = this->opponent();
|
||||
}
|
||||
}
|
||||
|
||||
if (!tc->alreadyHasTarget(target) && tc->canTarget(target) && nbtargets < 50){
|
||||
@@ -383,8 +388,13 @@ int AIPlayer::chooseTarget(TargetChooser * tc){
|
||||
}
|
||||
}
|
||||
}
|
||||
//Couldn't find any valid target (why did we play that in the first place ?)
|
||||
gameObs->cancelCurrentAction();
|
||||
//Couldn't find any valid target,
|
||||
//usually that's because we played a card that has bad side effects (ex: when X comes into play, return target land you own to your hand)
|
||||
//so we try again to choose a target in the other player's field...
|
||||
int cancel = gameObs->cancelCurrentAction();
|
||||
if (!cancel && !forceTarget) return chooseTarget(_tc,target->opponent());
|
||||
|
||||
//ERROR!!!
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,8 +135,7 @@ void GameObserver::nextGamePhase(){
|
||||
|
||||
int GameObserver::cancelCurrentAction(){
|
||||
SAFE_DELETE(targetChooser);
|
||||
mLayers->actionLayer()->cancelCurrentAction();
|
||||
return 1;
|
||||
return mLayers->actionLayer()->cancelCurrentAction();
|
||||
}
|
||||
|
||||
void GameObserver::nextCombatStep()
|
||||
|
||||
Reference in New Issue
Block a user