Files
wagic/projects/mtg/include/GameObserver.h
Xawotihs 9adb9d625d - reworked the testsuite and the rules (storyflow) to use the same game deserialization code, moved that code to the players and zone classes
- removed every references to the gameobserver singleton. This object can now be instantiated several times as it's needed for minmax. To be able to do that, I mostly added a reference to a gameobserver from any targetable object (cards, players, spells) and abilities.
2011-10-01 13:30:30 +00:00

97 lines
2.4 KiB
C++

#ifndef _GAMEOBSERVER_H_
#define _GAMEOBSERVER_H_
#include "Player.h"
#include "MTGAbility.h"
#include "DuelLayers.h"
#include "MTGCardInstance.h"
#include "PlayGuiObject.h"
#include "TargetChooser.h"
#include "PhaseRing.h"
#include "ReplacementEffects.h"
#include "GuiStatic.h"
#include <queue>
#include <time.h>
class MTGGamePhase;
class MTGAbility;
class MTGCardInstance;
struct CardGui;
class Player;
class TargetChooser;
class Rules;
using namespace std;
class GameObserver{
protected:
MTGCardInstance * cardWaitingForTargets;
queue<WEvent *> eventsQueue;
int nbPlayers;
int untap(MTGCardInstance * card);
bool WaitForExtraPayment(MTGCardInstance* card);
void initialize();
public:
int currentPlayerId;
CombatStep combatStep;
int turn;
int forceShuffleLibraries();
int targetListIsSet(MTGCardInstance * card);
PhaseRing * phaseRing;
int cancelCurrentAction();
int currentGamePhase;
ExtraCosts * mExtraPayment;
int oldGamePhase;
TargetChooser * targetChooser;
DuelLayers * mLayers;
ReplacementEffects *replacementEffects;
Player * gameOver;
Player * players[2]; //created outside
time_t startedAt;
Rules * mRules;
TargetChooser * getCurrentTargetChooser();
void stackObjectClicked(Interruptible * action);
int cardClick(MTGCardInstance * card,Targetable * _object = NULL );
int getCurrentGamePhase();
const char * getCurrentGamePhaseName();
const char * getNextGamePhaseName();
void nextCombatStep();
void userRequestNextGamePhase();
void nextGamePhase();
void cleanupPhase();
void nextPlayer();
void setPlayers(Player * _players[], int _nbplayers);
Player * currentPlayer;
Player * currentActionPlayer;
Player * isInterrupting;
Player * opponent();
Player * currentlyActing();
GameObserver();
GameObserver(Player * _players[], int _nbplayers);
~GameObserver();
void gameStateBasedEffects();
void enchantmentStatus();
void Affinity();
void eventOccured();
void addObserver(MTGAbility * observer);
bool removeObserver(ActionElement * observer);
void startGame(Rules * rules);
void untapPhase();
MTGCardInstance * isCardWaiting(){ return cardWaitingForTargets; }
int isInPlay(MTGCardInstance * card);
int isInGrave(MTGCardInstance * card);
int isInExile(MTGCardInstance * card);
void Update(float dt);
void Render();
void ButtonPressed(PlayGuiObject*);
int getPlayersNumber() {return nbPlayers;};
int receiveEvent(WEvent * event);
bool connectRule;
};
#endif