- Card Primitives system. Check Royal Assassin in RV, 10E, M10
- Please review, is sets/primitives a good directory? Should we rename MTGCard into "CardPrint"? 
- Unfortunately for now it is not possible to "override" a Primitive. A card that links to a primitive but also defines new "values" will create its own data and ignore the data in the "linked" primitive for the time being. I hope to solve that at some point...
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-12-27 12:14:36 +00:00
parent 6135774016
commit 05a72de5bc
29 changed files with 713 additions and 564 deletions
+82
View File
@@ -0,0 +1,82 @@
#ifndef _CARDPRIMITIVE_H_
#define _CARDPRIMITIVE_H_
#include <string>
#include <vector>
#include <map>
#include "ManaCost.h"
using namespace std;
class CardPrimitive {
protected:
ManaCost manaCost;
vector<string> ftdText;
int init();
string lcname;
public:
string text;
string name;
int colors[Constants::MTG_NB_COLORS];
map<int,int> basicAbilities;
map<string,string> magicTexts;
string magicText;
int alias;
string spellTargetType;
int power;
int toughness;
vector<int>types;
CardPrimitive();
CardPrimitive(CardPrimitive * source);
void setColor(int _color, int removeAllOthers = 0);
void setColor(string _color, int removeAllOthers = 0);
void removeColor(int color);
int getColor();
int hasColor(int _color);
int countColors();
int has(int ability);
void setText(string value);
const char * getText();
void addMagicText(string value);
void addMagicText(string value, string zone);
void setName(string value);
const string getName() const;
const string getLCName() const;
void addType(char * type_text);
void addType(int id);
void setType(const char * type_text);
void setSubtype( string value);
int removeType(string value, int removeAll = 0);
int removeType(int value, int removeAll = 0);
bool hasSubtype(int _subtype);
bool hasSubtype(const char * _subtype);
bool hasSubtype(string _subtype);
bool hasType(int _type);
bool hasType(const char * type);
void setManaCost(string value);
ManaCost * getManaCost();
bool isCreature();
bool isLand();
bool isSpell();
void setPower(int _power);
int getPower();
void setToughness(int _toughness);
int getToughness();
const vector<string>& formattedText();
};
#endif
+2 -1
View File
@@ -3,6 +3,7 @@
#include "../include/MTGDefinitions.h"
#include "../include/MTGCard.h"
#include "../include/CardPrimitive.h"
#include <map>
#include <string>
using std::map;
@@ -16,7 +17,7 @@ class Cmp1 { // compares cards by their name
bool operator()(MTGCard * card1, MTGCard * card2) const {
if (!card2) return true;
if (!card1) return false;
int result = card1->name.compare(card2->name);
int result = card1->data->name.compare(card2->data->name);
if (!result) return card1->getMTGId() < card2->getMTGId();
return ( result < 0);
}
+3
View File
@@ -27,6 +27,8 @@ class GameStateMenu: public GameState, public JGuiListener
int mVolume;
char nbcardsStr[400];
vector<string> langs;
vector<string> primitives;
int primitivesLoadCounter;
DIR *mDip;
struct dirent *mDit;
@@ -45,6 +47,7 @@ class GameStateMenu: public GameState, public JGuiListener
void loadLangMenu();
bool langChoices;
void runTest(); //!!
void listPrimitives();
public:
GameStateMenu(GameApp* parent);
virtual ~GameStateMenu();
+6 -58
View File
@@ -16,51 +16,31 @@
#include <vector>
#include <map>
#include "ManaCost.h"
class CardPrimitive;
using namespace std;
class MTGCard {
protected:
int mtgid;
ManaCost manaCost;
char rarity;
char image_name[MTGCARD_NAME_SIZE];
vector<string> ftdText;
int init();
string lcname;
int init();
public:
string text;
string name;
int colors[Constants::MTG_NB_COLORS];
map<int,int> basicAbilities;
map<string,string> magicTexts;
string magicText;
int alias;
string spellTargetType;
int power;
int toughness;
int setId;
int nb_types;
int types[MAX_TYPES_PER_CARD];
CardPrimitive * data;
MTGCard();
MTGCard(int set_id);
MTGCard(MTGCard * source);
void setColor(int _color, int removeAllOthers = 0);
void setColor(string _color, int removeAllOthers = 0);
void removeColor(int color);
int getColor();
int hasColor(int _color);
int countColors();
void setMTGId(int id);
int getMTGId();
int getId();
int has(int ability);
char getRarity();
void setRarity(char _rarity);
@@ -68,40 +48,8 @@ class MTGCard {
//void setImageName( char * value);
char * getImageName ();
void setText(string value);
const char * getText();
void setPrimitive(CardPrimitive * cp);
void addMagicText(string value);
void addMagicText(string value, string zone);
void setName(string value);
const string getName() const;
const string getLCName() const;
void addType(char * type_text);
void addType(int id);
void setType(const char * type_text);
void setSubtype( string value);
int removeType(string value, int removeAll = 0);
int removeType(int value, int removeAll = 0);
bool hasSubtype(int _subtype);
bool hasSubtype(const char * _subtype);
bool hasSubtype(string _subtype);
bool hasType(int _type);
bool hasType(const char * type);
void setManaCost(string value);
ManaCost * getManaCost();
bool isCreature();
bool isLand();
bool isSpell();
void setPower(int _power);
int getPower();
void setToughness(int _toughness);
int getToughness();
const vector<string>& formattedText();
};
+3 -1
View File
@@ -2,6 +2,7 @@
#define _MTG_CARD_INSTANCE_H_
#include "MTGCard.h"
#include "CardPrimitive.h"
#include "MTGGameZones.h"
#include "MTGAbility.h"
#include "WResourceManager.h"
@@ -24,7 +25,7 @@ struct Pos;
#include <list>
using namespace std;
class MTGCardInstance: public MTGCard, public Damageable {
class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
protected:
int untapping;
int nb_damages;
@@ -41,6 +42,7 @@ class MTGCardInstance: public MTGCard, public Damageable {
int addBlocker(MTGCardInstance * c);
int removeBlocker(MTGCardInstance * c);
int setAttacker(int value);
int init();
public:
MTGGameZone * currentZone;
Pos* view;
+8 -6
View File
@@ -15,6 +15,7 @@ using std::string;
class GameApp;
class MTGCard;
class CardPrimitive;
#define SET_METADATA "setinfo.txt"
@@ -80,10 +81,8 @@ extern MTGSets setlist;
class MTGAllCards {
private:
MTGCard * tempCard;
#if defined (_DEBUG)
bool committed;
#endif
MTGCard * tempCard; //used by parser
CardPrimitive * tempPrimitive; //used by parser
protected:
int conf_read_mode;
int colorsCount[Constants::MTG_NB_COLORS];
@@ -95,6 +94,7 @@ private:
vector<int> ids;
map<int, MTGCard *> collection;
map<string,CardPrimitive *>primitives;
MTGAllCards();
~MTGAllCards();
MTGCard * _(int id);
@@ -102,7 +102,7 @@ private:
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 load(const char * config_file, const char * setName = NULL, int autoload = 1);
int countByType(const char * _type);
int countByColor(int color);
int countBySet(int setId);
@@ -110,7 +110,9 @@ private:
int totalCards();
int randomCardId();
private:
int processConfLine(string s, MTGCard* card);
int processConfLine(string s, MTGCard* card, CardPrimitive * primitive);
bool addCardToCollection(MTGCard * card, int setId);
bool addPrimitive(CardPrimitive * primitive, MTGCard * card = NULL);
};