* moved deck saving to end of match. It now only saves when you've actually completed a game.

* added additional meta data for decks when saving them back to file.
  - decks saved this way now are split into three regions: creatures, spells and lands.  It's more for a visual sorting if a
     player wanted to look at the deck outside of the game.  It does not impact the deck loading negatively at all.  It may
     increase performance in cases where the deck was previously defined using the canonical names of the cards as the numeric ids
     reduce the work done when looking up the cards by name.
* modified ManaCost toString method.
* added toString method for ManaCostHybrid ( possibly make ManaCostHybrid a subclass of ManaCost)
* added additional operator overloading for ManaCost for printing to cover ManaCost when it's a pointer as well as a copy
   ( TODO: might want to check if making usage of ManaCost as a copy as opposed to a ptr is really necessary in most cases. )
* added alternate version of "trim" to handle trimming temporary strings as returned by things like ostringstream.str().
 - This was necessary since the PSP compiler doesn't do the necessary adjustments for those types of calls.
This commit is contained in:
techdragon.nguyen@gmail.com
2011-02-04 12:37:44 +00:00
parent 6edef29d17
commit 767983631a
15 changed files with 270 additions and 88 deletions

View File

@@ -27,7 +27,8 @@ public:
vector<DeckMetaData*> * getPlayerDeckOrderList();
vector<DeckMetaData*> * getAIDeckOrderList();
void saveDeck ( MTGDeck *deck, int deckId, MTGAllCards *collection );
void saveDeck ( const string& deckFilename, MTGAllCards *collection );
void saveDeck ( MTGDeck *deck, MTGAllCards *collection );
void AddMetaData( const std::string& filename, bool isAI);
DeckMetaData* getDeckMetaDataById(int deckId, bool isAI);
DeckMetaData* getDeckMetaDataByFilename(const std::string& filename, bool isAI);

View File

@@ -132,6 +132,9 @@ private:
class MTGDeck
{
private:
string getCardBlockText( const string& title, const string& textBlock );
void printDetailedDeckText(std::ofstream& file );
protected:
string filename;
int total_cards;
@@ -141,6 +144,7 @@ public:
map<int, int> cards;
string meta_desc;
string meta_name;
int meta_id;
string meta_deck_colors;
int totalCards();
int totalPrice();
@@ -157,7 +161,7 @@ public:
int remove(MTGCard * card);
string getFilename();
int save();
int save(string destFileName, bool useExpandedDescriptions, string &deckTitle, string &deckDesc);
int save(const string& destFileName, bool useExpandedDescriptions, const string& deckTitle, const string& deckDesc);
MTGCard * getCardById(int id);
};

View File

@@ -13,6 +13,11 @@ class MTGCardInstance;
class Player;
class ManaCost{
friend std::ostream& operator<<(std::ostream& out, ManaCost& m);
friend std::ostream& operator<<(std::ostream& out, ManaCost* m);
friend std::ostream& operator<<(std::ostream& out, ManaCost m);
protected:
int cost[Constants::MTG_NB_COLORS+1];
ManaCostHybrid * hybrids[10];
@@ -80,9 +85,9 @@ class ManaCost{
#ifdef WIN32
void Dump();
#endif
};
std::ostream& operator<<(std::ostream& out, const ManaCost& m);
};
class ManaPool:public ManaCost{
protected:

View File

@@ -3,16 +3,23 @@
class ManaCostHybrid
{
public:
int color1;
int color2;
int value1;
int value2;
ManaCostHybrid();
int hasColor(int color);
ManaCostHybrid(int c1, int v1, int c2, int v2);
void init(int c1, int v1, int c2, int v2);
int hasColor(int color);
string toString();
int getConvertedCost();
friend std::ostream& operator<<(std::ostream& out, ManaCostHybrid& m);
friend std::ostream& operator<<(std::ostream& out, ManaCostHybrid* m);
};
#endif

View File

@@ -74,7 +74,15 @@ namespace wagic
using std::string;
#define SPACES " \t\r\n"
//string manipulation methods
// for trimming strings on the fly
string trim (const string & s, const string & t = SPACES);
string trim_right (const string & s, const string & t = SPACES);
string trim_left (const string & s, const string & t = SPACES);
// trimmning strings inplace
string& trim(string& str);
string& ltrim(string& str);
string& rtrim(string& str);