Jeck - fixed issue 354, cleaned up mixed boosters, fixed a few issues with pack loading (slot pools weren't working), fixed TSP boosters to use 'S' rarity, removed some unused code.

This commit is contained in:
wagic.jeck
2010-02-19 20:10:30 +00:00
parent c67390be88
commit afffd4509f
12 changed files with 117 additions and 89 deletions

View File

@@ -0,0 +1,21 @@
<PACK name="TSP" type="Booster" pool="unlocked set:TSP;" price="700">
<slot copies="1">
<random_card>rarity:mythic;</random_card>
<random_card>rarity:rare;</random_card>
<random_card>rarity:rare;</random_card>
<random_card>rarity:rare;</random_card>
<random_card>rarity:rare;</random_card>
<random_card>rarity:rare;</random_card>
<random_card>rarity:rare;</random_card>
<random_card>rarity:rare;</random_card>
</slot>
<slot copies="3">
<random_card>rarity:uncommon;</random_card>
</slot>
<slot copies="1" pool="all set:TSB;">
<random_card>rarity:special;</random_card>
</slot>
<slot copies="10">
<random_card>rarity:common;</random_card>
</slot>
</PACK>

View File

@@ -14,10 +14,11 @@ using std::string;
class GameApp; class GameApp;
class MTGCard; class MTGCard;
class CardPrimitive; class CardPrimitive;
class MTGPack;
class MTGSetInfo{ class MTGSetInfo{
public: public:
MTGSetInfo(string _id); MTGSetInfo(string _id);
~MTGSetInfo();
string id; //Short name: 10E, RAV, etc. Automatic from folder. string id; //Short name: 10E, RAV, etc. Automatic from folder.
string author; //Author of set, for crediting mod makers, etc. string author; //Author of set, for crediting mod makers, etc.
string name; //Long name: Tenth Edition string name; //Long name: Tenth Edition
@@ -30,8 +31,6 @@ public:
int totalCards(); int totalCards();
string getName(); string getName();
string getBlock(); string getBlock();
int boosterCost();
int boosterSize();
void processConfLine(string line); void processConfLine(string line);
enum { enum {
@@ -46,10 +45,10 @@ public:
MAX_COUNT = 6 MAX_COUNT = 6
}; };
MTGPack * mPack; //Does it use a specialized booster pack?
bool bZipped; //Is this set's images present as a zip file? bool bZipped; //Is this set's images present as a zip file?
bool bThemeZipped; //[...] in the theme? bool bThemeZipped; //[...] in the theme?
int counts[MTGSetInfo::MAX_COUNT]; int counts[MTGSetInfo::MAX_COUNT];
int booster[MAX_RARITY];
}; };
class MTGSets{ class MTGSets{

View File

@@ -107,6 +107,7 @@ class Constants
NB_BASIC_ABILITIES = 48, NB_BASIC_ABILITIES = 48,
RARITY_S = 'S', //Special Rarity
RARITY_M = 'M', //Mythics RARITY_M = 'M', //Mythics
RARITY_R = 'R', //Rares RARITY_R = 'R', //Rares
RARITY_U = 'U', //Uncommons RARITY_U = 'U', //Uncommons
@@ -122,6 +123,7 @@ class Constants
//Price for singles //Price for singles
PRICE_1M = 3000, PRICE_1M = 3000,
PRICE_1R = 500, PRICE_1R = 500,
PRICE_1S = 200,
PRICE_1U = 100, PRICE_1U = 100,
PRICE_1C = 20, PRICE_1C = 20,
PRICE_1L = 5, PRICE_1L = 5,
@@ -132,10 +134,6 @@ class Constants
CHANCE_CUSTOM_PACK = 15, CHANCE_CUSTOM_PACK = 15,
CHANCE_PURE_OVERRIDE = 50, CHANCE_PURE_OVERRIDE = 50,
CHANCE_MIXED_OVERRIDE = 25, CHANCE_MIXED_OVERRIDE = 25,
PRICE_XR = 355,
PRICE_XU = 88,
PRICE_XC = 8,
PRICE_XL = 1,
MAIN_FONT = 0, MAIN_FONT = 0,
MENU_FONT = 1, MENU_FONT = 1,

View File

@@ -1,6 +1,8 @@
#ifndef _MTGPACCK_H_ #ifndef _MTGPACCK_H_
#define _MTGPACK_H_ #define _MTGPACK_H_
class ShopBooster;
class MTGPackEntry{ class MTGPackEntry{
public: public:
virtual int addCard(WSrcCards * pool,MTGDeck * to) = 0; virtual int addCard(WSrcCards * pool,MTGDeck * to) = 0;
@@ -9,6 +11,8 @@ public:
class MTGPackEntryRandom: public MTGPackEntry{ class MTGPackEntryRandom: public MTGPackEntry{
public: public:
MTGPackEntryRandom() {filter = ""; copies=1;};
MTGPackEntryRandom(string f, int c=1) {filter = f; copies = c;};
int addCard(WSrcCards * pool,MTGDeck * to); int addCard(WSrcCards * pool,MTGDeck * to);
string filter; string filter;
}; };
@@ -36,13 +40,16 @@ public:
class MTGPack{ class MTGPack{
public: public:
friend class MTGPacks; friend class MTGPacks;
friend class ShopBooster;
friend class MTGSetInfo;
bool meetsRequirements(); //Check if pool contains locked cards. bool meetsRequirements(); //Check if pool contains locked cards.
bool isUnlocked(); bool isUnlocked();
bool isValid() {return bValid;}; bool isValid() {return bValid;};
void load(string filename); void load(string filename);
int assemblePack(MTGDeck * to); int assemblePack(MTGDeck * to);
MTGPack(string s) {bValid = false; load(s); unlockStatus=0;}; MTGPack() {bValid = false; unlockStatus = 0; price=Constants::PRICE_BOOSTER;};
MTGPack(string s) {bValid = false; load(s); unlockStatus = 0;};
~MTGPack(); ~MTGPack();
string getName(); string getName();
string getSort() {return sort;}; string getSort() {return sort;};
@@ -72,8 +79,9 @@ public:
int size() {return (int)packs.size();}; int size() {return (int)packs.size();};
void refreshUnlocked(); void refreshUnlocked();
static MTGPack * getDefault();
private: private:
static MTGPack defaultBooster;
vector<MTGPack*> packs; vector<MTGPack*> packs;
}; };
#endif #endif

View File

@@ -304,8 +304,12 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
case Constants::RARITY_L: case Constants::RARITY_L:
sprintf(buf,_("%s Land").c_str(),setlist[card->setId].c_str()); sprintf(buf,_("%s Land").c_str(),setlist[card->setId].c_str());
break; break;
case Constants::RARITY_T:
sprintf(buf,_("%s Token").c_str(),setlist[card->setId].c_str());
break;
default: default:
sprintf(buf,"%s",setlist[card->setId].c_str()); case Constants::RARITY_S:
sprintf(buf,_("%s Special").c_str(),setlist[card->setId].c_str());
break; break;
} }

View File

@@ -736,9 +736,8 @@ void ShopBooster::randomCustom(MTGPacks * packlist){
pack = packlist->randomPack(); pack = packlist->randomPack();
if(pack && !pack->isUnlocked()) if(pack && !pack->isUnlocked())
pack = NULL; pack = NULL;
if(!pack){ if(!pack)
randomStandard(); randomStandard();
}
} }
void ShopBooster::randomStandard(){ void ShopBooster::randomStandard(){
int mSet = -1; int mSet = -1;
@@ -763,6 +762,7 @@ void ShopBooster::randomStandard(){
altSet = setlist.randomSet(-1,80-mSetCount); altSet = setlist.randomSet(-1,80-mSetCount);
} }
if(altSet == mainSet) altSet = NULL; //Prevent "10E & 10E Booster" if(altSet == mainSet) altSet = NULL; //Prevent "10E & 10E Booster"
if(!altSet) pack = mainSet->mPack;
} }
int ShopBooster::maxInventory(){ int ShopBooster::maxInventory(){
@@ -771,39 +771,15 @@ int ShopBooster::maxInventory(){
return 5; return 5;
} }
void ShopBooster::addToDeck(MTGDeck * d, WSrcCards * srcCards){ void ShopBooster::addToDeck(MTGDeck * d, WSrcCards * srcCards){
if(!pack){ //A combination booster.
if(pack){ MTGPack * mP = MTGPacks::getDefault();
if(!altSet && mainSet->mPack) mP = mainSet->mPack;
char buf[512];
if(!altSet) sprintf(buf,"set:%s;",mainSet->id.c_str());
else sprintf(buf,"set:%s;|set:%s;",mainSet->id.c_str(),altSet->id.c_str());
mP->pool = buf;
mP->assemblePack(d); //Use the primary packfile. assemblePack deletes pool.
}
else
pack->assemblePack(d); pack->assemblePack(d);
}
else{
WSrcCards * pool = NEW WSrcCards(0);
WCFilterSet *main, *alt;
int num = setlist.getSetNum(mainSet);
main = NEW WCFilterSet(num);
if(altSet){
num = setlist.getSetNum(altSet);
alt = NEW WCFilterSet(num);
pool->addFilter(NEW WCFilterOR(main,alt));
} else
pool->addFilter(main);
pool->loadMatches(srcCards,true);
pool->Shuffle();
//Add cards to booster. Pool is shuffled, so just step through.
int carryover = 1;
if(!(rand() % 8)){
pool->addFilter(NEW WCFilterRarity(Constants::RARITY_M));
carryover = pool->addToDeck(d,carryover);
}
pool->clearFilters();
pool->addFilter(NEW WCFilterRarity(Constants::RARITY_R));
carryover = pool->addToDeck(d,carryover);
pool->clearFilters();
pool->addFilter(NEW WCFilterRarity(Constants::RARITY_U));
carryover = pool->addToDeck(d,carryover+3);
pool->clearFilters();
pool->addFilter(NEW WCFilterRarity(Constants::RARITY_C));
carryover = pool->addToDeck(d,carryover+11);
SAFE_DELETE(pool);
}
} }

View File

@@ -5,6 +5,8 @@
#include "../include/Translate.h" #include "../include/Translate.h"
#include "../include/DeckMetaData.h" #include "../include/DeckMetaData.h"
#include "../include/PriceList.h" #include "../include/PriceList.h"
#include "../include/WDataSrc.h"
#include "../include/MTGPack.h"
#include <algorithm> #include <algorithm>
#include <string> #include <string>
#include <sstream> #include <sstream>
@@ -842,6 +844,10 @@ int MTGSets::size(){
} }
//MTGSetInfo //MTGSetInfo
MTGSetInfo::~MTGSetInfo(){
if(mPack != MTGPacks::getDefault())
SAFE_DELETE(mPack);
}
MTGSetInfo::MTGSetInfo(string _id) { MTGSetInfo::MTGSetInfo(string _id) {
string whitespaces (" \t\f\v\n\r"); string whitespaces (" \t\f\v\n\r");
id = _id; id = _id;
@@ -851,12 +857,14 @@ MTGSetInfo::MTGSetInfo(string _id) {
for(int i=0;i<MTGSetInfo::MAX_COUNT;i++) for(int i=0;i<MTGSetInfo::MAX_COUNT;i++)
counts[i] = 0; counts[i] = 0;
booster[MTGSetInfo::LAND] = 1; char myFilename[4096];
booster[MTGSetInfo::COMMON] = 10; sprintf(myFilename, RESPATH"/sets/%s/booster.txt", id.c_str());
booster[MTGSetInfo::UNCOMMON] = 3; mPack = NEW MTGPack(myFilename);
booster[MTGSetInfo::RARE] = 1; if(!mPack->isValid()){
SAFE_DELETE(mPack);
//Load metadata. (FIXME - Removed for release 0.1.0, will be fully implemented next release) }
bZipped = false;
bThemeZipped = false;
} }
void MTGSetInfo::count(MTGCard*c){ void MTGSetInfo::count(MTGCard*c){
@@ -889,32 +897,6 @@ int MTGSetInfo::totalCards(){
return counts[MTGSetInfo::TOTAL_CARDS]; return counts[MTGSetInfo::TOTAL_CARDS];
} }
int MTGSetInfo::boosterSize(){
int size = 0;
for(int i = 0; i<MTGSetInfo::MAX_RARITY;i++)
size += booster[i];
return size;
}
int MTGSetInfo::boosterCost(){
int price = 0;
for(int i = 0; i<MTGSetInfo::MAX_RARITY;i++){
if(i == MTGSetInfo::LAND)
price += booster[i] * Constants::PRICE_XL;
else if(i == MTGSetInfo::COMMON)
price += booster[i] * Constants::PRICE_XC;
else if(i == MTGSetInfo::UNCOMMON)
price += booster[i] * Constants::PRICE_XU;
else
price += booster[i] * Constants::PRICE_XR;
}
price += price + PriceList::difficultyScalar(price,setlist.findSet(id));
return (price/3); //Boosters only 33% influenced by economic difficulty.
}
string MTGSetInfo::getName(){ string MTGSetInfo::getName(){
if(name.size()) if(name.size())
return _(name); //Pretty name is translated. return _(name); //Pretty name is translated.
@@ -926,8 +908,6 @@ string MTGSetInfo::getBlock(){
return setlist.blocks[block]; return setlist.blocks[block];
} }
void MTGSetInfo::processConfLine(string line){ void MTGSetInfo::processConfLine(string line){
size_t i = line.find_first_of("="); size_t i = line.find_first_of("=");
if (i == string::npos) if (i == string::npos)

View File

@@ -11,6 +11,8 @@
#include "../include/MTGPack.h" #include "../include/MTGPack.h"
#include "../../../JGE/src/tinyxml/tinyxml.h" #include "../../../JGE/src/tinyxml/tinyxml.h"
MTGPack MTGPacks::defaultBooster;
int MTGPackEntryRandom::addCard(WSrcCards *pool, MTGDeck *to){ int MTGPackEntryRandom::addCard(WSrcCards *pool, MTGDeck *to){
int fails = 0; int fails = 0;
if(!pool) return 1; if(!pool) return 1;
@@ -39,7 +41,7 @@ int MTGPackSlot::add(WSrcCards * ocean, MTGDeck *to, int carryover){
int amt = copies + carryover; int amt = copies + carryover;
WSrcCards * myPool = NULL; WSrcCards * myPool = NULL;
if(pool.size()) if(pool.size())
MTGPack::getPool(pool); myPool = MTGPack::getPool(pool);
if(!myPool) myPool = ocean; if(!myPool) myPool = ocean;
for(int i=0;i<amt;i++){ for(int i=0;i<amt;i++){
size_t pos = rand() % entries.size(); size_t pos = rand() % entries.size();
@@ -90,8 +92,8 @@ void MTGPackSlot::addEntry(MTGPackEntry*item){
int MTGPack::assemblePack(MTGDeck *to){ int MTGPack::assemblePack(MTGDeck *to){
int carryover = 0; int carryover = 0;
WSrcCards * p = getPool(pool); WSrcCards * p = getPool(pool);
if(!p) if(!p) return -1;
return -1; p->Shuffle();
for(size_t i=0;i<slots.size();i++){ for(size_t i=0;i<slots.size();i++){
carryover = slots[i]->add(p,to,carryover); carryover = slots[i]->add(p,to,carryover);
@@ -140,7 +142,9 @@ void MTGPack::load(string filename){
holder = pPack->Attribute("pool"); holder = pPack->Attribute("pool");
if(holder) pool = holder; else pool = ""; if(holder) pool = holder; else pool = "";
holder = pPack->Attribute("type"); holder = pPack->Attribute("type");
if(holder) type = holder; else type = "Booster"; if(holder){
type = holder;
}else type = "Booster";
holder = pPack->Attribute("name"); holder = pPack->Attribute("name");
if(holder) name = holder; else name = "Special"; if(holder) name = holder; else name = "Special";
holder = pPack->Attribute("requires"); holder = pPack->Attribute("requires");
@@ -160,6 +164,8 @@ void MTGPack::load(string filename){
holder = pSlot->Attribute("copies"); holder = pSlot->Attribute("copies");
if(holder) s->copies = atoi(holder); if(holder) s->copies = atoi(holder);
else s->copies = 1; else s->copies = 1;
holder = pSlot->Attribute("pool");
if(holder) s->pool = holder;
for(pEntry = pSlot->FirstChildElement();pEntry!=NULL;pEntry=pEntry->NextSiblingElement()){ for(pEntry = pSlot->FirstChildElement();pEntry!=NULL;pEntry=pEntry->NextSiblingElement()){
tag = pEntry->Value(); tag = pEntry->Value();
@@ -221,7 +227,8 @@ void MTGPacks::loadAll(){
while ((mDit = readdir(mDip))){ while ((mDit = readdir(mDip))){
char myFilename[4096]; char myFilename[4096];
sprintf(myFilename, RESPATH"/packs/%s", mDit->d_name); sprintf(myFilename, RESPATH"/packs/%s", mDit->d_name);
if(myFilename[0] == '.') continue; if(mDit->d_name[0] == '.') continue;
if(!strcmp(mDit->d_name,"default_booster.txt")) continue;
MTGPack * p = NEW MTGPack(myFilename); MTGPack * p = NEW MTGPack(myFilename);
if(!p->isValid()){ if(!p->isValid()){
SAFE_DELETE(p); SAFE_DELETE(p);
@@ -267,6 +274,32 @@ bool MTGPack::isUnlocked(){
return (unlockStatus > 0); return (unlockStatus > 0);
} }
MTGPack * MTGPacks::getDefault(){
if(!defaultBooster.isValid()){
defaultBooster.load(RESPATH"/packs/default_booster.txt");
defaultBooster.unlockStatus = 1;
}
if(!defaultBooster.isValid()){
MTGPackSlot * ps = NEW MTGPackSlot(); ps->copies = 1;
ps->addEntry(NEW MTGPackEntryRandom("rarity:mythic;"));
for(int i=0;i<7;i++)
ps->addEntry(NEW MTGPackEntryRandom("rarity:rare;"));
defaultBooster.slots.push_back(ps);
ps = NEW MTGPackSlot(); ps->copies = 3;
ps->addEntry(NEW MTGPackEntryRandom("rarity:uncommon;"));
defaultBooster.slots.push_back(ps);
ps = NEW MTGPackSlot(); ps->copies = 1;
ps->addEntry(NEW MTGPackEntryRandom("rarity:land;"));
defaultBooster.slots.push_back(ps);
ps = NEW MTGPackSlot(); ps->copies = 10;
ps->addEntry(NEW MTGPackEntryRandom("rarity:common;"));
defaultBooster.slots.push_back(ps);
defaultBooster.bValid = true;
defaultBooster.unlockStatus = 1;
}
return &defaultBooster;
}
void MTGPacks::refreshUnlocked(){ void MTGPacks::refreshUnlocked(){
for(size_t t=0;t<packs.size();t++){ for(size_t t=0;t<packs.size();t++){
if(packs[t]->unlockStatus < 0) if(packs[t]->unlockStatus < 0)

View File

@@ -47,6 +47,9 @@ int PriceList::getPrice(int cardId){
case Constants::RARITY_M: case Constants::RARITY_M:
return Constants::PRICE_1M; return Constants::PRICE_1M;
break; break;
case Constants::RARITY_S:
return Constants::PRICE_1S;
break;
case Constants::RARITY_R: case Constants::RARITY_R:
return Constants::PRICE_1R; return Constants::PRICE_1R;
break; break;

View File

@@ -511,6 +511,7 @@ int WCSortRarity::rareToInt(char r){
case Constants::RARITY_U: return 3; case Constants::RARITY_U: return 3;
case Constants::RARITY_R: return 4; case Constants::RARITY_R: return 4;
case Constants::RARITY_M: return 5; case Constants::RARITY_M: return 5;
case Constants::RARITY_S: return 6;
} }
} }
bool WCSortRarity::operator()(const MTGCard*l, const MTGCard*r){ bool WCSortRarity::operator()(const MTGCard*l, const MTGCard*r){

View File

@@ -298,13 +298,15 @@ float WCFilterRarity::filterFee(){
bool WCFilterRarity::isMatch(MTGCard * c){ bool WCFilterRarity::isMatch(MTGCard * c){
if(!c || !c->data) if(!c || !c->data)
return false; return false;
if(rarity == 'A') return true; //A for "Any" or "All"
return (c->getRarity() == rarity); return (c->getRarity() == rarity);
} }
string WCFilterRarity::getCode(){ string WCFilterRarity::getCode(){
char buf[64]; char buf[64];
const char* rarities[7] = {"any","token","land","common","uncommon","rare","mythic"}; const char* rarities[8] = {"any","token","land","common","uncommon","rare","mythic","special"};
int x = 0; int x = 0;
switch(rarity){ switch(rarity){
case 'S': x=7; break;
case 'M': x=6; break; case 'M': x=6; break;
case 'R': x=5; break; case 'R': x=5; break;
case 'U': x=4; break; case 'U': x=4; break;
@@ -319,6 +321,7 @@ WCFilterRarity::WCFilterRarity(string arg){
rarity = -1; rarity = -1;
char c = toupper(arg[0]); char c = toupper(arg[0]);
switch(c){ switch(c){
case 'S':
case 'M': case 'M':
case 'R': case 'R':
case 'U': case 'U':
@@ -326,8 +329,9 @@ WCFilterRarity::WCFilterRarity(string arg){
case 'L': case 'L':
case 'T': case 'T':
rarity = c; rarity = c;
break; return;
} }
rarity = 'A';
} }
//WCFilterAbility //WCFilterAbility
bool WCFilterAbility::isMatch(MTGCard * c){ bool WCFilterAbility::isMatch(MTGCard * c){

View File

@@ -1621,6 +1621,7 @@ void WGuiFilterItem::updateValue(){
mParent->addArg("Rare","r:r;"); mParent->addArg("Rare","r:r;");
mParent->addArg("Uncommon","r:u;"); mParent->addArg("Uncommon","r:u;");
mParent->addArg("Common","r:c;"); mParent->addArg("Common","r:c;");
mParent->addArg("Special Rarity","{r:m;|r:t;|r:r;|r:u;|r:c;}");
}else if(filterType == FILTER_CMC){ }else if(filterType == FILTER_CMC){
for(int i=0;i<20;i++){ for(int i=0;i<20;i++){
sprintf(buf_code,"cmc:%i;",i); sprintf(buf_code,"cmc:%i;",i);