- a few shop changes
This commit is contained in:
wagic.the.homebrew
2009-03-14 11:52:50 +00:00
parent 658ef1fb12
commit 0256e64cd9
5 changed files with 36 additions and 31 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ class GameStateShop: public GameState, public JGuiListener
SimpleMenu * menu; SimpleMenu * menu;
int mStage; int mStage;
char starterBuffer[128], boosterBuffer[128]; char starterBuffer[128], boosterBuffer[128];
int setId; int setIds[2];
public: public:
GameStateShop(GameApp* parent); GameStateShop(GameApp* parent);
+2 -2
View File
@@ -51,12 +51,12 @@ class ShopItems:public JGuiController,public JGuiListener{
MTGAllCards * collection; MTGAllCards * collection;
SimpleMenu * dialog; SimpleMenu * dialog;
int showPriceDialog; int showPriceDialog;
int setId; int setIds[2];;
MTGCardInstance * displayCards[100]; MTGCardInstance * displayCards[100];
CardDisplay * display; CardDisplay * display;
void safeDeleteDisplay(); void safeDeleteDisplay();
public: public:
ShopItems(int id, JGuiListener* listener, JLBFont* font, int x, int y, MTGAllCards * _collection, int setId); ShopItems(int id, JGuiListener* listener, JLBFont* font, int x, int y, MTGAllCards * _collection, int _setIds[]);
~ShopItems(); ~ShopItems();
void Render(); void Render();
virtual void Update(float dt); virtual void Update(float dt);
+4 -4
View File
@@ -70,9 +70,9 @@ void GameStateOptions::Render()
const char * const CreditsText[] = { const char * const CreditsText[] = {
"Wagic, The Homebrew ?! by WilLoW", "Wagic, The Homebrew ?! by WilLoW",
"This is a work in progress and it contains bugs", "",
"updates on http://www.wololo.net/wagic", "updates, new cards, and more on http://www.wololo.net/wagic",
"Many thanks to the programmers and card creators who helped in this release", "Many thanks to the devs and card creators who help this project",
"", "",
"Developped with the JGE++ Library (http://jge.khors.com)", "Developped with the JGE++ Library (http://jge.khors.com)",
"Player's avatar from http://mathieuchoinet.blogspot.com, under CC License", "Player's avatar from http://mathieuchoinet.blogspot.com, under CC License",
@@ -82,7 +82,7 @@ void GameStateOptions::Render()
"Music by Celestial Aeon Project, under Creative Commons License", "Music by Celestial Aeon Project, under Creative Commons License",
"Their music can be downloaded at http://www.jamendo.com", "Their music can be downloaded at http://www.jamendo.com",
"", "",
"This work is not related to or endoresed by Wizards of the Coast, Inc", "This work is not related to or endorsed by Wizards of the Coast, Inc",
"", "",
"Please support this project with donations at http://wololo.net/wagic", "Please support this project with donations at http://wololo.net/wagic",
}; };
+9 -7
View File
@@ -49,20 +49,22 @@ void GameStateShop::Start()
} }
} }
if (nbsets){ if (nbsets){
setId = sets[(rand() % nbsets)]; setIds[0] = sets[(rand() % nbsets)];
setIds[1] = sets[(rand() % nbsets)];
}else{ }else{
setId = (rand() % MtgSets::SetsList->nb_items); setIds[0] = (rand() % MtgSets::SetsList->nb_items);
setIds[1] = (rand() % MtgSets::SetsList->nb_items);
} }
JQuad * mBackThumb = GameApp::CommonRes->GetQuad("back_thumb"); JQuad * mBackThumb = GameApp::CommonRes->GetQuad("back_thumb");
shop = NULL; shop = NULL;
shop = NEW ShopItems(10, this, itemFont, 10, 10, mParent->collection, setId); shop = NEW ShopItems(10, this, itemFont, 10, 0, mParent->collection, setIds);
sprintf(starterBuffer, "%s Starter (60 cards)",MtgSets::SetsList->values[setId].c_str()); sprintf(starterBuffer, "%s Booster (15 cards)",MtgSets::SetsList->values[setIds[0]].c_str());
sprintf(boosterBuffer, "%s Booster (15 cards)",MtgSets::SetsList->values[setId].c_str()); sprintf(boosterBuffer, "%s Booster (15 cards)",MtgSets::SetsList->values[setIds[1]].c_str());
shop->Add(starterBuffer,mBack,mBackThumb, 6000); shop->Add(starterBuffer,mBack,mBackThumb, 1900);
shop->Add(boosterBuffer,mBack,mBackThumb, 1900); shop->Add(boosterBuffer,mBack,mBackThumb, 1900);
for (int i = 0; i < 4; i++){ for (int i = 0; i < 5; i++){
shop->Add(mParent->collection->randomCardId()); shop->Add(mParent->collection->randomCardId());
} }
+20 -17
View File
@@ -119,13 +119,16 @@ bool ShopItem::ButtonPressed()
} }
ShopItems::ShopItems(int id, JGuiListener* listener, JLBFont* font, int x, int y, MTGAllCards * _collection, int _setId): JGuiController(id, listener), mX(x), mY(y), mFont(font), collection(_collection), setId(_setId){ ShopItems::ShopItems(int id, JGuiListener* listener, JLBFont* font, int x, int y, MTGAllCards * _collection, int _setIds[]): JGuiController(id, listener), mX(x), mY(y), mFont(font), collection(_collection){
mHeight = 0; mHeight = 0;
showPriceDialog = -1; showPriceDialog = -1;
dialog = NULL; dialog = NULL;
pricelist = NEW PriceList(RESPATH"/settings/prices.dat",_collection); pricelist = NEW PriceList(RESPATH"/settings/prices.dat",_collection);
playerdata = NEW PlayerData(_collection); playerdata = NEW PlayerData(_collection);
display = NULL; display = NULL;
for (int i=0; i < 2; i++){
setIds[i] = _setIds[i];
};
} }
@@ -135,12 +138,12 @@ void ShopItems::Add(int cardid){
int price = pricelist->getPrice(cardid); int price = pricelist->getPrice(cardid);
price = price + price * (rnd -10)/100; price = price + price * (rnd -10)/100;
JGuiController::Add(NEW ShopItem(mCount, mFont, cardid, mX + 10, mY + 10 + mHeight, (mCount == 0),collection, price)); JGuiController::Add(NEW ShopItem(mCount, mFont, cardid, mX + 10, mY + 10 + mHeight, (mCount == 0),collection, price));
mHeight += 40; mHeight += 38;
} }
void ShopItems::Add(char * text, JQuad * quad,JQuad * thumb, int price){ void ShopItems::Add(char * text, JQuad * quad,JQuad * thumb, int price){
JGuiController::Add(NEW ShopItem(mCount, mFont, text, quad, thumb, mX + 10, mY + 10 + mHeight, (mCount == 0), price)); JGuiController::Add(NEW ShopItem(mCount, mFont, text, quad, thumb, mX + 10, mY + 10 + mHeight, (mCount == 0), price));
mHeight += 40; mHeight += 38;
} }
void ShopItems::Update(float dt){ void ShopItems::Update(float dt){
@@ -216,20 +219,20 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
playerdata->collection->add(item->card); playerdata->collection->add(item->card);
item->quantity--; item->quantity--;
}else{ }else{
safeDeleteDisplay(); safeDeleteDisplay();
display = new CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5); display = new CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5);
int curNbcards = playerdata->collection->totalCards(); int curNbcards = playerdata->collection->totalCards();
if (showPriceDialog == 0){ //if (showPriceDialog == 0){
//Starter Deck // //Starter Deck
playerdata->collection->addRandomCards(3,setId,Constants::RARITY_R,NULL); // playerdata->collection->addRandomCards(3,setId,Constants::RARITY_R,NULL);
playerdata->collection->addRandomCards(9, setId,Constants::RARITY_U,NULL); // playerdata->collection->addRandomCards(9, setId,Constants::RARITY_U,NULL);
playerdata->collection->addRandomCards(48, setId,Constants::RARITY_C,NULL); // playerdata->collection->addRandomCards(48, setId,Constants::RARITY_C,NULL);
}else{ //}else{
//Booster //Booster
playerdata->collection->addRandomCards(1, setId,Constants::RARITY_R); playerdata->collection->addRandomCards(1, setIds[showPriceDialog],Constants::RARITY_R);
playerdata->collection->addRandomCards(3, setId,Constants::RARITY_U); playerdata->collection->addRandomCards(3, setIds[showPriceDialog],Constants::RARITY_U);
playerdata->collection->addRandomCards(11, setId,Constants::RARITY_C); playerdata->collection->addRandomCards(11, setIds[showPriceDialog],Constants::RARITY_C);
} // }
int newNbCards = playerdata->collection->totalCards();; int newNbCards = playerdata->collection->totalCards();;
for (int i = curNbcards; i < newNbCards ; i++){ for (int i = curNbcards; i < newNbCards ; i++){
MTGCardInstance * card = NEW MTGCardInstance(playerdata->collection->_(i), NULL); MTGCardInstance * card = NEW MTGCardInstance(playerdata->collection->_(i), NULL);