Files
wagic/projects/mtg/src/MTGGamePhase.cpp
Xawotihs c3dc51aed1 I just played 3 long games and I was able to undo two fully and got an assert on the third one after more than 1000 actions... so I commit what I have:
- Modified undo to stop at "next phase" action
- Added "muligan" and "force library shuffling" to the list of logged action
- Fixed random logging
- Fixed double logging of actions
- Merged all the "next game" functions into a single one
- Created a PlayerType type instead of using int
- Moved the player loading code into the GameObserver and out of GameStateDuel to avoid having player references in both and simplify the initialization and termination. Tweeked a bit the humanplayer class to be able to do that.
- Added a "load" menu available in testsuite mode, I use that to load problematique game. To use it, just copy-paste a game from the traces into Res/test/game/timetwister.txt. Game in traces starts by "rvalues:..." and ends by "[end]"
- Added some untested and commented out code in GuiCombat to use the mouse/touch to setup the damage on the blockers
- Broke the network game ... hoh well, I'll repair it when everything else works !!
- various code cleanup and compilation fixes on Linux
2011-10-26 22:14:12 +00:00

73 lines
1.5 KiB
C++

#include "PrecompiledHeader.h"
#include "MTGGamePhase.h"
#include "GuiPhaseBar.h"
MTGGamePhase* MTGGamePhase::instance = 0;
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
instance = this;
}
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;
}