Erwan
- had some problems compiling for the PSP. I assume I was the only one, please let me know if the "include JLogger" lines are not needed (they were needed for me) - Fix a memory leak when playing in "random deck" mode - Prevent the AI from playing cards with a cost it cannot understand (ExtraCosts with a target).
This commit is contained in:
@@ -159,22 +159,28 @@ int AIPlayer::getEfficiency(AIAction * action)
|
||||
return action->getEfficiency();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Can't yet handle extraCost objects (ex: sacrifice) if they require a target :(
|
||||
int AIPlayer::CanHandleCost(ManaCost * cost)
|
||||
{
|
||||
if (!cost) return 1;
|
||||
|
||||
ExtraCosts * ec = cost->extraCosts;
|
||||
if (!ec) return 1;
|
||||
|
||||
for (size_t i = 0; i < ec->costs.size(); ++i)
|
||||
{
|
||||
if (ec->costs[i]->tc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AIPlayer::canHandleCost(MTGAbility * ability)
|
||||
{
|
||||
//Can't handle sacrifice costs that require a target yet :(
|
||||
if (ability->cost)
|
||||
{
|
||||
ExtraCosts * ec = ability->cost->extraCosts;
|
||||
if (ec)
|
||||
{
|
||||
for (size_t i = 0; i < ec->costs.size(); i++)
|
||||
{
|
||||
if (ec->costs[i]->tc)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
return CanHandleCost(ability->cost);
|
||||
}
|
||||
|
||||
int AIAction::getEfficiency()
|
||||
@@ -871,6 +877,8 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
card = NULL;
|
||||
while ((card = cd.nextmatch(game->hand, card)))
|
||||
{
|
||||
if (!CanHandleCost(card->getManaCost()))
|
||||
continue;
|
||||
if (card->hasType(Subtypes::TYPE_CREATURE) && this->castrestrictedcreature < 0 && this->castrestrictedspell < 0)
|
||||
continue;
|
||||
if (card->hasType(Subtypes::TYPE_ENCHANTMENT) && this->castrestrictedspell < 0)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
|
||||
#include <JGE.h>
|
||||
#include <JLogger.h>
|
||||
#include <JRenderer.h>
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#include <time.h>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "Damage.h"
|
||||
#include "Rules.h"
|
||||
#include "ExtraCost.h"
|
||||
|
||||
#include <JLogger.h>
|
||||
#include <JRenderer.h>
|
||||
|
||||
GameObserver * GameObserver::mInstance = NULL;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "PlayerData.h"
|
||||
#include "utils.h"
|
||||
#include "WFont.h"
|
||||
#include <JLogger.h>
|
||||
|
||||
static const char* GAME_VERSION = "WTH?! 0.13.1 - by wololo";
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "MTGAbility.h"
|
||||
#include "DeckManager.h"
|
||||
#include "AIPlayer.h"
|
||||
#include <JLogger.h>
|
||||
|
||||
int Rules::getMTGId(string cardName)
|
||||
{
|
||||
@@ -297,6 +298,7 @@ Player * Rules::loadPlayerRandom(int isAI, int mode)
|
||||
else
|
||||
player = NEW AIPlayerBaka(tempDeck, deckFile, deckFileSmall, "");
|
||||
|
||||
delete tempDeck;
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#include "WFont.h"
|
||||
#include <JLogger.h>
|
||||
|
||||
//#define FORCE_LOW_CACHE_MEMORY
|
||||
const unsigned int kConstrainedCacheLimit = 8 * 1024 * 1024;
|
||||
|
||||
Reference in New Issue
Block a user