Erwan
-fixed shop refresh method problem (would not save correctly)
This commit is contained in:
BIN
projects/mtg/bin/Res/graphics/smallface.dat
Normal file
BIN
projects/mtg/bin/Res/graphics/smallface.dat
Normal file
Binary file not shown.
BIN
projects/mtg/bin/Res/graphics/smallface.png
Normal file
BIN
projects/mtg/bin/Res/graphics/smallface.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 981 B |
@@ -1154,8 +1154,7 @@ toughness=1
|
|||||||
[card]
|
[card]
|
||||||
text=When Highway Robber comes into play, target opponent loses 2 life and you gain 2 life.
|
text=When Highway Robber comes into play, target opponent loses 2 life and you gain 2 life.
|
||||||
id=129564
|
id=129564
|
||||||
target=player
|
auto=life:-2 opponent
|
||||||
auto=damage:2
|
|
||||||
auto=life:2 controller
|
auto=life:2 controller
|
||||||
name=Highway Robber
|
name=Highway Robber
|
||||||
rarity=C
|
rarity=C
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class DeckDataWrapper{
|
|||||||
~DeckDataWrapper();
|
~DeckDataWrapper();
|
||||||
|
|
||||||
int Add(MTGCard * card, int quantity = 1);
|
int Add(MTGCard * card, int quantity = 1);
|
||||||
|
int Add(MTGDeck * deck);
|
||||||
int Remove(MTGCard * card);
|
int Remove(MTGCard * card);
|
||||||
MTGCard * getNext(MTGCard * previous = NULL, int color = -1);
|
MTGCard * getNext(MTGCard * previous = NULL, int color = -1);
|
||||||
MTGCard * getPrevious(MTGCard * next = NULL, int color = -1);
|
MTGCard * getPrevious(MTGCard * next = NULL, int color = -1);
|
||||||
|
|||||||
@@ -777,7 +777,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
|||||||
{
|
{
|
||||||
MTGCard * card = cardIndex[2];
|
MTGCard * card = cardIndex[2];
|
||||||
if (card){
|
if (card){
|
||||||
int rnd = (rand() % 20);
|
int rnd = (rand() % 25);
|
||||||
playerdata->credits += price;
|
playerdata->credits += price;
|
||||||
price = price - (rnd * price)/100;
|
price = price - (rnd * price)/100;
|
||||||
pricelist->setPrice(card->getMTGId(),price*2);
|
pricelist->setPrice(card->getMTGId(),price*2);
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class ShopItem:public JGuiObject{
|
|||||||
JQuad * thumb;
|
JQuad * thumb;
|
||||||
float mScale;
|
float mScale;
|
||||||
float mTargetScale;
|
float mTargetScale;
|
||||||
DeckDataWrapper * mDDW;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
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, 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 id, JLBFont * font, char* text, JQuad * _quad, JQuad * _thumb,int x, int y, bool hasFocus, int _price);
|
||||||
~ShopItem();
|
~ShopItem();
|
||||||
|
int updateCount(DeckDataWrapper * ddw);
|
||||||
|
|
||||||
virtual void Render();
|
virtual void Render();
|
||||||
virtual void Update(float dt);
|
virtual void Update(float dt);
|
||||||
|
|||||||
@@ -8,12 +8,18 @@ DeckDataWrapper::DeckDataWrapper(MTGDeck * deck){
|
|||||||
for (int i = 0; i <= Constants::MTG_NB_COLORS; i++){
|
for (int i = 0; i <= Constants::MTG_NB_COLORS; i++){
|
||||||
colors[i] = 0;
|
colors[i] = 0;
|
||||||
}
|
}
|
||||||
|
Add(deck);
|
||||||
|
|
||||||
|
currentColor = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DeckDataWrapper::Add(MTGDeck * deck){
|
||||||
map<int,int>::iterator it;
|
map<int,int>::iterator it;
|
||||||
for (it = deck->cards.begin(); it!=deck->cards.end(); it++){
|
for (it = deck->cards.begin(); it!=deck->cards.end(); it++){
|
||||||
MTGCard * card = deck->getCardById(it->first);
|
MTGCard * card = deck->getCardById(it->first);
|
||||||
Add(card,it->second);
|
Add(card,it->second);
|
||||||
}
|
}
|
||||||
currentColor = -1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckDataWrapper::save(){
|
void DeckDataWrapper::save(){
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ void GameStateShop::Start()
|
|||||||
|
|
||||||
|
|
||||||
void GameStateShop::load(){
|
void GameStateShop::load(){
|
||||||
|
if (shop) shop->saveAll();
|
||||||
SAFE_DELETE(shop);
|
SAFE_DELETE(shop);
|
||||||
int sets[500];
|
int sets[500];
|
||||||
int boosterSets[500];
|
int boosterSets[500];
|
||||||
|
|||||||
@@ -530,6 +530,7 @@ int MTGDeck::remove(int cardid){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int MTGDeck::remove(MTGCard * card){
|
int MTGDeck::remove(MTGCard * card){
|
||||||
if (!card) return 0;
|
if (!card) return 0;
|
||||||
return (remove(card->getId()));
|
return (remove(card->getId()));
|
||||||
|
|||||||
@@ -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){
|
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;
|
mHasFocus = hasFocus;
|
||||||
mDDW = ddw;
|
|
||||||
mScale = 1.0f;
|
mScale = 1.0f;
|
||||||
mTargetScale = 1.0f;
|
mTargetScale = 1.0f;
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ ShopItem::ShopItem(int id, JLBFont *font, int _cardid, int x, int y, bool hasFoc
|
|||||||
Entering();
|
Entering();
|
||||||
|
|
||||||
card = collection->getCardById(_cardid);
|
card = collection->getCardById(_cardid);
|
||||||
nameCount = mDDW->countByName(card);
|
updateCount(ddw);
|
||||||
|
|
||||||
quantity = 1 + (rand() % 4);
|
quantity = 1 + (rand() % 4);
|
||||||
if (card->getRarity() == Constants::RARITY_L) quantity = 50;
|
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(){
|
ShopItem::~ShopItem(){
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -242,13 +247,15 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
|
|||||||
if (playerdata->credits >= price){
|
if (playerdata->credits >= price){
|
||||||
playerdata->credits -= price;
|
playerdata->credits -= price;
|
||||||
if (item->card){
|
if (item->card){
|
||||||
int rnd = (rand() % 5);
|
int rnd = (rand() % 25);
|
||||||
price = price + (rnd * price)/100;
|
price = price + (rnd * price)/100;
|
||||||
pricelist->setPrice(item->card->getMTGId(),price);
|
pricelist->setPrice(item->card->getMTGId(),price);
|
||||||
playerdata->collection->add(item->card);
|
playerdata->collection->add(item->card);
|
||||||
item->quantity--;
|
item->quantity--;
|
||||||
item->nameCount++;
|
myCollection->Add(item->card);
|
||||||
}else{
|
item->nameCount++;
|
||||||
|
item->price = price;
|
||||||
|
}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);
|
||||||
|
|
||||||
@@ -257,10 +264,20 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
|
|||||||
int rnd = rand() % 8;
|
int rnd = rand() % 8;
|
||||||
if (rnd == 0) rare_or_mythic = Constants::RARITY_M;
|
if (rnd == 0) rare_or_mythic = Constants::RARITY_M;
|
||||||
int sets[] = {setIds[showPriceDialog]};
|
int sets[] = {setIds[showPriceDialog]};
|
||||||
|
//for (int i= 0; i <15; i++){
|
||||||
|
// tempDeck->add(136218);
|
||||||
|
//}
|
||||||
tempDeck->addRandomCards(1, sets,1,rare_or_mythic);
|
tempDeck->addRandomCards(1, sets,1,rare_or_mythic);
|
||||||
tempDeck->addRandomCards(3, sets,1,Constants::RARITY_U);
|
tempDeck->addRandomCards(3, sets,1,Constants::RARITY_U);
|
||||||
tempDeck->addRandomCards(11, sets,1,Constants::RARITY_C);
|
tempDeck->addRandomCards(11, sets,1,Constants::RARITY_C);
|
||||||
|
|
||||||
playerdata->collection->add(tempDeck);
|
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;
|
int i = 0;
|
||||||
@@ -272,12 +289,6 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
|
|||||||
display->AddCard(card);
|
display->AddCard(card);
|
||||||
i++;
|
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;
|
delete tempDeck;
|
||||||
}
|
}
|
||||||
@@ -289,9 +300,10 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (item->card){
|
if (item->card){
|
||||||
int rnd = (rand() % 5);
|
int rnd = (rand() % 25);
|
||||||
price = price - (rnd * price)/100;
|
price = price - (rnd * price)/100;
|
||||||
pricelist->setPrice(item->card->getMTGId(),price);
|
pricelist->setPrice(item->card->getMTGId(),price);
|
||||||
|
item->price = price;
|
||||||
}
|
}
|
||||||
showPriceDialog = -1;
|
showPriceDialog = -1;
|
||||||
break;
|
break;
|
||||||
@@ -334,7 +346,6 @@ ostream& ShopItem::toString(ostream& out) const
|
|||||||
<< " ; thumb : " << thumb
|
<< " ; thumb : " << thumb
|
||||||
<< " ; mScale : " << mScale
|
<< " ; mScale : " << mScale
|
||||||
<< " ; mTargetScale : " << mTargetScale
|
<< " ; mTargetScale : " << mTargetScale
|
||||||
<< " ; mDDW : " << mDDW
|
|
||||||
<< " ; nameCount : " << nameCount
|
<< " ; nameCount : " << nameCount
|
||||||
<< " ; quantity : " << quantity
|
<< " ; quantity : " << quantity
|
||||||
<< " ; card : " << card
|
<< " ; card : " << card
|
||||||
|
|||||||
Reference in New Issue
Block a user