- the AI can now use activated abilities (stupidly though...)
- a few card bugfixes
This commit is contained in:
wagic.the.homebrew
2009-03-01 10:20:31 +00:00
parent 6412c453d1
commit 555eb5ee02
15 changed files with 499 additions and 102 deletions

View File

@@ -9,6 +9,8 @@
#include "Player.h"
#include <queue>
using std::queue;
#define INFO_NBCREATURES 0
#define INFO_CREATURESPOWER 1
@@ -16,13 +18,40 @@
class AIStats;
class AIAction{
protected:
int efficiency;
public:
MTGAbility * ability;
Player * player;
MTGCardInstance * click;
MTGCardInstance * target; // TODO Improve
AIAction(MTGAbility * a, MTGCardInstance * c, MTGCardInstance * t = NULL):ability(a),click(c),target(t){player = NULL; efficiency = -1;};
AIAction(MTGCardInstance * c, MTGCardInstance * t = NULL):click(c),target(t){player = NULL; ability = NULL; efficiency = -1;};
AIAction(Player * p):player(p){ability = NULL; target = NULL; click = NULL; efficiency = -1;};
int getEfficiency();
int Act();
};
class CmpAbilities { // compares Abilities efficiency
public:
bool operator()(AIAction * a1, AIAction * a2) const {
int e1 = a1->getEfficiency();
int e2 = a2->getEfficiency();
if (e1 == e2) return a1 > a2; //TODO improve
return (e1 > e2);
}
};
class AIPlayer: public Player{
protected:
MTGCardInstance * nextCardToPlay;
ManaCost * potentialMana;
queue<AIAction *> clickstream;
void tapLandsForMana(ManaCost * potentialMana, ManaCost * cost);
int checkInterrupt();
int combatDamages();
int interruptIfICan();
int chooseAttackers();
int chooseBlockers();
int effectBadOrGood(MTGCardInstance * card);
@@ -30,7 +59,7 @@ class AIPlayer: public Player{
AIStats * getStats();
public:
void End(){};
virtual int displayStack(){return 0;};
virtual int displayStack(){return 1;};
AIStats * stats;
ManaCost * getPotentialMana();
AIPlayer(MTGPlayerCards * _deck, string deckFile);
@@ -39,6 +68,9 @@ class AIPlayer: public Player{
virtual int chooseTarget(TargetChooser * tc = NULL);
virtual int Act(float dt);
int isAI(){return 1;};
int selectAbility();
int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, map<AIAction *, int,CmpAbilities> * ranking);
int useAbility();
};
@@ -52,6 +84,7 @@ class AIPlayerBaka: public AIPlayer{
AIPlayerBaka(MTGPlayerCards * _deck, char * deckFile, char * avatarFile);
virtual int Act(float dt);
void initTimer();
int computeActions();
};
class AIPlayerFactory{