Files
wagic/projects/mtg/src/MTGGamePhase.cpp
Xawotihs 29132073de - Modified DeckManager class to not use a global instance anymore when used within the game engine
- Modified DuelLayers to not use a global MTGPhaseGame instance anymore
- Moved the reset of currentActionCard out of the ActionLayer render function : that fixes the remaing problematic tests in the multithreaded testsuite
- Added a method in ActionLayer converting a card ability into a menu index
- Used this new method in the game observer to log correctly AI ability actions
- Added a DumpAssert method in the game observer, it can be used to dump the game and assert in order to easy crash reproduction
- Cleaned up TargetList properties access
- Added an optimisation in GuiMana to not compute update code if the rendering is not used (multi-threaded mode)
- Added a deadlock detection in the test AI vs AI multithreaded mode
- Fixed minor bugs in test AI vs AI multithreaded mode
- Added a games/second counter in the test AI vs AI rendering
2011-11-23 19:11:48 +00:00

70 lines
1.4 KiB
C++

#include "PrecompiledHeader.h"
#include "MTGGamePhase.h"
#include "GuiPhaseBar.h"
MTGGamePhase::MTGGamePhase(GameObserver* g, int id) :
ActionElement(id), observer(g)
{
animation = 0;
currentState = -1;
mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
mFont->SetBase(0); // using 2nd font
}
void MTGGamePhase::Update(float dt)
{
int newState = observer->getCurrentGamePhase();
if (newState != currentState)
{
activeState = ACTIVE;
animation = 4;
currentState = newState;
}
if (animation > 0)
{
animation--;
}
else
{
activeState = INACTIVE;
animation = 0;
}
}
bool MTGGamePhase::NextGamePhase()
{
if (activeState == INACTIVE)
{
if (observer->currentActionPlayer == observer->currentlyActing())
{
activeState = ACTIVE;
observer->userRequestNextGamePhase();
return true;
}
}
return false;
}
bool MTGGamePhase::CheckUserInput(JButton key)
{
JButton trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_NEXT : JGE_BTN_PREV);
if (trigger == key)
{
return NextGamePhase();
}
return false;
}
MTGGamePhase * MTGGamePhase::clone() const
{
return NEW MTGGamePhase(*this);
}
ostream& MTGGamePhase::toString(ostream& out) const
{
return out << "MTGGamePhase ::: animation " << animation << " ; currentState : " << currentState;
}