- This is some Work in progress to make Wagic less "game" dependent. This change especially is an attempt at moving away from some dangerous patents owned by some company. It introduces "modrules.xml", a global configuration file describing dynamic settings for any given Wagic mod. It is very basic for now, but allows to customize a bit. In particular, it allows to remove the concept of shop and deck editor from the game, dynamically generate the main menu, and represent card activation with a mask rather than a rotation. I have a sample in progress which I hope to submit in the days to come, a proof of concept (nothing fancy yet) for another type of game using these ideas, as well as a few other things I introduced recently. In the future, I am hoping to extend modrules.xml so that it entirely describes the rules of a given card game. the other files in rules.txt will describe "extensions" to the core rules, just like they do right now, so this new file does not make them obsolete. - Also fixed minor bugs I stumbled upon while developing
111 lines
2.3 KiB
C++
111 lines
2.3 KiB
C++
#ifndef _MODRULES_H_
|
|
#define _MODRULES_H_
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
using namespace std;
|
|
|
|
#include "CardGui.h"
|
|
|
|
class TiXmlElement;
|
|
|
|
|
|
enum
|
|
{
|
|
SUBMENUITEM_CANCEL = kCancelMenuID,
|
|
MENUITEM_PLAY,
|
|
MENUITEM_DECKEDITOR,
|
|
MENUITEM_SHOP,
|
|
MENUITEM_OPTIONS,
|
|
MENUITEM_EXIT,
|
|
MENUITEM_TROPHIES,
|
|
SUBMENUITEM_1PLAYER,
|
|
#ifdef NETWORK_SUPPORT
|
|
SUBMENUITEM_2PLAYERS,
|
|
SUBMENUITEM_HOST_GAME,
|
|
SUBMENUITEM_JOIN_GAME,
|
|
#endif //NETWORK_SUPPORT
|
|
SUBMENUITEM_DEMO,
|
|
SUBMENUITEM_TESTSUITE,
|
|
SUBMENUITEM_END_OFFSET
|
|
};
|
|
|
|
class ModRulesMenuItem
|
|
{
|
|
protected:
|
|
static int strToAction(string str);
|
|
public:
|
|
int mActionId;
|
|
string mDisplayName;
|
|
ModRulesMenuItem(string actionIdStr, string displayName);
|
|
//most actionIds are associated to a game state. e.g. MENUITEM_DECKEDITOR <--> GAME_STATE_DECK_VIEWER
|
|
//This function returns the game state that matches the actionId, if any
|
|
int getMatchingGameState();
|
|
static int getMatchingGameState(int actionId);
|
|
};
|
|
|
|
class ModRulesMainMenuItem: public ModRulesMenuItem
|
|
{
|
|
public:
|
|
int mIconId;
|
|
string mParticleFile;
|
|
ModRulesMainMenuItem(string actionIdStr, string displayName, int iconId, string particleFile);
|
|
};
|
|
|
|
class ModRulesOtherMenuItem: public ModRulesMenuItem
|
|
{
|
|
public:
|
|
JButton mKey;
|
|
ModRulesOtherMenuItem(string actionIdStr, string displayName, string keyStr);
|
|
static JButton strToJButton(string keyStr);
|
|
};
|
|
|
|
class ModRulesMenu
|
|
{
|
|
public:
|
|
vector<ModRulesMainMenuItem *> main;
|
|
vector<ModRulesOtherMenuItem *> other;
|
|
|
|
void parse(TiXmlElement* element);
|
|
~ModRulesMenu();
|
|
};
|
|
|
|
class ModRulesGeneral
|
|
{
|
|
protected:
|
|
bool mHasDeckEditor;
|
|
bool mHasShop;
|
|
public:
|
|
bool hasDeckEditor() {return mHasDeckEditor;};
|
|
bool hasShop() {return mHasShop;};
|
|
ModRulesGeneral();
|
|
void parse(TiXmlElement* element);
|
|
};
|
|
|
|
class ModRulesCards
|
|
{
|
|
public:
|
|
SimpleCardEffect * activateEffect;
|
|
static SimpleCardEffect * parseEffect(string str);
|
|
ModRulesCards();
|
|
~ModRulesCards();
|
|
void parse(TiXmlElement* element);
|
|
};
|
|
|
|
class ModRules
|
|
{
|
|
public:
|
|
ModRulesGeneral general;
|
|
ModRulesCards cards;
|
|
ModRulesMenu menu;
|
|
|
|
bool load(string filename);
|
|
static int getValueAsInt(TiXmlElement* element, string childName);
|
|
|
|
};
|
|
|
|
extern ModRules gModRules;
|
|
|
|
|
|
#endif
|