diff --git a/projects/mtg/bin/Res/graphics/smallface.dat b/projects/mtg/bin/Res/graphics/smallface.dat new file mode 100644 index 000000000..adddccfd2 Binary files /dev/null and b/projects/mtg/bin/Res/graphics/smallface.dat differ diff --git a/projects/mtg/bin/Res/graphics/smallface.png b/projects/mtg/bin/Res/graphics/smallface.png new file mode 100644 index 000000000..e3d155039 Binary files /dev/null and b/projects/mtg/bin/Res/graphics/smallface.png differ diff --git a/projects/mtg/bin/Res/sets/10E/_cards.dat b/projects/mtg/bin/Res/sets/10E/_cards.dat index d3f88ecb0..9e5648523 100644 --- a/projects/mtg/bin/Res/sets/10E/_cards.dat +++ b/projects/mtg/bin/Res/sets/10E/_cards.dat @@ -1154,8 +1154,7 @@ toughness=1 [card] text=When Highway Robber comes into play, target opponent loses 2 life and you gain 2 life. id=129564 -target=player -auto=damage:2 +auto=life:-2 opponent auto=life:2 controller name=Highway Robber rarity=C diff --git a/projects/mtg/include/DeckDataWrapper.h b/projects/mtg/include/DeckDataWrapper.h index b469f2986..abd00c9c2 100644 --- a/projects/mtg/include/DeckDataWrapper.h +++ b/projects/mtg/include/DeckDataWrapper.h @@ -33,6 +33,7 @@ class DeckDataWrapper{ ~DeckDataWrapper(); int Add(MTGCard * card, int quantity = 1); + int Add(MTGDeck * deck); int Remove(MTGCard * card); MTGCard * getNext(MTGCard * previous = NULL, int color = -1); MTGCard * getPrevious(MTGCard * next = NULL, int color = -1); diff --git a/projects/mtg/include/GameStateDeckViewer.h b/projects/mtg/include/GameStateDeckViewer.h index 96eaab305..9377f111b 100644 --- a/projects/mtg/include/GameStateDeckViewer.h +++ b/projects/mtg/include/GameStateDeckViewer.h @@ -777,7 +777,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener { MTGCard * card = cardIndex[2]; if (card){ - int rnd = (rand() % 20); + int rnd = (rand() % 25); playerdata->credits += price; price = price - (rnd * price)/100; pricelist->setPrice(card->getMTGId(),price*2); diff --git a/projects/mtg/include/ShopItem.h b/projects/mtg/include/ShopItem.h index 52500e199..10e7b8b36 100644 --- a/projects/mtg/include/ShopItem.h +++ b/projects/mtg/include/ShopItem.h @@ -26,7 +26,6 @@ class ShopItem:public JGuiObject{ JQuad * thumb; float mScale; float mTargetScale; - DeckDataWrapper * mDDW; public: @@ -37,6 +36,7 @@ class ShopItem:public JGuiObject{ ShopItem(int id, JLBFont * font, int _cardid, int x, int y, bool hasFocus, MTGAllCards * collection, int _price, DeckDataWrapper * ddw); ShopItem(int id, JLBFont * font, char* text, JQuad * _quad, JQuad * _thumb,int x, int y, bool hasFocus, int _price); ~ShopItem(); + int updateCount(DeckDataWrapper * ddw); virtual void Render(); virtual void Update(float dt); diff --git a/projects/mtg/src/DeckDataWrapper.cpp b/projects/mtg/src/DeckDataWrapper.cpp index 9fd4e4fcb..aeba86f9f 100644 --- a/projects/mtg/src/DeckDataWrapper.cpp +++ b/projects/mtg/src/DeckDataWrapper.cpp @@ -8,12 +8,18 @@ DeckDataWrapper::DeckDataWrapper(MTGDeck * deck){ for (int i = 0; i <= Constants::MTG_NB_COLORS; i++){ colors[i] = 0; } + Add(deck); + + currentColor = -1; +} + +int DeckDataWrapper::Add(MTGDeck * deck){ map::iterator it; for (it = deck->cards.begin(); it!=deck->cards.end(); it++){ MTGCard * card = deck->getCardById(it->first); Add(card,it->second); } - currentColor = -1; + return 1; } void DeckDataWrapper::save(){ diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index 345e4ef0f..3ef6f6062 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -47,6 +47,7 @@ void GameStateShop::Start() void GameStateShop::load(){ + if (shop) shop->saveAll(); SAFE_DELETE(shop); int sets[500]; int boosterSets[500]; diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index f9ed81ba7..c4653965e 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -530,6 +530,7 @@ int MTGDeck::remove(int cardid){ return 1; } + int MTGDeck::remove(MTGCard * card){ if (!card) return 0; return (remove(card->getId())); diff --git a/projects/mtg/src/ShopItem.cpp b/projects/mtg/src/ShopItem.cpp index 3370b19af..33422a2de 100644 --- a/projects/mtg/src/ShopItem.cpp +++ b/projects/mtg/src/ShopItem.cpp @@ -20,7 +20,6 @@ ShopItem::ShopItem(int id, JLBFont *font, char* text, JQuad * _quad,JQuad * _thu ShopItem::ShopItem(int id, JLBFont *font, int _cardid, int x, int y, bool hasFocus, MTGAllCards * collection, int _price, DeckDataWrapper * ddw): JGuiObject(id), mFont(font), mX(x), mY(y), price(_price){ mHasFocus = hasFocus; - mDDW = ddw; mScale = 1.0f; mTargetScale = 1.0f; @@ -28,7 +27,7 @@ ShopItem::ShopItem(int id, JLBFont *font, int _cardid, int x, int y, bool hasFoc Entering(); card = collection->getCardById(_cardid); - nameCount = mDDW->countByName(card); + updateCount(ddw); quantity = 1 + (rand() % 4); if (card->getRarity() == Constants::RARITY_L) quantity = 50; @@ -37,6 +36,12 @@ ShopItem::ShopItem(int id, JLBFont *font, int _cardid, int x, int y, bool hasFoc } +int ShopItem::updateCount(DeckDataWrapper * ddw){ + if (!card) return 0; + nameCount = ddw->countByName(card); + return nameCount; +} + ShopItem::~ShopItem(){ } @@ -242,13 +247,15 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){ if (playerdata->credits >= price){ playerdata->credits -= price; if (item->card){ - int rnd = (rand() % 5); - price = price + (rnd * price)/100; - pricelist->setPrice(item->card->getMTGId(),price); - playerdata->collection->add(item->card); - item->quantity--; - item->nameCount++; - }else{ + int rnd = (rand() % 25); + price = price + (rnd * price)/100; + pricelist->setPrice(item->card->getMTGId(),price); + playerdata->collection->add(item->card); + item->quantity--; + myCollection->Add(item->card); + item->nameCount++; + item->price = price; + }else{ safeDeleteDisplay(); display = NEW CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5); @@ -257,10 +264,20 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){ int rnd = rand() % 8; if (rnd == 0) rare_or_mythic = Constants::RARITY_M; int sets[] = {setIds[showPriceDialog]}; + //for (int i= 0; i <15; i++){ + // tempDeck->add(136218); + //} tempDeck->addRandomCards(1, sets,1,rare_or_mythic); tempDeck->addRandomCards(3, sets,1,Constants::RARITY_U); tempDeck->addRandomCards(11, sets,1,Constants::RARITY_C); + playerdata->collection->add(tempDeck); + myCollection->Add(tempDeck); + + for (int j = 0; j < mCount; j++){ + ShopItem * si = ((ShopItem *)mObjects[j]); + si->updateCount(myCollection); + } int i = 0; @@ -272,12 +289,6 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){ display->AddCard(card); i++; } - for (int j = 0; j < mCount; j++){ - ShopItem * si = ((ShopItem *)mObjects[j]); - if (si->card && si->card->name.compare(c->name) == 0){ - si->nameCount+= it->second; - } - } } delete tempDeck; } @@ -289,9 +300,10 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){ break; case 2: if (item->card){ - int rnd = (rand() % 5); + int rnd = (rand() % 25); price = price - (rnd * price)/100; pricelist->setPrice(item->card->getMTGId(),price); + item->price = price; } showPriceDialog = -1; break; @@ -334,7 +346,6 @@ ostream& ShopItem::toString(ostream& out) const << " ; thumb : " << thumb << " ; mScale : " << mScale << " ; mTargetScale : " << mTargetScale - << " ; mDDW : " << mDDW << " ; nameCount : " << nameCount << " ; quantity : " << quantity << " ; card : " << card