Should fix cross-compilation issue on PSP.
This commit is contained in:
@@ -84,10 +84,10 @@ public:
|
|||||||
{
|
{
|
||||||
};
|
};
|
||||||
int Act();
|
int Act();
|
||||||
ostream& logSimpleAct(ostream& out, MTGCardInstance* click);
|
ostream& logSimpleAct(ostream& out, MTGCardInstance* click) const;
|
||||||
ostream& logMultiAct(ostream& out, vector<Targetable*>& actionTargets);
|
ostream& logMultiAct(ostream& out, const vector<Targetable *> &actionTargets) const;
|
||||||
|
|
||||||
friend ostream& operator<<(ostream& out, AIAction& a);
|
friend ostream& operator<<(ostream& out, const AIAction& a);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -67,8 +67,7 @@ AIAction::AIAction(AIPlayer * owner, MTGCardInstance * c, MTGCardInstance * t)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// should be "const AIAction& " instead, but compiler is annoying to enable that.
|
ostream& operator<<(ostream& out, const AIAction& a)
|
||||||
ostream& operator<<(ostream& out, AIAction& a)
|
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
if (a.player && !a.playerAbilityTarget)
|
if (a.player && !a.playerAbilityTarget)
|
||||||
@@ -153,42 +152,39 @@ int AIAction::Act()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& AIAction::logSimpleAct(ostream& out, MTGCardInstance* click)
|
ostream& AIAction::logSimpleAct(ostream& out, MTGCardInstance* click) const
|
||||||
{
|
{
|
||||||
string currentPlayer = "p" + (owner->getObserver()->getPlayerId(owner) + 1);
|
string currentPlayer = "p" + (owner->getObserver()->getPlayerId(owner) + 1);
|
||||||
out << currentPlayer << click->currentZone->getName() << "[" << click->currentZone->getIndex(click) << "]" << endl;
|
out << currentPlayer << click->currentZone->getName() << "[" << click->currentZone->getIndex(click) << "]" << endl;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& AIAction::logMultiAct(ostream& out, vector<Targetable*>& actionTargets)
|
ostream& AIAction::logMultiAct(ostream& out, const vector<Targetable*>& actionTargets) const
|
||||||
{
|
{
|
||||||
GameObserver * g = owner->getObserver();
|
GameObserver * g = owner->getObserver();
|
||||||
TargetChooser * tc = g->getCurrentTargetChooser();
|
TargetChooser * tc = g->getCurrentTargetChooser();
|
||||||
do {
|
do {
|
||||||
if(!tc) break;
|
if(!tc) break;
|
||||||
vector<Targetable*>::iterator ite = actionTargets.begin();
|
vector<Targetable*>::const_iterator ite = actionTargets.begin();
|
||||||
while(ite != actionTargets.end())
|
while(ite != actionTargets.end())
|
||||||
{
|
{
|
||||||
MTGCardInstance * card = ((MTGCardInstance *) (*ite));
|
MTGCardInstance * card = ((MTGCardInstance *) (*ite));
|
||||||
if(card == (MTGCardInstance*)tc->source)//click source first.
|
if(card == (MTGCardInstance*)tc->source)//click source first.
|
||||||
{
|
{
|
||||||
g->cardClick(card);
|
logSimpleAct(out, card);
|
||||||
ite = actionTargets.erase(ite);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
++ite;
|
++ite;
|
||||||
}
|
}
|
||||||
|
|
||||||
//shuffle to make it less predictable, otherwise ai will always seem to target from right to left. making it very obvious.
|
// this is just wrong, but at least it should compile
|
||||||
owner->getRandomGenerator()->random_shuffle(actionTargets.begin(), actionTargets.end());
|
|
||||||
|
|
||||||
for(int k = 0 ;k < int(actionTargets.size()) && k < tc->maxtargets; k++)
|
for(int k = 0 ;k < int(actionTargets.size()) && k < tc->maxtargets; k++)
|
||||||
{
|
{
|
||||||
if (MTGCardInstance * card = dynamic_cast<MTGCardInstance *>(actionTargets[k]))
|
if (MTGCardInstance * card = dynamic_cast<MTGCardInstance *>(actionTargets[k]))
|
||||||
{
|
{
|
||||||
if(k+1 == int(actionTargets.size()))
|
if(k+1 == int(actionTargets.size()))
|
||||||
tc->done = true;
|
tc->done = true;
|
||||||
g->cardClick(card);
|
logSimpleAct(out, card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tc->attemptsToFill++;
|
tc->attemptsToFill++;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ void AIPlayerMinMax::LookAround()
|
|||||||
|
|
||||||
stringstream stream;
|
stringstream stream;
|
||||||
stream << *observer;
|
stream << *observer;
|
||||||
vector<AIAction>::iterator it;
|
vector<AIAction>::const_iterator it;
|
||||||
for(it = potentialActions.begin(); it != potentialActions.end(); it++)
|
for(it = potentialActions.begin(); it != potentialActions.end(); it++)
|
||||||
{
|
{
|
||||||
stringstream theCommand;
|
stringstream theCommand;
|
||||||
|
|||||||
Reference in New Issue
Block a user