-Fix for issue 583 (fireball crash)
-- converted an array into a vector to avoid weird edge cases -- fixed bugs with array "backupTargets"
This commit is contained in:
@@ -1,43 +1,43 @@
|
||||
#ifndef _AIHINTS_H_
|
||||
#define _AIHINTS_H_
|
||||
|
||||
#ifndef _AIHINTS_H_
|
||||
#define _AIHINTS_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
#include "AIPlayer.h"
|
||||
|
||||
class ManaCost;
|
||||
class MTGAbility;
|
||||
|
||||
class AIHint
|
||||
{
|
||||
public:
|
||||
string mCondition;
|
||||
string mAction;
|
||||
int mSourceId;
|
||||
AIHint(string line);
|
||||
};
|
||||
|
||||
|
||||
class AIHints
|
||||
{
|
||||
protected:
|
||||
AIPlayer * mPlayer;
|
||||
vector<AIHint *> hints;
|
||||
AIHint * getByCondition (string condition);
|
||||
AIAction * findAbilityRecursive(AIHint * hint, ManaCost * potentialMana);
|
||||
vector<MTGAbility *> findAbilities(AIHint * hint);
|
||||
RankingContainer findActions(AIHint * hint);
|
||||
string constraintsNotFulfilled(AIAction * a, AIHint * hint, ManaCost * potentialMana);
|
||||
bool findSource(int sourceId);
|
||||
bool abilityMatches(MTGAbility * a, AIHint * hint);
|
||||
public:
|
||||
AIHints (AIPlayer * player);
|
||||
AIAction * suggestAbility(ManaCost * potentialMana);
|
||||
void add(string line);
|
||||
~AIHints();
|
||||
};
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
#include "AIPlayer.h"
|
||||
|
||||
class ManaCost;
|
||||
class MTGAbility;
|
||||
|
||||
class AIHint
|
||||
{
|
||||
public:
|
||||
string mCondition;
|
||||
string mAction;
|
||||
int mSourceId;
|
||||
AIHint(string line);
|
||||
};
|
||||
|
||||
|
||||
class AIHints
|
||||
{
|
||||
protected:
|
||||
AIPlayer * mPlayer;
|
||||
vector<AIHint *> hints;
|
||||
AIHint * getByCondition (string condition);
|
||||
AIAction * findAbilityRecursive(AIHint * hint, ManaCost * potentialMana);
|
||||
vector<MTGAbility *> findAbilities(AIHint * hint);
|
||||
RankingContainer findActions(AIHint * hint);
|
||||
string constraintsNotFulfilled(AIAction * a, AIHint * hint, ManaCost * potentialMana);
|
||||
bool findSource(int sourceId);
|
||||
bool abilityMatches(MTGAbility * a, AIHint * hint);
|
||||
public:
|
||||
AIHints (AIPlayer * player);
|
||||
AIAction * suggestAbility(ManaCost * potentialMana);
|
||||
void add(string line);
|
||||
~AIHints();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
int typeAsTarget(){return TARGET_CARD;}
|
||||
const string getDisplayName() const;
|
||||
MTGCardInstance * target;
|
||||
Targetable * backupTargets[MAX_TARGETS];
|
||||
vector<Targetable *> backupTargets;
|
||||
|
||||
|
||||
//types
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
|
||||
virtual int full()
|
||||
{
|
||||
if (maxtargets != -1 && cursor >= maxtargets)
|
||||
if (maxtargets != -1 && ((int) (targets.size())) >= maxtargets)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
;
|
||||
virtual int ready()
|
||||
{
|
||||
return cursor;
|
||||
return (int) (targets.size());
|
||||
}
|
||||
;
|
||||
virtual ~TargetChooser()
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef _TARGETSLIST_H_
|
||||
#define _TARGETSLIST_H_
|
||||
|
||||
#define MAX_TARGETS 20
|
||||
|
||||
class Targetable;
|
||||
class MTGCardInstance;
|
||||
class Player;
|
||||
@@ -11,13 +9,15 @@ class Spell;
|
||||
class Interruptible;
|
||||
class Damage;
|
||||
|
||||
#include <vector>
|
||||
using std::vector;
|
||||
|
||||
class TargetsList
|
||||
{
|
||||
public:
|
||||
int cursor;
|
||||
TargetsList();
|
||||
TargetsList(Targetable * _targets[], int nbtargets);
|
||||
Targetable* targets[MAX_TARGETS];
|
||||
vector<Targetable*> targets;
|
||||
int alreadyHasTarget(Targetable * target);
|
||||
int removeTarget(Targetable * _card);
|
||||
int toggleTarget(Targetable * _card);
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
Targetable * getNextTarget(Targetable * previous = 0, int type = -1);
|
||||
void initTargets()
|
||||
{
|
||||
cursor = 0;
|
||||
targets.clear();
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user