Erwan
- a few shop changes
This commit is contained in:
@@ -26,7 +26,7 @@ class GameStateShop: public GameState, public JGuiListener
|
||||
SimpleMenu * menu;
|
||||
int mStage;
|
||||
char starterBuffer[128], boosterBuffer[128];
|
||||
int setId;
|
||||
int setIds[2];
|
||||
|
||||
public:
|
||||
GameStateShop(GameApp* parent);
|
||||
|
||||
@@ -51,12 +51,12 @@ class ShopItems:public JGuiController,public JGuiListener{
|
||||
MTGAllCards * collection;
|
||||
SimpleMenu * dialog;
|
||||
int showPriceDialog;
|
||||
int setId;
|
||||
int setIds[2];;
|
||||
MTGCardInstance * displayCards[100];
|
||||
CardDisplay * display;
|
||||
void safeDeleteDisplay();
|
||||
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();
|
||||
void Render();
|
||||
virtual void Update(float dt);
|
||||
|
||||
@@ -70,9 +70,9 @@ void GameStateOptions::Render()
|
||||
|
||||
const char * const CreditsText[] = {
|
||||
"Wagic, The Homebrew ?! by WilLoW",
|
||||
"This is a work in progress and it contains bugs",
|
||||
"updates on http://www.wololo.net/wagic",
|
||||
"Many thanks to the programmers and card creators who helped in this release",
|
||||
"",
|
||||
"updates, new cards, and more on http://www.wololo.net/wagic",
|
||||
"Many thanks to the devs and card creators who help this project",
|
||||
"",
|
||||
"Developped with the JGE++ Library (http://jge.khors.com)",
|
||||
"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",
|
||||
"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",
|
||||
};
|
||||
|
||||
@@ -49,20 +49,22 @@ void GameStateShop::Start()
|
||||
}
|
||||
}
|
||||
if (nbsets){
|
||||
setId = sets[(rand() % nbsets)];
|
||||
setIds[0] = sets[(rand() % nbsets)];
|
||||
setIds[1] = sets[(rand() % nbsets)];
|
||||
}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");
|
||||
|
||||
shop = NULL;
|
||||
|
||||
shop = NEW ShopItems(10, this, itemFont, 10, 10, mParent->collection, setId);
|
||||
sprintf(starterBuffer, "%s Starter (60 cards)",MtgSets::SetsList->values[setId].c_str());
|
||||
sprintf(boosterBuffer, "%s Booster (15 cards)",MtgSets::SetsList->values[setId].c_str());
|
||||
shop->Add(starterBuffer,mBack,mBackThumb, 6000);
|
||||
shop = NEW ShopItems(10, this, itemFont, 10, 0, mParent->collection, setIds);
|
||||
sprintf(starterBuffer, "%s Booster (15 cards)",MtgSets::SetsList->values[setIds[0]].c_str());
|
||||
sprintf(boosterBuffer, "%s Booster (15 cards)",MtgSets::SetsList->values[setIds[1]].c_str());
|
||||
shop->Add(starterBuffer,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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
showPriceDialog = -1;
|
||||
dialog = NULL;
|
||||
pricelist = NEW PriceList(RESPATH"/settings/prices.dat",_collection);
|
||||
playerdata = NEW PlayerData(_collection);
|
||||
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);
|
||||
price = price + price * (rnd -10)/100;
|
||||
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){
|
||||
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){
|
||||
@@ -216,20 +219,20 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
|
||||
playerdata->collection->add(item->card);
|
||||
item->quantity--;
|
||||
}else{
|
||||
safeDeleteDisplay();
|
||||
display = new CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5);
|
||||
int curNbcards = playerdata->collection->totalCards();
|
||||
if (showPriceDialog == 0){
|
||||
//Starter Deck
|
||||
playerdata->collection->addRandomCards(3,setId,Constants::RARITY_R,NULL);
|
||||
playerdata->collection->addRandomCards(9, setId,Constants::RARITY_U,NULL);
|
||||
playerdata->collection->addRandomCards(48, setId,Constants::RARITY_C,NULL);
|
||||
}else{
|
||||
//Booster
|
||||
playerdata->collection->addRandomCards(1, setId,Constants::RARITY_R);
|
||||
playerdata->collection->addRandomCards(3, setId,Constants::RARITY_U);
|
||||
playerdata->collection->addRandomCards(11, setId,Constants::RARITY_C);
|
||||
}
|
||||
safeDeleteDisplay();
|
||||
display = new CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5);
|
||||
int curNbcards = playerdata->collection->totalCards();
|
||||
//if (showPriceDialog == 0){
|
||||
// //Starter Deck
|
||||
// playerdata->collection->addRandomCards(3,setId,Constants::RARITY_R,NULL);
|
||||
// playerdata->collection->addRandomCards(9, setId,Constants::RARITY_U,NULL);
|
||||
// playerdata->collection->addRandomCards(48, setId,Constants::RARITY_C,NULL);
|
||||
//}else{
|
||||
//Booster
|
||||
playerdata->collection->addRandomCards(1, setIds[showPriceDialog],Constants::RARITY_R);
|
||||
playerdata->collection->addRandomCards(3, setIds[showPriceDialog],Constants::RARITY_U);
|
||||
playerdata->collection->addRandomCards(11, setIds[showPriceDialog],Constants::RARITY_C);
|
||||
// }
|
||||
int newNbCards = playerdata->collection->totalCards();;
|
||||
for (int i = curNbcards; i < newNbCards ; i++){
|
||||
MTGCardInstance * card = NEW MTGCardInstance(playerdata->collection->_(i), NULL);
|
||||
|
||||
Reference in New Issue
Block a user