Erwan
-added possibility for tester to take control of the test suite
This commit is contained in:
@@ -32,7 +32,7 @@ public:
|
|||||||
ActionStack * stackLayer();
|
ActionStack * stackLayer();
|
||||||
void init();
|
void init();
|
||||||
virtual void Update(float dt, Player * player);
|
virtual void Update(float dt, Player * player);
|
||||||
|
void CheckUserInput(int isAI);
|
||||||
void Render();
|
void Render();
|
||||||
void Add(GuiLayer * layer);
|
void Add(GuiLayer * layer);
|
||||||
void Remove();
|
void Remove();
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ class TestSuiteAI:public AIPlayer{
|
|||||||
public:
|
public:
|
||||||
TestSuite * suite;
|
TestSuite * suite;
|
||||||
float timer;
|
float timer;
|
||||||
|
int humanMode;
|
||||||
TestSuiteAI(TestSuite * suite, int playerId);
|
TestSuiteAI(TestSuite * suite, int playerId);
|
||||||
virtual int Act(float dt);
|
virtual int Act(float dt);
|
||||||
virtual int displayStack(){return 1;}
|
virtual int displayStack(){return 1;}
|
||||||
|
|||||||
@@ -43,12 +43,8 @@ void DuelLayers::init(){
|
|||||||
Add(NEW GuiBackground());
|
Add(NEW GuiBackground());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DuelLayers::Update(float dt, Player * currentPlayer)
|
void DuelLayers::CheckUserInput(int isAI){
|
||||||
{
|
|
||||||
for (int i = 0; i < nbitems; ++i) objects[i]->Update(dt);
|
|
||||||
int isAI = currentPlayer->isAI();
|
|
||||||
u32 key;
|
u32 key;
|
||||||
GameObserver * game = GameObserver::GetInstance();
|
|
||||||
while ((key = JGE::GetInstance()->ReadButton())){
|
while ((key = JGE::GetInstance()->ReadButton())){
|
||||||
if ((!isAI) && (0 != key))
|
if ((!isAI) && (0 != key))
|
||||||
{
|
{
|
||||||
@@ -59,7 +55,16 @@ void DuelLayers::Update(float dt, Player * currentPlayer)
|
|||||||
if (cs->CheckUserInput(key)) break;
|
if (cs->CheckUserInput(key)) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DuelLayers::Update(float dt, Player * currentPlayer)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < nbitems; ++i) objects[i]->Update(dt);
|
||||||
|
int isAI = currentPlayer->isAI();
|
||||||
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
if (isAI) currentPlayer->Act(dt);
|
if (isAI) currentPlayer->Act(dt);
|
||||||
|
|
||||||
|
CheckUserInput(isAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionStack * DuelLayers::stackLayer(){
|
ActionStack * DuelLayers::stackLayer(){
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using std::string;
|
|||||||
TestSuiteAI::TestSuiteAI(TestSuite * _suite, int playerId):AIPlayer(_suite->buildDeck(playerId),"testsuite", "testsuite"){
|
TestSuiteAI::TestSuiteAI(TestSuite * _suite, int playerId):AIPlayer(_suite->buildDeck(playerId),"testsuite", "testsuite"){
|
||||||
suite = _suite;
|
suite = _suite;
|
||||||
timer = 0;
|
timer = 0;
|
||||||
|
humanMode = 0;
|
||||||
mAvatarTex = JRenderer::GetInstance()->LoadTexture("ai/baka/avatar.jpg", TEX_TYPE_USE_VRAM);
|
mAvatarTex = JRenderer::GetInstance()->LoadTexture("ai/baka/avatar.jpg", TEX_TYPE_USE_VRAM);
|
||||||
if (mAvatarTex){
|
if (mAvatarTex){
|
||||||
mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50);
|
mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50);
|
||||||
@@ -58,6 +59,12 @@ Interruptible * TestSuite::getActionByMTGId(int mtgid){
|
|||||||
int TestSuiteAI::Act(float dt){
|
int TestSuiteAI::Act(float dt){
|
||||||
GameObserver * g = GameObserver::GetInstance();
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
g->gameOver = NULL; // Prevent draw rule from losing the game
|
g->gameOver = NULL; // Prevent draw rule from losing the game
|
||||||
|
if (humanMode){
|
||||||
|
g->mLayers->CheckUserInput(0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
timer+= dt;
|
timer+= dt;
|
||||||
if (AManaProducer::currentlyTapping || timer < suite->timerLimit) return 1;
|
if (AManaProducer::currentlyTapping || timer < suite->timerLimit) return 1;
|
||||||
timer = 0;
|
timer = 0;
|
||||||
@@ -89,6 +96,11 @@ int TestSuiteAI::Act(float dt){
|
|||||||
if (g->getCurrentGamePhase() != Constants::MTG_PHASE_CLEANUP) suite->currentAction--;
|
if (g->getCurrentGamePhase() != Constants::MTG_PHASE_CLEANUP) suite->currentAction--;
|
||||||
g->userRequestNextGamePhase();
|
g->userRequestNextGamePhase();
|
||||||
}
|
}
|
||||||
|
else if (action.compare("human")==0){
|
||||||
|
OutputDebugString("You have control");
|
||||||
|
humanMode = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
else if (action.compare("next")==0){
|
else if (action.compare("next")==0){
|
||||||
/*
|
/*
|
||||||
if (drl->orderingIsNeeded){
|
if (drl->orderingIsNeeded){
|
||||||
|
|||||||
Reference in New Issue
Block a user