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:
21
projects/mtg/bin/Res/sets/TSP/booster.txt
Normal file
21
projects/mtg/bin/Res/sets/TSP/booster.txt
Normal 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>
|
||||
@@ -14,10 +14,11 @@ using std::string;
|
||||
class GameApp;
|
||||
class MTGCard;
|
||||
class CardPrimitive;
|
||||
|
||||
class MTGPack;
|
||||
class MTGSetInfo{
|
||||
public:
|
||||
MTGSetInfo(string _id);
|
||||
~MTGSetInfo();
|
||||
string id; //Short name: 10E, RAV, etc. Automatic from folder.
|
||||
string author; //Author of set, for crediting mod makers, etc.
|
||||
string name; //Long name: Tenth Edition
|
||||
@@ -30,8 +31,6 @@ public:
|
||||
int totalCards();
|
||||
string getName();
|
||||
string getBlock();
|
||||
int boosterCost();
|
||||
int boosterSize();
|
||||
void processConfLine(string line);
|
||||
|
||||
enum {
|
||||
@@ -46,10 +45,10 @@ public:
|
||||
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 bThemeZipped; //[...] in the theme?
|
||||
int counts[MTGSetInfo::MAX_COUNT];
|
||||
int booster[MAX_RARITY];
|
||||
int counts[MTGSetInfo::MAX_COUNT];
|
||||
};
|
||||
|
||||
class MTGSets{
|
||||
|
||||
@@ -107,6 +107,7 @@ class Constants
|
||||
NB_BASIC_ABILITIES = 48,
|
||||
|
||||
|
||||
RARITY_S = 'S', //Special Rarity
|
||||
RARITY_M = 'M', //Mythics
|
||||
RARITY_R = 'R', //Rares
|
||||
RARITY_U = 'U', //Uncommons
|
||||
@@ -122,6 +123,7 @@ class Constants
|
||||
//Price for singles
|
||||
PRICE_1M = 3000,
|
||||
PRICE_1R = 500,
|
||||
PRICE_1S = 200,
|
||||
PRICE_1U = 100,
|
||||
PRICE_1C = 20,
|
||||
PRICE_1L = 5,
|
||||
@@ -132,10 +134,6 @@ class Constants
|
||||
CHANCE_CUSTOM_PACK = 15,
|
||||
CHANCE_PURE_OVERRIDE = 50,
|
||||
CHANCE_MIXED_OVERRIDE = 25,
|
||||
PRICE_XR = 355,
|
||||
PRICE_XU = 88,
|
||||
PRICE_XC = 8,
|
||||
PRICE_XL = 1,
|
||||
|
||||
MAIN_FONT = 0,
|
||||
MENU_FONT = 1,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef _MTGPACCK_H_
|
||||
#define _MTGPACK_H_
|
||||
|
||||
class ShopBooster;
|
||||
|
||||
class MTGPackEntry{
|
||||
public:
|
||||
virtual int addCard(WSrcCards * pool,MTGDeck * to) = 0;
|
||||
@@ -9,6 +11,8 @@ public:
|
||||
|
||||
class MTGPackEntryRandom: public MTGPackEntry{
|
||||
public:
|
||||
MTGPackEntryRandom() {filter = ""; copies=1;};
|
||||
MTGPackEntryRandom(string f, int c=1) {filter = f; copies = c;};
|
||||
int addCard(WSrcCards * pool,MTGDeck * to);
|
||||
string filter;
|
||||
};
|
||||
@@ -36,13 +40,16 @@ public:
|
||||
class MTGPack{
|
||||
public:
|
||||
friend class MTGPacks;
|
||||
friend class ShopBooster;
|
||||
friend class MTGSetInfo;
|
||||
bool meetsRequirements(); //Check if pool contains locked cards.
|
||||
bool isUnlocked();
|
||||
bool isValid() {return bValid;};
|
||||
void load(string filename);
|
||||
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();
|
||||
string getName();
|
||||
string getSort() {return sort;};
|
||||
@@ -72,8 +79,9 @@ public:
|
||||
int size() {return (int)packs.size();};
|
||||
void refreshUnlocked();
|
||||
|
||||
|
||||
static MTGPack * getDefault();
|
||||
private:
|
||||
static MTGPack defaultBooster;
|
||||
vector<MTGPack*> packs;
|
||||
};
|
||||
#endif
|
||||
@@ -304,8 +304,12 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
|
||||
case Constants::RARITY_L:
|
||||
sprintf(buf,_("%s Land").c_str(),setlist[card->setId].c_str());
|
||||
break;
|
||||
case Constants::RARITY_T:
|
||||
sprintf(buf,_("%s Token").c_str(),setlist[card->setId].c_str());
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -736,9 +736,8 @@ void ShopBooster::randomCustom(MTGPacks * packlist){
|
||||
pack = packlist->randomPack();
|
||||
if(pack && !pack->isUnlocked())
|
||||
pack = NULL;
|
||||
if(!pack){
|
||||
if(!pack)
|
||||
randomStandard();
|
||||
}
|
||||
}
|
||||
void ShopBooster::randomStandard(){
|
||||
int mSet = -1;
|
||||
@@ -763,6 +762,7 @@ void ShopBooster::randomStandard(){
|
||||
altSet = setlist.randomSet(-1,80-mSetCount);
|
||||
}
|
||||
if(altSet == mainSet) altSet = NULL; //Prevent "10E & 10E Booster"
|
||||
if(!altSet) pack = mainSet->mPack;
|
||||
|
||||
}
|
||||
int ShopBooster::maxInventory(){
|
||||
@@ -771,39 +771,15 @@ int ShopBooster::maxInventory(){
|
||||
return 5;
|
||||
}
|
||||
void ShopBooster::addToDeck(MTGDeck * d, WSrcCards * srcCards){
|
||||
|
||||
if(pack){
|
||||
if(!pack){ //A combination booster.
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "../include/Translate.h"
|
||||
#include "../include/DeckMetaData.h"
|
||||
#include "../include/PriceList.h"
|
||||
#include "../include/WDataSrc.h"
|
||||
#include "../include/MTGPack.h"
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
@@ -842,6 +844,10 @@ int MTGSets::size(){
|
||||
}
|
||||
|
||||
//MTGSetInfo
|
||||
MTGSetInfo::~MTGSetInfo(){
|
||||
if(mPack != MTGPacks::getDefault())
|
||||
SAFE_DELETE(mPack);
|
||||
}
|
||||
MTGSetInfo::MTGSetInfo(string _id) {
|
||||
string whitespaces (" \t\f\v\n\r");
|
||||
id = _id;
|
||||
@@ -851,12 +857,14 @@ MTGSetInfo::MTGSetInfo(string _id) {
|
||||
for(int i=0;i<MTGSetInfo::MAX_COUNT;i++)
|
||||
counts[i] = 0;
|
||||
|
||||
booster[MTGSetInfo::LAND] = 1;
|
||||
booster[MTGSetInfo::COMMON] = 10;
|
||||
booster[MTGSetInfo::UNCOMMON] = 3;
|
||||
booster[MTGSetInfo::RARE] = 1;
|
||||
|
||||
//Load metadata. (FIXME - Removed for release 0.1.0, will be fully implemented next release)
|
||||
char myFilename[4096];
|
||||
sprintf(myFilename, RESPATH"/sets/%s/booster.txt", id.c_str());
|
||||
mPack = NEW MTGPack(myFilename);
|
||||
if(!mPack->isValid()){
|
||||
SAFE_DELETE(mPack);
|
||||
}
|
||||
bZipped = false;
|
||||
bThemeZipped = false;
|
||||
}
|
||||
|
||||
void MTGSetInfo::count(MTGCard*c){
|
||||
@@ -889,32 +897,6 @@ int MTGSetInfo::totalCards(){
|
||||
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(){
|
||||
if(name.size())
|
||||
return _(name); //Pretty name is translated.
|
||||
@@ -926,8 +908,6 @@ string MTGSetInfo::getBlock(){
|
||||
|
||||
return setlist.blocks[block];
|
||||
}
|
||||
|
||||
|
||||
void MTGSetInfo::processConfLine(string line){
|
||||
size_t i = line.find_first_of("=");
|
||||
if (i == string::npos)
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "../include/MTGPack.h"
|
||||
#include "../../../JGE/src/tinyxml/tinyxml.h"
|
||||
|
||||
MTGPack MTGPacks::defaultBooster;
|
||||
|
||||
int MTGPackEntryRandom::addCard(WSrcCards *pool, MTGDeck *to){
|
||||
int fails = 0;
|
||||
if(!pool) return 1;
|
||||
@@ -39,7 +41,7 @@ int MTGPackSlot::add(WSrcCards * ocean, MTGDeck *to, int carryover){
|
||||
int amt = copies + carryover;
|
||||
WSrcCards * myPool = NULL;
|
||||
if(pool.size())
|
||||
MTGPack::getPool(pool);
|
||||
myPool = MTGPack::getPool(pool);
|
||||
if(!myPool) myPool = ocean;
|
||||
for(int i=0;i<amt;i++){
|
||||
size_t pos = rand() % entries.size();
|
||||
@@ -90,8 +92,8 @@ void MTGPackSlot::addEntry(MTGPackEntry*item){
|
||||
int MTGPack::assemblePack(MTGDeck *to){
|
||||
int carryover = 0;
|
||||
WSrcCards * p = getPool(pool);
|
||||
if(!p)
|
||||
return -1;
|
||||
if(!p) return -1;
|
||||
p->Shuffle();
|
||||
|
||||
for(size_t i=0;i<slots.size();i++){
|
||||
carryover = slots[i]->add(p,to,carryover);
|
||||
@@ -140,7 +142,9 @@ void MTGPack::load(string filename){
|
||||
holder = pPack->Attribute("pool");
|
||||
if(holder) pool = holder; else pool = "";
|
||||
holder = pPack->Attribute("type");
|
||||
if(holder) type = holder; else type = "Booster";
|
||||
if(holder){
|
||||
type = holder;
|
||||
}else type = "Booster";
|
||||
holder = pPack->Attribute("name");
|
||||
if(holder) name = holder; else name = "Special";
|
||||
holder = pPack->Attribute("requires");
|
||||
@@ -160,6 +164,8 @@ void MTGPack::load(string filename){
|
||||
holder = pSlot->Attribute("copies");
|
||||
if(holder) s->copies = atoi(holder);
|
||||
else s->copies = 1;
|
||||
holder = pSlot->Attribute("pool");
|
||||
if(holder) s->pool = holder;
|
||||
|
||||
for(pEntry = pSlot->FirstChildElement();pEntry!=NULL;pEntry=pEntry->NextSiblingElement()){
|
||||
tag = pEntry->Value();
|
||||
@@ -221,7 +227,8 @@ void MTGPacks::loadAll(){
|
||||
while ((mDit = readdir(mDip))){
|
||||
char myFilename[4096];
|
||||
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);
|
||||
if(!p->isValid()){
|
||||
SAFE_DELETE(p);
|
||||
@@ -267,6 +274,32 @@ bool MTGPack::isUnlocked(){
|
||||
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(){
|
||||
for(size_t t=0;t<packs.size();t++){
|
||||
if(packs[t]->unlockStatus < 0)
|
||||
|
||||
@@ -47,6 +47,9 @@ int PriceList::getPrice(int cardId){
|
||||
case Constants::RARITY_M:
|
||||
return Constants::PRICE_1M;
|
||||
break;
|
||||
case Constants::RARITY_S:
|
||||
return Constants::PRICE_1S;
|
||||
break;
|
||||
case Constants::RARITY_R:
|
||||
return Constants::PRICE_1R;
|
||||
break;
|
||||
|
||||
@@ -511,6 +511,7 @@ int WCSortRarity::rareToInt(char r){
|
||||
case Constants::RARITY_U: return 3;
|
||||
case Constants::RARITY_R: return 4;
|
||||
case Constants::RARITY_M: return 5;
|
||||
case Constants::RARITY_S: return 6;
|
||||
}
|
||||
}
|
||||
bool WCSortRarity::operator()(const MTGCard*l, const MTGCard*r){
|
||||
|
||||
@@ -298,13 +298,15 @@ float WCFilterRarity::filterFee(){
|
||||
bool WCFilterRarity::isMatch(MTGCard * c){
|
||||
if(!c || !c->data)
|
||||
return false;
|
||||
if(rarity == 'A') return true; //A for "Any" or "All"
|
||||
return (c->getRarity() == rarity);
|
||||
}
|
||||
string WCFilterRarity::getCode(){
|
||||
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;
|
||||
switch(rarity){
|
||||
case 'S': x=7; break;
|
||||
case 'M': x=6; break;
|
||||
case 'R': x=5; break;
|
||||
case 'U': x=4; break;
|
||||
@@ -319,6 +321,7 @@ WCFilterRarity::WCFilterRarity(string arg){
|
||||
rarity = -1;
|
||||
char c = toupper(arg[0]);
|
||||
switch(c){
|
||||
case 'S':
|
||||
case 'M':
|
||||
case 'R':
|
||||
case 'U':
|
||||
@@ -326,8 +329,9 @@ WCFilterRarity::WCFilterRarity(string arg){
|
||||
case 'L':
|
||||
case 'T':
|
||||
rarity = c;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
rarity = 'A';
|
||||
}
|
||||
//WCFilterAbility
|
||||
bool WCFilterAbility::isMatch(MTGCard * c){
|
||||
|
||||
@@ -1621,6 +1621,7 @@ void WGuiFilterItem::updateValue(){
|
||||
mParent->addArg("Rare","r:r;");
|
||||
mParent->addArg("Uncommon","r:u;");
|
||||
mParent->addArg("Common","r:c;");
|
||||
mParent->addArg("Special Rarity","{r:m;|r:t;|r:r;|r:u;|r:c;}");
|
||||
}else if(filterType == FILTER_CMC){
|
||||
for(int i=0;i<20;i++){
|
||||
sprintf(buf_code,"cmc:%i;",i);
|
||||
|
||||
Reference in New Issue
Block a user