New descriptive text popup feature for deck selection
http://wololo.net/forum/viewtopic.php?f=13&t=2423
This commit is contained in:
@@ -1,63 +1,75 @@
|
||||
/*
|
||||
A class for very simple menus structure
|
||||
*/
|
||||
#ifndef _DeckMenu_H_
|
||||
#define _DeckMenu_H_
|
||||
|
||||
#include <string>
|
||||
#include "WFont.h"
|
||||
#include "hge/hgeparticle.h"
|
||||
#include "DeckMetaData.h"
|
||||
#include "TextScroller.h"
|
||||
|
||||
class DeckMenu:public JGuiController{
|
||||
protected:
|
||||
|
||||
float mHeight, mWidth, mX, mY;
|
||||
float titleX, titleY, titleWidth;
|
||||
float descX, descY, descHeight, descWidth;
|
||||
float statsX, statsY, statsHeight, statsWidth;
|
||||
float avatarX, avatarY;
|
||||
float starsOffsetX;
|
||||
|
||||
bool menuInitialized;
|
||||
string backgroundName;
|
||||
|
||||
int fontId;
|
||||
string title;
|
||||
string displayTitle;
|
||||
WFont * mFont;
|
||||
float menuFontScale;
|
||||
float titleFontScale;
|
||||
|
||||
int maxItems, startId;
|
||||
|
||||
float selectionT, selectionY;
|
||||
float timeOpen;
|
||||
|
||||
static hgeParticleSystem* stars;
|
||||
|
||||
void initMenuItems();
|
||||
string getDescription();
|
||||
string getMetaInformation();
|
||||
|
||||
public:
|
||||
TextScroller * scroller;
|
||||
bool autoTranslate;
|
||||
DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "", const float& mFontScale = 1.0f );
|
||||
~DeckMenu();
|
||||
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
|
||||
void Close();
|
||||
void updateScroller();
|
||||
void RenderBackground();
|
||||
|
||||
float selectionTargetY;
|
||||
bool closed;
|
||||
static void destroy();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
A class for menus with a fixed layout
|
||||
*/
|
||||
#ifndef _DeckMenu_H_
|
||||
#define _DeckMenu_H_
|
||||
|
||||
#include <string>
|
||||
#include "WFont.h"
|
||||
#include "hge/hgeparticle.h"
|
||||
#include "DeckMetaData.h"
|
||||
#include "TextScroller.h"
|
||||
|
||||
class DeckMenu: public JGuiController
|
||||
{
|
||||
protected:
|
||||
|
||||
float mHeight, mWidth, mX, mY;
|
||||
float titleX, titleY, titleWidth;
|
||||
float descX, descY, descHeight, descWidth;
|
||||
float statsX, statsY, statsHeight, statsWidth;
|
||||
float avatarX, avatarY;
|
||||
float detailedInfoBoxX, detailedInfoBoxY;
|
||||
float starsOffsetX;
|
||||
|
||||
bool menuInitialized;
|
||||
string backgroundName;
|
||||
|
||||
int fontId;
|
||||
string title;
|
||||
string displayTitle;
|
||||
WFont * mFont;
|
||||
float menuFontScale;
|
||||
float titleFontScale;
|
||||
|
||||
int maxItems, startId;
|
||||
|
||||
float selectionT, selectionY;
|
||||
float timeOpen;
|
||||
|
||||
static hgeParticleSystem* stars;
|
||||
|
||||
void initMenuItems();
|
||||
string getDescription();
|
||||
string getMetaInformation();
|
||||
DeckMetaData *selectedDeck;
|
||||
|
||||
public:
|
||||
TextScroller * scroller;
|
||||
bool autoTranslate;
|
||||
|
||||
//used for detailed info button
|
||||
JQuad * pspIcons[8];
|
||||
JTexture * pspIconsTexture;
|
||||
DeckMetaData * getSelectedDeck();
|
||||
bool selectedDeckHasDetails();
|
||||
int selectedDeckId;
|
||||
bool showDetailsScreen;
|
||||
bool enableDetails;
|
||||
float selectionTargetY;
|
||||
bool closed;
|
||||
|
||||
DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "", const int& startIndex = 0, const float& mFontScale = 1.0f);
|
||||
~DeckMenu();
|
||||
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
|
||||
void Close();
|
||||
void updateScroller();
|
||||
void RenderBackground();
|
||||
|
||||
static void destroy();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,89 +1,101 @@
|
||||
#ifndef _DECKSTATS_H_
|
||||
#define _DECKSTATS_H_
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "MTGDefinitions.h"
|
||||
#include <DeckDataWrapper.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Player;
|
||||
class GameObserver;
|
||||
|
||||
class DeckStat{
|
||||
class DeckStat
|
||||
{
|
||||
public:
|
||||
int nbgames;
|
||||
int victories;
|
||||
DeckStat(int _nbgames = 0 , int _victories = 0):nbgames(_nbgames),victories(_victories){};
|
||||
int percentVictories();
|
||||
int nbgames;
|
||||
int victories;
|
||||
DeckStat(int _nbgames = 0, int _victories = 0);
|
||||
int percentVictories();
|
||||
};
|
||||
|
||||
class DeckStats{
|
||||
class DeckStats
|
||||
{
|
||||
protected:
|
||||
static DeckStats * mInstance;
|
||||
static DeckStats * mInstance;
|
||||
public:
|
||||
map<string, DeckStat *>stats;
|
||||
static DeckStats * GetInstance();
|
||||
void saveStats(Player * player, Player * opponent, GameObserver * game);
|
||||
void save(const char * filename);
|
||||
void save(Player * player);
|
||||
void load(const char * filename);
|
||||
void load(Player * player);
|
||||
void cleanStats();
|
||||
~DeckStats();
|
||||
int percentVictories(string opponentsDeckFile);
|
||||
int percentVictories();
|
||||
DeckStat * getDeckStat(string opponentsFile);
|
||||
int nbGames();
|
||||
map<string, DeckStat *> stats;
|
||||
static DeckStats * GetInstance();
|
||||
void saveStats(Player * player, Player * opponent, GameObserver * game);
|
||||
void save(const char * filename);
|
||||
void save(Player * player);
|
||||
void load(const char * filename);
|
||||
void load(Player * player);
|
||||
void cleanStats();
|
||||
~DeckStats();
|
||||
int percentVictories(string opponentsDeckFile);
|
||||
int percentVictories();
|
||||
DeckStat * getDeckStat(string opponentsFile);
|
||||
int nbGames();
|
||||
};
|
||||
|
||||
class StatsWrapper
|
||||
{
|
||||
|
||||
class StatsWrapper {
|
||||
|
||||
public:
|
||||
|
||||
StatsWrapper( int deckId );
|
||||
~StatsWrapper();
|
||||
|
||||
// Stats parameters and status
|
||||
int currentPage;
|
||||
int pageCount;
|
||||
bool needUpdate;
|
||||
|
||||
// Actual stats
|
||||
int percentVictories;
|
||||
int gamesPlayed;
|
||||
int cardCount;
|
||||
int countLands;
|
||||
int totalPrice;
|
||||
int totalManaCost;
|
||||
float avgManaCost;
|
||||
int totalCreatureCost;
|
||||
float avgCreatureCost;
|
||||
int totalSpellCost;
|
||||
float avgSpellCost;
|
||||
int countManaProducers;
|
||||
|
||||
int countCreatures, countSpells, countInstants, countEnchantments, countSorceries, countArtifacts;
|
||||
|
||||
float noLandsProbInTurn[Constants::STATS_FOR_TURNS];
|
||||
float noCreaturesProbInTurn[Constants::STATS_FOR_TURNS];
|
||||
|
||||
int countCardsPerCost[Constants::STATS_MAX_MANA_COST+1];
|
||||
int countCardsPerCostAndColor[Constants::STATS_MAX_MANA_COST+1][Constants::MTG_NB_COLORS+1];
|
||||
int countCreaturesPerCost[Constants::STATS_MAX_MANA_COST+1];
|
||||
int countCreaturesPerCostAndColor[Constants::STATS_MAX_MANA_COST+1][Constants::MTG_NB_COLORS+1];
|
||||
int countSpellsPerCost[Constants::STATS_MAX_MANA_COST+1];
|
||||
int countSpellsPerCostAndColor[Constants::STATS_MAX_MANA_COST+1][Constants::MTG_NB_COLORS+1];
|
||||
int countLandsPerColor[Constants::MTG_NB_COLORS+1];
|
||||
int countBasicLandsPerColor[Constants::MTG_NB_COLORS+1];
|
||||
int countNonLandProducersPerColor[Constants::MTG_NB_COLORS+1];
|
||||
int totalCostPerColor[Constants::MTG_NB_COLORS+1];
|
||||
int totalColoredSymbols;
|
||||
|
||||
vector<string> aiDeckNames;
|
||||
vector<DeckStat*> aiDeckStats;
|
||||
};
|
||||
public:
|
||||
|
||||
StatsWrapper(int deckId);
|
||||
StatsWrapper(string filename);
|
||||
~StatsWrapper();
|
||||
|
||||
void initStatistics(string deckstats);
|
||||
|
||||
// Stats parameters and status
|
||||
int mDeckId;
|
||||
int currentPage;
|
||||
int pageCount;
|
||||
bool needUpdate;
|
||||
|
||||
// Actual stats
|
||||
int percentVictories;
|
||||
int gamesPlayed;
|
||||
int cardCount;
|
||||
int countLands;
|
||||
int totalPrice;
|
||||
int totalManaCost;
|
||||
float avgManaCost;
|
||||
int totalCreatureCost;
|
||||
float avgCreatureCost;
|
||||
int totalSpellCost;
|
||||
float avgSpellCost;
|
||||
int countManaProducers;
|
||||
|
||||
int countCreatures, countSpells, countInstants, countEnchantments, countSorceries, countArtifacts;
|
||||
|
||||
float noLandsProbInTurn[Constants::STATS_FOR_TURNS];
|
||||
float noCreaturesProbInTurn[Constants::STATS_FOR_TURNS];
|
||||
|
||||
int countCardsPerCost[Constants::STATS_MAX_MANA_COST + 1];
|
||||
int countCardsPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
|
||||
int countCreaturesPerCost[Constants::STATS_MAX_MANA_COST + 1];
|
||||
int countCreaturesPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
|
||||
int countSpellsPerCost[Constants::STATS_MAX_MANA_COST + 1];
|
||||
int countSpellsPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
|
||||
int countLandsPerColor[Constants::MTG_NB_COLORS + 1];
|
||||
int countBasicLandsPerColor[Constants::MTG_NB_COLORS + 1];
|
||||
int countNonLandProducersPerColor[Constants::MTG_NB_COLORS + 1];
|
||||
int totalCostPerColor[Constants::MTG_NB_COLORS + 1];
|
||||
int totalColoredSymbols;
|
||||
|
||||
void updateStats(string filename, MTGAllCards * collection);
|
||||
void updateStats(DeckDataWrapper *mtgDeck);
|
||||
int countCardsByType(const char * _type, DeckDataWrapper * myDeck);
|
||||
float noLuck(int n, int a, int x);
|
||||
|
||||
vector<string> aiDeckNames;
|
||||
vector<DeckStat*> aiDeckStats;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,157 +1,156 @@
|
||||
#ifndef _GAME_STATE_DECK_VIEWER_H_
|
||||
#define _GAME_STATE_DECK_VIEWER_H_
|
||||
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <JGE.h>
|
||||
|
||||
#include "GameState.h"
|
||||
#include "DeckEditorMenu.h"
|
||||
#include "SimpleMenu.h"
|
||||
#include "WResourceManager.h"
|
||||
#include "CardGui.h"
|
||||
#include "GameOptions.h"
|
||||
#include "PriceList.h"
|
||||
#include "PlayerData.h"
|
||||
#include "DeckDataWrapper.h"
|
||||
#include "DeckStats.h"
|
||||
#include "WDataSrc.h"
|
||||
#include "WGui.h"
|
||||
|
||||
#define NO_USER_ACTIVITY_HELP_DELAY 10
|
||||
#define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1
|
||||
|
||||
enum
|
||||
{
|
||||
STAGE_TRANSITION_RIGHT = 0,
|
||||
STAGE_TRANSITION_LEFT = 1,
|
||||
STAGE_WAITING = 2,
|
||||
STAGE_TRANSITION_UP = 3,
|
||||
STAGE_TRANSITION_DOWN = 4,
|
||||
STAGE_ONSCREEN_MENU = 5,
|
||||
STAGE_WELCOME = 6,
|
||||
STAGE_MENU = 7,
|
||||
STAGE_FILTERS = 8
|
||||
};
|
||||
|
||||
|
||||
// TODO: need a better name for MENU_FIRST_MENU, this is reused for the 1st submenu of
|
||||
// available options in the duel menu
|
||||
enum
|
||||
{
|
||||
MENU_CARD_PURCHASE = 2,
|
||||
MENU_DECK_SELECTION = 10,
|
||||
MENU_DECK_BUILDER = 11,
|
||||
MENU_FIRST_DUEL_SUBMENU = 102,
|
||||
MENU_LANGUAGE_SELECTION = 103,
|
||||
};
|
||||
|
||||
// enums for menu options
|
||||
// TODO: make these enums a little more descriptive. (ie should reflect what menu they are attached to )
|
||||
enum DECK_VIEWER_MENU_ITEMS
|
||||
{
|
||||
MENU_ITEM_NEW_DECK = -30,
|
||||
MENU_ITEM_CHEAT_MODE = -12,
|
||||
MENU_ITEM_CANCEL = kCancelMenuID,
|
||||
MENU_ITEM_SAVE_RETURN_MAIN_MENU = 0,
|
||||
MENU_ITEM_SAVE_RENAME = 1,
|
||||
MENU_ITEM_SWITCH_DECKS_NO_SAVE = 2,
|
||||
MENU_ITEM_MAIN_MENU = 3,
|
||||
MENU_ITEM_EDITOR_CANCEL = kCancelMenuID,
|
||||
MENU_ITEM_SAVE_AS_AI_DECK = 5,
|
||||
MENU_ITEM_YES = 20,
|
||||
MENU_ITEM_NO = 21,
|
||||
MENU_ITEM_FILTER_BY = 22
|
||||
|
||||
|
||||
};
|
||||
|
||||
#define ALL_COLORS -1
|
||||
|
||||
#define ROTATE_LEFT 1;
|
||||
#define ROTATE_RIGHT 0;
|
||||
|
||||
#define HIGH_SPEED 15.0
|
||||
#define MED_SPEED 5.0f
|
||||
#define LOW_SPEED 1.5
|
||||
|
||||
#define MAX_SAVED_FILTERS 8
|
||||
|
||||
class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
JQuad * mIcons[7];
|
||||
JQuad * pspIcons[8];
|
||||
JTexture * pspIconsTexture;
|
||||
float last_user_activity;
|
||||
float onScreenTransition;
|
||||
float mRotation;
|
||||
float mSlide;
|
||||
int mAlpha;
|
||||
int mStage;
|
||||
int nbDecks;
|
||||
int deckNum;
|
||||
int useFilter;
|
||||
JMusic * bgMusic;
|
||||
JQuad * backQuad;
|
||||
int lastPos;
|
||||
int lastTotal;
|
||||
|
||||
WGuiFilters * filterMenu;
|
||||
WSrcDeckViewer * source;
|
||||
|
||||
DeckEditorMenu * welcome_menu;
|
||||
SimpleMenu * subMenu;
|
||||
DeckEditorMenu * menu;
|
||||
PriceList* pricelist;
|
||||
PlayerData * playerdata;
|
||||
int price;
|
||||
DeckDataWrapper * displayed_deck;
|
||||
DeckDataWrapper * myDeck;
|
||||
DeckDataWrapper * myCollection;
|
||||
MTGCard * cardIndex[7];
|
||||
StatsWrapper *stw;
|
||||
|
||||
int hudAlpha;
|
||||
string newDeckname;
|
||||
bool isAIDeckSave;
|
||||
bool mSwitching;
|
||||
void saveDeck(); //Saves the deck and additional necessary information
|
||||
void saveAsAIDeck(string deckName); // saves deck as an AI Deck
|
||||
int getCurrentPos();
|
||||
|
||||
public:
|
||||
GameStateDeckViewer(GameApp* parent);
|
||||
virtual ~GameStateDeckViewer();
|
||||
void updateDecks();
|
||||
void rotateCards(int direction);
|
||||
void loadIndexes();
|
||||
void updateFilters();
|
||||
void rebuildFilters();
|
||||
void switchDisplay();
|
||||
void Start();
|
||||
virtual void End();
|
||||
void addRemove(MTGCard * card);
|
||||
virtual void Update(float dt);
|
||||
void renderOnScreenBasicInfo();
|
||||
void renderSlideBar();
|
||||
void renderDeckBackground();
|
||||
void renderOnScreenMenu();
|
||||
virtual void renderCard(int id, float rotation);
|
||||
virtual void renderCard (int id);
|
||||
virtual void Render();
|
||||
int loadDeck(int deckid);
|
||||
void LoadDeckStatistics(int deckId);
|
||||
|
||||
void buildEditorMenu();
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
void updateStats();
|
||||
int countCardsByType(const char * _type);
|
||||
};
|
||||
|
||||
// n cards total, a of them are desired, x drawn
|
||||
// returns probability of no A's
|
||||
float noLuck(int n, int a, int x);
|
||||
|
||||
#endif
|
||||
#ifndef _GAME_STATE_DECK_VIEWER_H_
|
||||
#define _GAME_STATE_DECK_VIEWER_H_
|
||||
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <JGE.h>
|
||||
|
||||
#include "GameState.h"
|
||||
#include "DeckEditorMenu.h"
|
||||
#include "SimpleMenu.h"
|
||||
#include "WResourceManager.h"
|
||||
#include "CardGui.h"
|
||||
#include "GameOptions.h"
|
||||
#include "PriceList.h"
|
||||
#include "PlayerData.h"
|
||||
#include "DeckDataWrapper.h"
|
||||
#include "DeckStats.h"
|
||||
#include "WDataSrc.h"
|
||||
#include "WGui.h"
|
||||
|
||||
#define NO_USER_ACTIVITY_HELP_DELAY 10
|
||||
#define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1
|
||||
|
||||
enum
|
||||
{
|
||||
STAGE_TRANSITION_RIGHT = 0,
|
||||
STAGE_TRANSITION_LEFT = 1,
|
||||
STAGE_WAITING = 2,
|
||||
STAGE_TRANSITION_UP = 3,
|
||||
STAGE_TRANSITION_DOWN = 4,
|
||||
STAGE_ONSCREEN_MENU = 5,
|
||||
STAGE_WELCOME = 6,
|
||||
STAGE_MENU = 7,
|
||||
STAGE_FILTERS = 8
|
||||
};
|
||||
|
||||
// TODO: need a better name for MENU_FIRST_MENU, this is reused for the 1st submenu of
|
||||
// available options in the duel menu
|
||||
enum
|
||||
{
|
||||
MENU_CARD_PURCHASE = 2,
|
||||
MENU_DECK_SELECTION = 10,
|
||||
MENU_DECK_BUILDER = 11,
|
||||
MENU_FIRST_DUEL_SUBMENU = 102,
|
||||
MENU_LANGUAGE_SELECTION = 103,
|
||||
};
|
||||
|
||||
// enums for menu options
|
||||
// TODO: make these enums a little more descriptive. (ie should reflect what menu they are attached to )
|
||||
enum DECK_VIEWER_MENU_ITEMS
|
||||
{
|
||||
MENU_ITEM_NEW_DECK = -30,
|
||||
MENU_ITEM_CHEAT_MODE = -12,
|
||||
MENU_ITEM_CANCEL = kCancelMenuID,
|
||||
MENU_ITEM_SAVE_RETURN_MAIN_MENU = 0,
|
||||
MENU_ITEM_SAVE_RENAME = 1,
|
||||
MENU_ITEM_SWITCH_DECKS_NO_SAVE = 2,
|
||||
MENU_ITEM_MAIN_MENU = 3,
|
||||
MENU_ITEM_EDITOR_CANCEL = kCancelMenuID,
|
||||
MENU_ITEM_SAVE_AS_AI_DECK = 5,
|
||||
MENU_ITEM_YES = 20,
|
||||
MENU_ITEM_NO = 21,
|
||||
MENU_ITEM_FILTER_BY = 22,
|
||||
MENUITEM_MORE_INFO = kInfoMenuID
|
||||
|
||||
};
|
||||
|
||||
#define ALL_COLORS -1
|
||||
|
||||
#define ROTATE_LEFT 1;
|
||||
#define ROTATE_RIGHT 0;
|
||||
|
||||
#define HIGH_SPEED 15.0
|
||||
#define MED_SPEED 5.0f
|
||||
#define LOW_SPEED 1.5
|
||||
|
||||
#define MAX_SAVED_FILTERS 8
|
||||
|
||||
class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
JQuad * mIcons[7];
|
||||
JQuad * pspIcons[8];
|
||||
JTexture * pspIconsTexture;
|
||||
float last_user_activity;
|
||||
float onScreenTransition;
|
||||
float mRotation;
|
||||
float mSlide;
|
||||
int mAlpha;
|
||||
int mStage;
|
||||
int nbDecks;
|
||||
int deckNum;
|
||||
int useFilter;
|
||||
JMusic * bgMusic;
|
||||
JQuad * backQuad;
|
||||
int lastPos;
|
||||
int lastTotal;
|
||||
|
||||
WGuiFilters * filterMenu;
|
||||
WSrcDeckViewer * source;
|
||||
|
||||
DeckEditorMenu * welcome_menu;
|
||||
SimpleMenu * subMenu;
|
||||
DeckEditorMenu * menu;
|
||||
PriceList* pricelist;
|
||||
PlayerData * playerdata;
|
||||
int price;
|
||||
DeckDataWrapper * displayed_deck;
|
||||
DeckDataWrapper * myDeck;
|
||||
DeckDataWrapper * myCollection;
|
||||
MTGCard * cardIndex[7];
|
||||
StatsWrapper *stw;
|
||||
|
||||
int hudAlpha;
|
||||
string newDeckname;
|
||||
bool isAIDeckSave;
|
||||
bool mSwitching;
|
||||
void saveDeck(); //Saves the deck and additional necessary information
|
||||
void saveAsAIDeck(string deckName); // saves deck as an AI Deck
|
||||
int getCurrentPos();
|
||||
|
||||
public:
|
||||
GameStateDeckViewer(GameApp* parent);
|
||||
virtual ~GameStateDeckViewer();
|
||||
void updateDecks();
|
||||
void rotateCards(int direction);
|
||||
void loadIndexes();
|
||||
void updateFilters();
|
||||
void rebuildFilters();
|
||||
void switchDisplay();
|
||||
void Start();
|
||||
virtual void End();
|
||||
void addRemove(MTGCard * card);
|
||||
virtual void Update(float dt);
|
||||
void renderOnScreenBasicInfo();
|
||||
void renderSlideBar();
|
||||
void renderDeckBackground();
|
||||
void renderOnScreenMenu();
|
||||
virtual void renderCard(int id, float rotation);
|
||||
virtual void renderCard(int id);
|
||||
virtual void Render();
|
||||
int loadDeck(int deckid);
|
||||
void LoadDeckStatistics(int deckId);
|
||||
|
||||
void buildEditorMenu();
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
void updateStats();
|
||||
int countCardsByType(const char * _type);
|
||||
};
|
||||
|
||||
// n cards total, a of them are desired, x drawn
|
||||
// returns probability of no A's
|
||||
float noLuck(int n, int a, int x);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,73 +1,76 @@
|
||||
#ifndef _GAME_STATE_DUEL_H_
|
||||
#define _GAME_STATE_DUEL_H_
|
||||
|
||||
|
||||
#include "GameState.h"
|
||||
#include "SimpleMenu.h"
|
||||
#include "DeckMenu.h"
|
||||
#include "MTGDeck.h"
|
||||
#include "GameObserver.h"
|
||||
|
||||
#define CHOOSE_OPPONENT 7
|
||||
|
||||
#ifdef TESTSUITE
|
||||
class TestSuite;
|
||||
#endif
|
||||
class Credits;
|
||||
class Rules;
|
||||
|
||||
|
||||
class GameStateDuel: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
#ifdef TESTSUITE
|
||||
TestSuite * testSuite;
|
||||
#endif
|
||||
Credits * credits;
|
||||
int mGamePhase;
|
||||
Player * mCurrentPlayer;
|
||||
Player * mPlayers[2];
|
||||
MTGPlayerCards * deck[2];
|
||||
GameObserver * game;
|
||||
DeckMenu * deckmenu;
|
||||
DeckMenu * opponentMenu;
|
||||
SimpleMenu * menu;
|
||||
bool premadeDeck;
|
||||
int OpponentsDeckid;
|
||||
string musictrack;
|
||||
Rules * rules;
|
||||
|
||||
bool MusicExist(string FileName);
|
||||
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
|
||||
void ensureOpponentMenu(); //loads the opponentMenu if it doesn't exist
|
||||
void initScroller();
|
||||
|
||||
public:
|
||||
GameStateDuel(GameApp* parent);
|
||||
virtual ~GameStateDuel();
|
||||
#ifdef TESTSUITE
|
||||
void loadTestSuitePlayers();
|
||||
#endif
|
||||
virtual void ButtonPressed(int ControllerId, int ControlId);
|
||||
virtual void Start();
|
||||
virtual void End();
|
||||
virtual void Update(float dt);
|
||||
virtual void Render();
|
||||
void initRand (unsigned seed = 0);
|
||||
|
||||
enum ENUM_DUEL_STATE_MENU_ITEM
|
||||
{
|
||||
MENUITEM_CANCEL = kCancelMenuID,
|
||||
MENUITEM_NEW_DECK = -10,
|
||||
MENUITEM_RANDOM_PLAYER = -11,
|
||||
MENUITEM_RANDOM_AI = -12,
|
||||
MENUITEM_MAIN_MENU = -13,
|
||||
MENUITEM_EVIL_TWIN = -14,
|
||||
MENUITEM_MULLIGAN = -15
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _GAME_STATE_DUEL_H_
|
||||
#define _GAME_STATE_DUEL_H_
|
||||
|
||||
#include "GameState.h"
|
||||
#include "SimpleMenu.h"
|
||||
#include "SimplePopup.h"
|
||||
#include "DeckMenu.h"
|
||||
#include "MTGDeck.h"
|
||||
#include "GameObserver.h"
|
||||
|
||||
#define CHOOSE_OPPONENT 7
|
||||
|
||||
#ifdef TESTSUITE
|
||||
class TestSuite;
|
||||
#endif
|
||||
class Credits;
|
||||
class Rules;
|
||||
|
||||
class GameStateDuel: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
#ifdef TESTSUITE
|
||||
TestSuite * testSuite;
|
||||
#endif
|
||||
Credits * credits;
|
||||
int mGamePhase;
|
||||
Player * mCurrentPlayer;
|
||||
Player * mPlayers[2];
|
||||
MTGPlayerCards * deck[2];
|
||||
GameObserver * game;
|
||||
DeckMenu * deckmenu;
|
||||
DeckMenu * opponentMenu;
|
||||
SimpleMenu * menu;
|
||||
SimplePopup * popupScreen; // used for informational screens, modal
|
||||
static int selectedPlayerDeckId;
|
||||
static int selectedAIDeckId;
|
||||
|
||||
bool premadeDeck;
|
||||
int OpponentsDeckid;
|
||||
string musictrack;
|
||||
Rules * rules;
|
||||
|
||||
bool MusicExist(string FileName);
|
||||
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
|
||||
void ensureOpponentMenu(); //loads the opponentMenu if it doesn't exist
|
||||
void initScroller();
|
||||
|
||||
public:
|
||||
GameStateDuel(GameApp* parent);
|
||||
virtual ~GameStateDuel();
|
||||
#ifdef TESTSUITE
|
||||
void loadTestSuitePlayers();
|
||||
#endif
|
||||
virtual void ButtonPressed(int ControllerId, int ControlId);
|
||||
virtual void Start();
|
||||
virtual void End();
|
||||
virtual void Update(float dt);
|
||||
virtual void Render();
|
||||
void initRand(unsigned seed = 0);
|
||||
|
||||
enum ENUM_DUEL_STATE_MENU_ITEM
|
||||
{
|
||||
MENUITEM_CANCEL = kCancelMenuID,
|
||||
MENUITEM_NEW_DECK = -10,
|
||||
MENUITEM_RANDOM_PLAYER = -11,
|
||||
MENUITEM_RANDOM_AI = -12,
|
||||
MENUITEM_MAIN_MENU = -13,
|
||||
MENUITEM_EVIL_TWIN = -14,
|
||||
MENUITEM_MULLIGAN = -15,
|
||||
MENUITEM_MORE_INFO = kInfoMenuID
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,78 +1,102 @@
|
||||
#ifndef _PLAYER_H_
|
||||
#define _PLAYER_H_
|
||||
|
||||
#include "JGE.h"
|
||||
#include "MTGGameZones.h"
|
||||
#include "Damage.h"
|
||||
#include "Targetable.h"
|
||||
|
||||
class MTGDeck;
|
||||
class MTGPlayerCards;
|
||||
class MTGInPlay;
|
||||
class ManaPool;
|
||||
|
||||
class Player: public Damageable{
|
||||
protected:
|
||||
ManaPool * manaPool;
|
||||
|
||||
public:
|
||||
enum ENUM_PLAY_MODE
|
||||
{
|
||||
MODE_TEST_SUITE,
|
||||
MODE_HUMAN,
|
||||
MODE_AI,
|
||||
};
|
||||
|
||||
|
||||
virtual void End();
|
||||
int typeAsTarget(){return TARGET_PLAYER;}
|
||||
const string getDisplayName() const;
|
||||
virtual int displayStack(){return 1;}
|
||||
JTexture * mAvatarTex;
|
||||
JQuad * mAvatar;
|
||||
int playMode;
|
||||
int canPutLandsIntoPlay;
|
||||
int nomaxhandsize;
|
||||
int castedspellsthisturn;
|
||||
int onlyonecast;
|
||||
int castcount;
|
||||
int nocreatureinstant;
|
||||
int nospellinstant;
|
||||
int onlyoneinstant;
|
||||
int castrestrictedcreature;
|
||||
int castrestrictedspell;
|
||||
MTGPlayerCards * game;
|
||||
int afterDamage();
|
||||
int poisoned();
|
||||
int damaged();
|
||||
int prevented();
|
||||
Player(MTGDeck * deck, string deckFile, string deckFileSmall);
|
||||
virtual ~Player();
|
||||
void unTapPhase();
|
||||
MTGInPlay * inPlay();
|
||||
ManaPool * getManaPool();
|
||||
void cleanupPhase();
|
||||
virtual int Act(float dt){return 0;};
|
||||
virtual int isAI(){return 0;};
|
||||
Player * opponent();
|
||||
int getId();
|
||||
JQuad * getIcon();
|
||||
string deckFile;
|
||||
string deckFileSmall;
|
||||
string deckName;
|
||||
|
||||
virtual int receiveEvent(WEvent * event){return 0;};
|
||||
virtual void Render(){};
|
||||
void loadAvatar(string file);
|
||||
};
|
||||
|
||||
class HumanPlayer: public Player{
|
||||
public:
|
||||
HumanPlayer(MTGDeck * deck, string deckFile, string deckFileSmall);
|
||||
HumanPlayer(string deckFile);
|
||||
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream&, const Player&);
|
||||
|
||||
#endif
|
||||
#ifndef _PLAYER_H_
|
||||
#define _PLAYER_H_
|
||||
|
||||
#include "JGE.h"
|
||||
#include "MTGGameZones.h"
|
||||
#include "Damage.h"
|
||||
#include "Targetable.h"
|
||||
|
||||
class MTGDeck;
|
||||
class MTGPlayerCards;
|
||||
class MTGInPlay;
|
||||
class ManaPool;
|
||||
|
||||
class Player: public Damageable
|
||||
{
|
||||
protected:
|
||||
ManaPool * manaPool;
|
||||
|
||||
public:
|
||||
enum ENUM_PLAY_MODE
|
||||
{
|
||||
MODE_TEST_SUITE, MODE_HUMAN, MODE_AI,
|
||||
};
|
||||
|
||||
JTexture * mAvatarTex;
|
||||
JQuad * mAvatar;
|
||||
int playMode;
|
||||
int canPutLandsIntoPlay;
|
||||
int nomaxhandsize;
|
||||
int castedspellsthisturn;
|
||||
int onlyonecast;
|
||||
int castcount;
|
||||
int nocreatureinstant;
|
||||
int nospellinstant;
|
||||
int onlyoneinstant;
|
||||
int castrestrictedcreature;
|
||||
int castrestrictedspell;
|
||||
MTGPlayerCards * game;
|
||||
string deckFile;
|
||||
string deckFileSmall;
|
||||
string deckName;
|
||||
|
||||
Player(MTGDeck * deck, string deckFile, string deckFileSmall);
|
||||
virtual ~Player();
|
||||
|
||||
virtual void End();
|
||||
virtual int displayStack()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
const string getDisplayName() const;
|
||||
int typeAsTarget()
|
||||
{
|
||||
return TARGET_PLAYER;
|
||||
}
|
||||
|
||||
int afterDamage();
|
||||
int poisoned();
|
||||
int damaged();
|
||||
int prevented();
|
||||
void unTapPhase();
|
||||
MTGInPlay * inPlay();
|
||||
ManaPool * getManaPool();
|
||||
void cleanupPhase();
|
||||
virtual int Act(float dt)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual int isAI()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Player * opponent();
|
||||
int getId();
|
||||
JQuad * getIcon();
|
||||
|
||||
virtual int receiveEvent(WEvent * event)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void Render()
|
||||
{
|
||||
}
|
||||
|
||||
void loadAvatar(string file);
|
||||
};
|
||||
|
||||
class HumanPlayer: public Player
|
||||
{
|
||||
public:
|
||||
HumanPlayer(MTGDeck * deck, string deckFile, string deckFileSmall);
|
||||
HumanPlayer(string deckFile);
|
||||
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream&, const Player&);
|
||||
|
||||
#endif
|
||||
|
||||
48
projects/mtg/include/SimplePopup.h
Normal file
48
projects/mtg/include/SimplePopup.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* SimplePopup.h
|
||||
* Created on: Nov 18, 2010
|
||||
*
|
||||
* Simple popup dialog box for displaying information only.
|
||||
*/
|
||||
|
||||
#ifndef SIMPLEPOPUP_H_
|
||||
#define SIMPLEPOPUP_H_
|
||||
|
||||
#pragma once
|
||||
#include <JGui.h>
|
||||
#include <JTypes.h>
|
||||
#include <WFont.h>
|
||||
#include <DeckMetaData.h>
|
||||
|
||||
class SimplePopup: public JGuiController
|
||||
{
|
||||
|
||||
private:
|
||||
float mHeight, mWidth, mX, mY;
|
||||
int mMaxLines;
|
||||
int mFontId;
|
||||
DeckMetaData * mDeckInformation;
|
||||
string mTitle;
|
||||
WFont *mTextFont;
|
||||
StatsWrapper *stw;
|
||||
|
||||
void drawHorzPole(float x, float y, float width);
|
||||
void drawVertPole(float x, float y, float height);
|
||||
|
||||
public:
|
||||
MTGAllCards * mCollection;
|
||||
bool autoTranslate;
|
||||
bool closed;
|
||||
|
||||
SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title = "", DeckMetaData* deckInfo = NULL, MTGAllCards * collection = NULL);
|
||||
~SimplePopup(void);
|
||||
void Render();
|
||||
void Update(DeckMetaData* deckMetaData);
|
||||
|
||||
string getDetailedInformation(string deckFilename);
|
||||
|
||||
void Update(float dt);
|
||||
void Close();
|
||||
};
|
||||
|
||||
#endif /* SIMPLEPOPUP_H_ */
|
||||
Reference in New Issue
Block a user