Erwan
- Fix issue #16 (testsuite segfaults if file does not exist) - Fix issue #37 (Normal Combat Damage is not dealt to creatures when the AI attacks) - TestSuite now has an "AI" mode (see test/manual/p2_attacks.txt)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "../include/AIStats.h"
|
||||
#include "../include/AllAbilities.h"
|
||||
#include "../include/ExtraCost.h"
|
||||
#include "../include/GuiCombat.h"
|
||||
|
||||
const char * const MTG_LAND_TEXTS[] = {"artifact","forest","island","mountain","swamp","plains","other lands"};
|
||||
|
||||
@@ -250,13 +251,12 @@ int AIPlayer::selectAbility(){
|
||||
}
|
||||
|
||||
if (ranking.size()){
|
||||
OutputDebugString("We have a winrar\n");
|
||||
AIAction * a = ranking.begin()->first;
|
||||
int chance = 1 + rand() % 100;
|
||||
if (getEfficiency(a) < chance){
|
||||
a = NULL;
|
||||
}else{
|
||||
OutputDebugString("We REALLY have a winner\n");
|
||||
OutputDebugString("AIPlayer:Using Activated ability\n");
|
||||
tapLandsForMana(pMana, a->ability->cost);
|
||||
clickstream.push(a);
|
||||
}
|
||||
@@ -507,8 +507,15 @@ int AIPlayer::orderBlockers(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AIPlayer::affectCombatDamages(CombatStep step){
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
GuiCombat * gc = g->mLayers->combatLayer();
|
||||
for (vector<AttackerDamaged*>::iterator attacker = gc->attackers.begin(); attacker != gc->attackers.end(); ++attacker)
|
||||
gc->autoaffectDamage(*attacker, step);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//TODO: Deprecate combatDamages
|
||||
int AIPlayer::combatDamages(){
|
||||
//int result = 0;
|
||||
GameObserver * gameObs = GameObserver::GetInstance();
|
||||
@@ -736,7 +743,6 @@ int AIPlayerBaka::Act(float dt){
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
|
||||
if (!(g->currentlyActing() == this)){
|
||||
OutputDebugString("Cannot interrupt\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ enum ENUM_DUEL_STATE
|
||||
DUEL_STATE_CANCEL,
|
||||
DUEL_STATE_PLAY,
|
||||
DUEL_STATE_BACK_TO_MAIN_MENU,
|
||||
DUEL_STATE_MENU
|
||||
DUEL_STATE_MENU,
|
||||
DUEL_STATE_ERROR
|
||||
};
|
||||
|
||||
enum ENUM_DUEL_MENUS
|
||||
@@ -275,7 +276,11 @@ void GameStateDuel::Update(float dt)
|
||||
sprintf(buf, "nb cards in player2's graveyard : %i\n",mPlayers[1]->game->graveyard->nb_cards);
|
||||
LOG(buf);
|
||||
}else{
|
||||
mGamePhase = DUEL_STATE_END;
|
||||
if (!game){
|
||||
mGamePhase = DUEL_STATE_ERROR;
|
||||
}else{
|
||||
mGamePhase = DUEL_STATE_END;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -402,6 +407,13 @@ void GameStateDuel::Render()
|
||||
credits->Render();
|
||||
break;
|
||||
}
|
||||
case DUEL_STATE_ERROR:
|
||||
{
|
||||
JRenderer * r = JRenderer::GetInstance();
|
||||
r->ClearScreen(ARGB(200,0,0,0));
|
||||
mFont->DrawString(_("AN ERROR OCCURED, CHECK FILE NAMES").c_str(),0,SCREEN_HEIGHT/2);
|
||||
break;
|
||||
}
|
||||
case DUEL_STATE_CHOOSE_DECK1:
|
||||
case DUEL_STATE_CHOOSE_DECK1_TO_2:
|
||||
case DUEL_STATE_CHOOSE_DECK2:
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "../include/config.h"
|
||||
#include "../include/GameApp.h"
|
||||
#include "../include/GuiCombat.h"
|
||||
#include "../include/AIPlayer.h"
|
||||
#include "Closest.cpp"
|
||||
|
||||
static const float MARGIN = 70;
|
||||
@@ -469,7 +470,7 @@ int GuiCombat::receiveEventMinus(WEvent* e)
|
||||
case DAMAGE: DAMAGE:
|
||||
step = event->step;
|
||||
if (!go->currentPlayer->displayStack()) {
|
||||
//resolve();
|
||||
((AIPlayer *)go->currentPlayer)->affectCombatDamages(step);
|
||||
go->nextGamePhase();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -8,16 +8,18 @@
|
||||
#include <string>
|
||||
using std::string;
|
||||
|
||||
TestSuiteAI::TestSuiteAI(TestSuite * _suite, int playerId):AIPlayer(_suite->buildDeck(playerId),"testsuite", "testsuite"){
|
||||
|
||||
enum ENUM_PLAY_MODE
|
||||
{
|
||||
MODE_TEST_SUITE,
|
||||
MODE_HUMAN,
|
||||
MODE_AI,
|
||||
};
|
||||
|
||||
TestSuiteAI::TestSuiteAI(TestSuite * _suite, int playerId):AIPlayerBaka(_suite->buildDeck(playerId),"testsuite", "testsuite","baka.jpg"){
|
||||
suite = _suite;
|
||||
timer = 0;
|
||||
humanMode = 0;
|
||||
|
||||
mAvatarTex = resources.RetrieveTexture("baka.jpg",RETRIEVE_VRAM,TEXTURE_SUB_AVATAR);
|
||||
if(mAvatarTex)
|
||||
mAvatar = resources.RetrieveQuad("baka.jpg", 0, 0, 35, 50,"bakaAvatar",RETRIEVE_VRAM,TEXTURE_SUB_AVATAR);
|
||||
else
|
||||
mAvatar = NULL;
|
||||
playMode = MODE_TEST_SUITE;
|
||||
|
||||
}
|
||||
|
||||
@@ -58,11 +60,16 @@ Interruptible * TestSuite::getActionByMTGId(int mtgid){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int TestSuiteAI::displayStack(){
|
||||
if (playMode == MODE_AI) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int TestSuiteAI::Act(float dt){
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
g->gameOver = NULL; // Prevent draw rule from losing the game
|
||||
if (humanMode){
|
||||
if (playMode == MODE_AI) return AIPlayerBaka::Act(dt);
|
||||
if (playMode == MODE_HUMAN){
|
||||
g->mLayers->CheckUserInput(0);
|
||||
return 1;
|
||||
}
|
||||
@@ -101,7 +108,12 @@ int TestSuiteAI::Act(float dt){
|
||||
}
|
||||
else if (action.compare("human")==0){
|
||||
OutputDebugString("TESTSUITE You have control");
|
||||
humanMode = 1;
|
||||
playMode = MODE_HUMAN;
|
||||
return 1;
|
||||
}
|
||||
else if (action.compare("ai")==0){
|
||||
OutputDebugString("TESTSUITE Switching to AI");
|
||||
playMode = MODE_AI;
|
||||
return 1;
|
||||
}
|
||||
else if (action.compare("next")==0){
|
||||
|
||||
Reference in New Issue
Block a user