Just won my first Wagic network game :)
In details: - I removed my player swap idea, it caused tons of issues with randoms - instead I simply keep both peer on the exact same game and added one single parameter allowing to configure the view on the game. So, each peer is rendering the same game (gameObserver class) from a different player point of view (DuelLayers and related classes). - a lot of gui stuff are missing to prevent user forbidden interactions but it works fine on Windows
This commit is contained in:
@@ -29,9 +29,11 @@ protected:
|
||||
GuiAvatars * avatars;
|
||||
GameObserver* observer;
|
||||
MTGGamePhase* phaseHandler;
|
||||
int mPlayerViewIndex;
|
||||
CardSelectorBase* mCardSelector;
|
||||
|
||||
public:
|
||||
DuelLayers();
|
||||
DuelLayers(GameObserver* go, int playerViewIndex = 0);
|
||||
~DuelLayers();
|
||||
|
||||
ActionLayer * actionLayer();
|
||||
@@ -39,7 +41,6 @@ public:
|
||||
GuiCombat * combatLayer();
|
||||
GuiAvatars * GetAvatars();
|
||||
MTGGamePhase* getPhaseHandler() {return phaseHandler;};
|
||||
void init(GameObserver* go);
|
||||
virtual void Update(float dt, Player * player);
|
||||
void CheckUserInput(int isAI);
|
||||
void Render();
|
||||
@@ -47,8 +48,11 @@ public:
|
||||
void Remove();
|
||||
int receiveEvent(WEvent * e);
|
||||
float RightBoundary();
|
||||
|
||||
CardSelectorBase* mCardSelector;
|
||||
int getPlayerViewIndex(){ return mPlayerViewIndex; };
|
||||
Player* getRenderedPlayer();
|
||||
Player* getRenderedPlayerOpponent();
|
||||
CardSelectorBase* getCardSelector() { return mCardSelector; };
|
||||
GameObserver* getObserver(){ return observer; };
|
||||
};
|
||||
|
||||
#include "ActionLayer.h"
|
||||
|
||||
@@ -52,8 +52,8 @@ class GameObserver{
|
||||
string startupGameSerialized;
|
||||
bool parseLine(const string& s);
|
||||
virtual void logAction(const string& s);
|
||||
bool processAction(const string& s, bool swapPlayer = false);
|
||||
bool processActions(bool undo, bool swapPlayer
|
||||
bool processAction(const string& s);
|
||||
bool processActions(bool undo
|
||||
#ifdef TESTSUITE
|
||||
, TestSuiteGame* testgame
|
||||
#endif
|
||||
@@ -143,7 +143,7 @@ class GameObserver{
|
||||
logAction(players[playerId], s);
|
||||
};
|
||||
void logAction(MTGCardInstance* card, MTGGameZone* zone, size_t index, int result);
|
||||
bool load(const string& s, bool undo = false, bool swapPlayers = false
|
||||
bool load(const string& s, bool undo = false, int controlledPlayerIndex = 0
|
||||
#ifdef TESTSUITE
|
||||
, TestSuiteGame* testgame = 0
|
||||
#endif
|
||||
@@ -155,7 +155,7 @@ class GameObserver{
|
||||
bool isStarted() { return (mLayers!=NULL);};
|
||||
RandomGenerator* getRandomGenerator() { return &randomGenerator; };
|
||||
WResourceManager* getResourceManager() { if(this) return mResourceManager;else return 0;};
|
||||
CardSelectorBase* getCardSelector() { return mLayers->mCardSelector;};
|
||||
CardSelectorBase* getCardSelector() { return mLayers->getCardSelector();};
|
||||
bool operator==(const GameObserver& aGame);
|
||||
JGE* getInput(){return mJGE;};
|
||||
DeckManager* getDeckManager(){ return mDeckManager; };
|
||||
@@ -180,6 +180,9 @@ class GameObserver{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
DuelLayers *getView() { return mLayers; };
|
||||
|
||||
};
|
||||
|
||||
#ifdef NETWORK_SUPPORT
|
||||
|
||||
@@ -17,7 +17,7 @@ protected:
|
||||
GuiAvatar* active;
|
||||
|
||||
public:
|
||||
GuiAvatars(GameObserver *observer);
|
||||
GuiAvatars(DuelLayers* duelLayers);
|
||||
~GuiAvatars();
|
||||
|
||||
GuiAvatar* GetSelf();
|
||||
|
||||
@@ -11,12 +11,14 @@
|
||||
|
||||
class GameObserver;
|
||||
class Player;
|
||||
class DuelLayers;
|
||||
|
||||
class GuiLayer
|
||||
{
|
||||
protected:
|
||||
JButton mActionButton;
|
||||
GameObserver* observer;
|
||||
DuelLayers* mpDuelLayers;
|
||||
public:
|
||||
int mCurr;
|
||||
vector<JGuiObject *> mObjects;
|
||||
@@ -28,6 +30,7 @@ public:
|
||||
virtual void resetObjects();
|
||||
int getMaxId();
|
||||
GuiLayer(GameObserver *observer);
|
||||
GuiLayer(DuelLayers *duelLayers);
|
||||
virtual ~GuiLayer();
|
||||
virtual void Update(float dt);
|
||||
virtual bool CheckUserInput(JButton key)
|
||||
|
||||
@@ -11,9 +11,10 @@ protected:
|
||||
Phase* phase;
|
||||
float angle;
|
||||
float zoomFactor;
|
||||
DuelLayers* mpDuelLayers;
|
||||
|
||||
public:
|
||||
GuiPhaseBar(GameObserver* observer);
|
||||
GuiPhaseBar(DuelLayers* duelLayers);
|
||||
~GuiPhaseBar();
|
||||
void Update(float dt);
|
||||
virtual void Render();
|
||||
|
||||
@@ -81,7 +81,7 @@ protected:
|
||||
vector<CardView*> cards;
|
||||
|
||||
public:
|
||||
GuiPlay(GameObserver*);
|
||||
GuiPlay(DuelLayers*);
|
||||
~GuiPlay();
|
||||
virtual void Render();
|
||||
void Replace();
|
||||
|
||||
Reference in New Issue
Block a user