Files
wagic/projects/mtg/include/MTGDeck.h
Psyyringe 779921a53f Psyringe - This revision adds "cheat mode", as suggested and pre-reviewed here:
http://wololo.net/forum/viewtopic.php?f=15&t=730

Although the feature is named "cheat mode", its main purpose is to provide a toolbox for content creators. Currently this means to help AI deck creators, but the cheat mode is easily extensible.

Features:
- To enable cheat mode, create a new profile with the super secret cheat name (shouldn't be hard to find - or just mail me if you don't want to look). Then, leave and re-enter the Options menu. You can now enable cheat mode on the first tab. Note: The secret profile name is *not* my original suggestion from the forum, I went with Jeck's alternative suggestion so that he won't have to cringe over bad puns everytime he's using it. ;)

- Complete collection: In cheat mode, there's a new option in the deck viewer, which makes sure that you have at least 4 of any card available.

- Deck integrity: When in cheat mode, and you load a deck with cards that are not present in your collection, then these cards won't be stripped from your deck any more. Instead, they are added to your collection.

- Money cheat: In cheat mode, when you click on an item in the shop, you get the option to steal 1,000 credits from the shopkeeper.

Please review my code - I just started with C++, I may make very obvious mistakes or use inelegant style. The sooner you point this out, the sooner I'll improve.

thanks to wololo and jeck for comments and suggestions.

Jeck: Do the setVisible and setHidden methods currently work? I tried to use them to hide a menu item, but they all seem to lead to empty methods - Perhaps placeholders for a not yet implemented functionality?
2009-11-02 04:27:14 +00:00

105 lines
2.0 KiB
C++

#ifndef _MTGDECK_H_
#define _MTGDECK_H_
#define MTG_ERROR -1
#include "../include/MTGDefinitions.h"
#include "../include/GameApp.h"
#include "../include/WResourceManager.h"
#include <string>
using std::string;
class GameApp;
class MTGCard;
#define MAX_SETS 100
class MtgSets{
protected:
public:
int nb_items;
string values[MAX_SETS];
public:
static MtgSets * SetsList;
MtgSets();
int Add(const char * subtype);
int find(string value);
};
class MTGAllCards {
private:
MTGCard * tempCard;
#if defined (_DEBUG)
bool committed;
#endif
protected:
int conf_read_mode;
int colorsCount[Constants::MTG_NB_COLORS];
int total_cards;
GameApp * parent;
void init();
void initCounters();
public:
vector<int> ids;
map<int, MTGCard *> collection;
MTGAllCards();
~MTGAllCards();
MTGCard * _(int id);
void destroyAllCards();
MTGAllCards(const char * config_file, const char * set_name);
MTGCard * getCardById(int id);
MTGCard * getCardByName(string name);
int load(const char * config_file, const char * setName, int autoload = 1);
int countByType(const char * _type);
int countByColor(int color);
int countBySet(int setId);
int readConfLine(ifstream &file, int set_id);
int totalCards();
int randomCardId();
private:
int processConfLine(string s, MTGCard* card);
};
class MTGDeck{
protected:
string filename;
int total_cards;
public:
MTGAllCards * database;
map <int,int> cards;
string meta_desc;
string meta_name;
int totalCards();
MTGDeck(MTGAllCards * _allcards);
MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0);
int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL, int * colors = NULL, int nbcolors = 0);
int add(int cardid);
int add(MTGDeck * deck); // adds the contents of "deck" into myself
int complete();
int remove(int cardid);
int removeAll();
int add(MTGCard * card);
int remove(MTGCard * card);
int save();
MTGCard * getCardById(int id);
};
#endif