Jeck - Minor update to trophy room, moved metadata into cards.dat
* updated daily build * Card spoiler now sorts by collector's number. * Metadata looks for "[m" (for speed reasons), I've been using "[meta]" in files. No sets currently use metadata.
This commit is contained in:
Binary file not shown.
@@ -11,14 +11,10 @@
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
|
||||
|
||||
class GameApp;
|
||||
class MTGCard;
|
||||
class CardPrimitive;
|
||||
|
||||
#define SET_METADATA "setinfo.txt"
|
||||
|
||||
class MTGSetInfo{
|
||||
public:
|
||||
MTGSetInfo(string _id);
|
||||
@@ -36,6 +32,7 @@ public:
|
||||
string getBlock();
|
||||
int boosterCost();
|
||||
int boosterSize();
|
||||
void processConfLine(string line);
|
||||
|
||||
enum {
|
||||
//For memoized counts
|
||||
@@ -91,7 +88,11 @@ private:
|
||||
void init();
|
||||
void initCounters();
|
||||
public:
|
||||
|
||||
enum {
|
||||
READ_ANYTHING = 0,
|
||||
READ_CARD = 1,
|
||||
READ_METADATA = 2,
|
||||
};
|
||||
vector<int> ids;
|
||||
map<int, MTGCard *> collection;
|
||||
map<string,CardPrimitive *>primitives;
|
||||
@@ -119,8 +120,6 @@ private:
|
||||
class MTGDeck{
|
||||
protected:
|
||||
string filename;
|
||||
|
||||
|
||||
int total_cards;
|
||||
|
||||
public:
|
||||
|
||||
@@ -177,6 +177,19 @@ protected:
|
||||
float mLastInput;
|
||||
};
|
||||
|
||||
struct WCardSort{
|
||||
public:
|
||||
virtual bool operator()(const MTGCard*l, const MTGCard*r) = 0;
|
||||
};
|
||||
|
||||
struct WCSortCollector: public WCardSort{
|
||||
bool operator()(const MTGCard*l, const MTGCard*r);
|
||||
};
|
||||
|
||||
struct WCSortAlpha: public WCardSort{
|
||||
bool operator()(const MTGCard*l, const MTGCard*r);
|
||||
};
|
||||
|
||||
class WGuiImage: public WGuiItem{
|
||||
public:
|
||||
WGuiImage(WDataSource * wds, float _w = 0, float _h = 0, int _margin = 0);
|
||||
|
||||
@@ -210,11 +210,14 @@ bool GameStateAwards::enterSet(int setid){
|
||||
WGuiList * spoiler = NEW WGuiList("Spoiler",setSrc);
|
||||
spoiler->setX(210);
|
||||
spoiler->setWidth(SCREEN_WIDTH - 220);
|
||||
MTGAllCards * c = GameApp::collection;
|
||||
for(it = c->collection.begin();it!=c->collection.end();it++){
|
||||
if(it->second && it->second->setId == setid && it->second->getId() >= 0) //Add only non-tokens from this set.
|
||||
spoiler->Add(NEW WGuiItem(it->second->data->name));
|
||||
while(true){
|
||||
MTGCard * c = setSrc->getCard();
|
||||
if(c)
|
||||
spoiler->Add(NEW WGuiItem(c->data->name));
|
||||
if(!setSrc->next())
|
||||
break;
|
||||
}
|
||||
setSrc->setPos(0);
|
||||
spoiler->Entering(0);
|
||||
WGuiCardImage * wi = NEW WGuiCardImage(setSrc);
|
||||
wi->setX(105);
|
||||
|
||||
@@ -335,21 +335,34 @@ bool MTGAllCards::addPrimitive(CardPrimitive * primitive, MTGCard * card){
|
||||
}
|
||||
|
||||
int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
|
||||
|
||||
MTGSetInfo * si = setlist.getInfo(set_id);
|
||||
string s;
|
||||
int result = 1;
|
||||
if(!std::getline(file,s)) return 0;
|
||||
if (!s.size()) return -1;
|
||||
if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files
|
||||
switch(conf_read_mode) {
|
||||
case 0:
|
||||
case MTGAllCards::READ_ANYTHING:
|
||||
if (s[0] == '['){
|
||||
conf_read_mode = 1;
|
||||
if(s[1] == 'm'){ //M for metadata.
|
||||
conf_read_mode = MTGAllCards::READ_METADATA;
|
||||
}
|
||||
else{
|
||||
conf_read_mode = MTGAllCards::READ_CARD;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case MTGAllCards::READ_METADATA:
|
||||
if (s[0] == '[' && s[1] == '/'){
|
||||
conf_read_mode = 0;
|
||||
conf_read_mode = MTGAllCards::READ_ANYTHING;
|
||||
break;
|
||||
}
|
||||
if(si)
|
||||
si->processConfLine(s);
|
||||
break;
|
||||
case MTGAllCards::READ_CARD:
|
||||
if (s[0] == '[' && s[1] == '/'){
|
||||
conf_read_mode = MTGAllCards::READ_ANYTHING;
|
||||
if (tempPrimitive) addPrimitive (tempPrimitive,tempCard);
|
||||
if (tempCard){
|
||||
addCardToCollection(tempCard, set_id);
|
||||
@@ -816,3 +829,23 @@ string MTGSetInfo::getBlock(){
|
||||
|
||||
return setlist.blocks[block];
|
||||
}
|
||||
|
||||
|
||||
void MTGSetInfo::processConfLine(string line){
|
||||
unsigned int i = line.find_first_of("=");
|
||||
if (i == string::npos)
|
||||
return;
|
||||
|
||||
string key = line.substr(0,i);
|
||||
std::transform(key.begin(),key.end(),key.begin(),::tolower);
|
||||
string value = line.substr(i+1);
|
||||
|
||||
if(key.compare("name") == 0)
|
||||
name = value;
|
||||
else if(key.compare("author") == 0)
|
||||
author = value;
|
||||
else if(key.compare("block") == 0)
|
||||
block = setlist.findBlock(value.c_str());
|
||||
else if(key.compare("year") == 0)
|
||||
year = atoi(value.c_str());
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <JGE.h>
|
||||
#include "../include/PlayerData.h"
|
||||
#include "../include/Translate.h"
|
||||
#include "../include/Subtypes.h"
|
||||
#include <dirent.h>
|
||||
#include <stdlib.h>
|
||||
#include <algorithm>
|
||||
@@ -1393,6 +1394,68 @@ JQuad * WSrcImage::getImage(){
|
||||
WSrcImage::WSrcImage(string s){
|
||||
filename = s;
|
||||
}
|
||||
|
||||
bool WCSortAlpha::operator()(const MTGCard*l, const MTGCard*r){
|
||||
if(!l || !r || !l->data || !r->data)
|
||||
return false;
|
||||
string ln = l->data->getLCName();
|
||||
string rn = r->data->getLCName();
|
||||
return (ln < rn);
|
||||
}
|
||||
bool WCSortCollector::operator()(const MTGCard*l, const MTGCard*r){
|
||||
if(!l || !r || !l->data || !r->data)
|
||||
return false;
|
||||
|
||||
int lc, rc;
|
||||
lc = l->data->countColors(); rc = r->data->countColors();
|
||||
if(lc == 0) lc = 999;
|
||||
if(rc == 0) rc = 999;
|
||||
|
||||
int isW = (int)l->data->hasColor(Constants::MTG_COLOR_WHITE) - (int) r->data->hasColor(Constants::MTG_COLOR_WHITE);
|
||||
int isU = (int)l->data->hasColor(Constants::MTG_COLOR_BLUE) - (int) r->data->hasColor(Constants::MTG_COLOR_BLUE);
|
||||
int isB = (int)l->data->hasColor(Constants::MTG_COLOR_BLACK) - (int) r->data->hasColor(Constants::MTG_COLOR_BLACK);
|
||||
int isR = (int)l->data->hasColor(Constants::MTG_COLOR_RED) - (int) r->data->hasColor(Constants::MTG_COLOR_RED);
|
||||
int isG = (int)l->data->hasColor(Constants::MTG_COLOR_GREEN) - (int) r->data->hasColor(Constants::MTG_COLOR_GREEN);
|
||||
int isArt = (int)l->data->hasType(Subtypes::TYPE_ARTIFACT) - (int) r->data->hasType(Subtypes::TYPE_ARTIFACT);
|
||||
int isLand = (int)l->data->hasType(Subtypes::TYPE_LAND) - (int) r->data->hasType(Subtypes::TYPE_LAND);
|
||||
|
||||
//Nested if hell. TODO: Farm these out to their own objects as a user-defined filter/sort system.
|
||||
if(!isLand){
|
||||
int isBasic = (int)l->data->hasType("Basic") - (int) r->data->hasType("Basic");
|
||||
if(!isBasic){
|
||||
if(!isArt){
|
||||
if(lc == rc){
|
||||
if(!isG){
|
||||
if(!isR){
|
||||
if(!isB){
|
||||
if(!isU){
|
||||
if(!isW){
|
||||
string ln = l->data->getLCName();
|
||||
string rn = r->data->getLCName();
|
||||
if(ln.substr(0,4) == "the ")
|
||||
ln = ln.substr(4);
|
||||
if(rn.substr(0,4) == "the ")
|
||||
rn = rn.substr(4);
|
||||
return (ln < rn);
|
||||
}
|
||||
return (isW < 0);
|
||||
}
|
||||
return (isU < 0);
|
||||
}
|
||||
return (isB < 0);
|
||||
}
|
||||
return (isR < 0);
|
||||
}
|
||||
return (isG < 0);
|
||||
}
|
||||
return (lc < rc);
|
||||
}
|
||||
return (isArt < 0);
|
||||
}
|
||||
else return(isBasic < 0);
|
||||
}
|
||||
return (isLand < 0);
|
||||
}
|
||||
//WSrcMTGSet
|
||||
WSrcMTGSet::WSrcMTGSet(int setid, float delay){
|
||||
MTGAllCards * ac = GameApp::collection;
|
||||
@@ -1405,6 +1468,8 @@ WSrcMTGSet::WSrcMTGSet(int setid, float delay){
|
||||
cards.push_back(it->second);
|
||||
}
|
||||
|
||||
std::sort(cards.begin(),cards.end(),WCSortCollector());
|
||||
|
||||
currentCard = -1;
|
||||
if(cards.size())
|
||||
currentCard = 0;
|
||||
|
||||
Reference in New Issue
Block a user