Jeck - Added custom booster packs (see miki), numerous small fixes. Once we hit feature-freeze I'll be reviewing this stuff in depth, as again there's likely a lot of room for cleaning... just wanted to get it in first :).

I cut some bits out that weren't ready for SVN, hopefully I've committed everything correctly.
This commit is contained in:
wagic.jeck
2010-02-11 18:32:44 +00:00
parent 103a3d2822
commit ab34fc16f9
31 changed files with 1013 additions and 134 deletions
+17 -2
View File
@@ -27,7 +27,22 @@
#define SHOP_ITEMS SHOP_SLOTS+1
#define LIST_FADEIN 15
struct ShopBooster{
class MTGPack;
class MTGPacks;
class ShopBooster{
public:
ShopBooster();
string getName();
void randomize(MTGPacks * packlist);
int basePrice();
int maxInventory();
void addToDeck(MTGDeck * d, WSrcCards * srcCards);
string getSort();
private:
void randomCustom(MTGPacks * packlist);
void randomStandard();
MTGPack * pack;
MTGSetInfo * mainSet;
MTGSetInfo * altSet;
};
@@ -58,6 +73,7 @@ class GameStateShop: public GameState, public JGuiListener
SimpleMenu * menu;
PriceList * pricelist;
PlayerData * playerdata;
MTGPacks * packlist;
bool mTouched;
bool needLoad;
int mPrices[SHOP_ITEMS];
@@ -75,7 +91,6 @@ class GameStateShop: public GameState, public JGuiListener
void load();
void save(bool force=false);
void updateCounts();
void assembleBooster(int controlId);
void beginPurchase(int controlId);
void purchaseCard(int controlId);
void purchaseBooster(int controlId);
+4 -8
View File
@@ -35,18 +35,14 @@ class MTGCard {
MTGCard(MTGCard * source);
void setMTGId(int id);
int getMTGId();
int getId();
char getRarity();
void setRarity(char _rarity);
//void setImageName( char * value);
char * getImageName ();
void setPrimitive(CardPrimitive * cp);
int getMTGId() const;
int getId() const;
char getRarity() const;
char * getImageName();
};
+5 -1
View File
@@ -127,7 +127,11 @@ class Constants
PRICE_1L = 5,
//Price in booster
PRICE_XM = 2500,
PRICE_BOOSTER = 700,
PRICE_MIXED_BOOSTER = 800,
CHANCE_CUSTOM_PACK = 15,
CHANCE_PURE_OVERRIDE = 50,
CHANCE_MIXED_OVERRIDE = 25,
PRICE_XR = 355,
PRICE_XU = 88,
PRICE_XC = 8,
+79
View File
@@ -0,0 +1,79 @@
#ifndef _MTGPACCK_H_
#define _MTGPACK_H_
class MTGPackEntry{
public:
virtual int addCard(WSrcCards * pool,MTGDeck * to) = 0;
int copies;
};
class MTGPackEntryRandom: public MTGPackEntry{
public:
int addCard(WSrcCards * pool,MTGDeck * to);
string filter;
};
class MTGPackEntrySpecific: public MTGPackEntry{
public:
int addCard(WSrcCards * pool,MTGDeck * to);
MTGCard * card;
};
class MTGPackEntryNothing: public MTGPackEntry{
public:
int addCard(WSrcCards * pool,MTGDeck * to) {return 0;};
};
class MTGPackSlot{
public:
~MTGPackSlot();
int add(WSrcCards * ocean, MTGDeck * to, int carryover);
void addEntry(MTGPackEntry*item);
int copies;
string pool;
vector<MTGPackEntry*> entries;
};
class MTGPack{
public:
friend class MTGPacks;
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();
string getName();
string getSort() {return sort;};
int getPrice() {return price;};
static WSrcCards * getPool(string poolstr);
protected:
void countCards();
string name; //Name of the pack.
string type; //"Booster", "Deck", "Whatever"
string pool; //The starting pool.
string sort; //The sorting method.
string check; //Unlock requirements.
string desc; //Big card description.
bool bValid;
int unlockStatus;
int price; //Base price.
int minCards, maxCards;
vector<MTGPackSlot*> slots;
};
class MTGPacks{
public:
~MTGPacks();
MTGPack * randomPack(int key=0);
void loadAll();
int size() {return (int)packs.size();};
void refreshUnlocked();
private:
vector<MTGPack*> packs;
};
#endif
+2 -1
View File
@@ -21,7 +21,8 @@ class PriceList{
int getSellPrice(int cardid);
int getPurchasePrice(int cardid);
int getPrice(int cardId);
int setPrice(int cardId, int price);
int setPrice(int cardId,int price);
int getOtherPrice(int amt);
static float difficultyScalar(float price, int cardid=0);
static void updateKey() {randomKey = rand();};
};
+16 -2
View File
@@ -5,8 +5,10 @@ class WCardFilter;
struct WCardSort;
struct WDistort;
class PriceList;
class MTGCard;
class MTGDeck;
class MTGAllCards;
class JQuad;
class WSyncable{
public:
@@ -69,22 +71,29 @@ public:
virtual void Sort(int method);
virtual bool setOffset(int pos);
virtual bool isEmptySet(WCardFilter * f);
virtual void addFilter(WCardFilter * f);
virtual void clearFilters();
virtual WCardFilter* unhookFilters();
virtual bool matchesFilters(MTGCard * c);
virtual void validateFilters();
virtual void bakeFilters(); //Discards all invalidated cards.
virtual float filterFee();
virtual int addToDeck(MTGDeck * i, int num=-1); //Returns num that didn't add
//Loads into us.
virtual int loadMatches(MTGAllCards* ac); //loadMatches adds the cards from something
virtual int loadMatches(MTGDeck * deck); //into this, if it matches our filter
virtual int loadMatches(WSrcCards* src, bool all=false); //If all==true, ignore filters on src.
//We load it
virtual int addRandomCards(MTGDeck * i, int howmany=1);
virtual int addToDeck(MTGDeck * i, int num=-1); //Returns num that didn't add
enum {
MAX_CYCLES = 4, //How many cycles to search, for addToDeck
SORT_COLLECTOR,
SORT_ALPHA
SORT_ALPHA,
SORT_RARITY
};
protected:
vector<MTGCard*> cards;
@@ -122,5 +131,10 @@ struct WCSortAlpha{
bool operator()(const MTGCard*l, const MTGCard*r);
};
struct WCSortRarity{
int rareToInt(char r);
bool operator()(const MTGCard*l, const MTGCard*r);
};
#endif
+2 -2
View File
@@ -8,11 +8,11 @@ public:
WCFilterFactory() {};
static WCFilterFactory * GetInstance();
static void Destroy();
WCardFilter * Construct(string x);
WCardFilter * Construct(string src);
private:
size_t findNext(string src, size_t start, char open='(', char close=')');
WCardFilter * Leaf(string src);
WCardFilter * Terminal(string type, string arg);
WCardFilter * Terminal(string src, string arg);
static WCFilterFactory * me;
};