Erwan
- reduced price of boosters - Sets need to be unlocked in order to be accessed from the shop - Added a "refresh" option in the shop
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -26,6 +26,7 @@ private:
|
|||||||
int isMomirUnlocked();
|
int isMomirUnlocked();
|
||||||
int isEvilTwinUnlocked();
|
int isEvilTwinUnlocked();
|
||||||
int isRandomDeckUnlocked();
|
int isRandomDeckUnlocked();
|
||||||
|
int unlockRandomSet();
|
||||||
public:
|
public:
|
||||||
int value;
|
int value;
|
||||||
Player * p1, *p2;
|
Player * p1, *p2;
|
||||||
@@ -34,6 +35,7 @@ public:
|
|||||||
int unlocked;
|
int unlocked;
|
||||||
JQuad * unlockedQuad;
|
JQuad * unlockedQuad;
|
||||||
JTexture * unlockedTex;
|
JTexture * unlockedTex;
|
||||||
|
string unlockedString;
|
||||||
vector<CreditBonus *> bonus;
|
vector<CreditBonus *> bonus;
|
||||||
Credits();
|
Credits();
|
||||||
~Credits();
|
~Credits();
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class GameStateShop: public GameState, public JGuiListener
|
|||||||
char starterBuffer[128], boosterBuffer[128];
|
char starterBuffer[128], boosterBuffer[128];
|
||||||
char setNames[SHOP_BOOSTERS][128];
|
char setNames[SHOP_BOOSTERS][128];
|
||||||
int setIds[SHOP_BOOSTERS];
|
int setIds[SHOP_BOOSTERS];
|
||||||
|
void load();
|
||||||
public:
|
public:
|
||||||
GameStateShop(GameApp* parent);
|
GameStateShop(GameApp* parent);
|
||||||
virtual ~GameStateShop();
|
virtual ~GameStateShop();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class GameApp;
|
|||||||
class MTGCard;
|
class MTGCard;
|
||||||
|
|
||||||
|
|
||||||
#define MAX_SETS 50
|
#define MAX_SETS 100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ class MTGDeck{
|
|||||||
int totalCards();
|
int totalCards();
|
||||||
MTGDeck(TexturesCache * cache, MTGAllCards * _allcards);
|
MTGDeck(TexturesCache * cache, MTGAllCards * _allcards);
|
||||||
MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only = 0);
|
MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only = 0);
|
||||||
int addRandomCards(int howmany, int setId = -1, int rarity = -1, const char * subtype = NULL, int * colors = NULL, int nbcolors = 0);
|
int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL, int * colors = NULL, int nbcolors = 0);
|
||||||
int add(int cardid);
|
int add(int cardid);
|
||||||
int add(MTGDeck * deck); // adds the contents of "deck" into myself
|
int add(MTGDeck * deck); // adds the contents of "deck" into myself
|
||||||
int remove(int cardid);
|
int remove(int cardid);
|
||||||
|
|||||||
@@ -744,6 +744,10 @@ while( iter != mObjects.end() ){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ActionStack::Fizzle(Interruptible * action){
|
void ActionStack::Fizzle(Interruptible * action){
|
||||||
|
if (!action){
|
||||||
|
OutputDebugString("==ERROR==: action is NULL in ActionStack::Fizzle\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (action->type == ACTION_SPELL){
|
if (action->type == ACTION_SPELL){
|
||||||
Spell * spell = (Spell *) action;
|
Spell * spell = (Spell *) action;
|
||||||
spell->source->controller()->game->putInGraveyard(spell->source);
|
spell->source->controller()->game->putInGraveyard(spell->source);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "../include/PlayerData.h"
|
#include "../include/PlayerData.h"
|
||||||
#include "../include/DeckStats.h"
|
#include "../include/DeckStats.h"
|
||||||
#include "../include/Translate.h"
|
#include "../include/Translate.h"
|
||||||
|
#include "../include/MTGDeck.h"
|
||||||
|
|
||||||
CreditBonus::CreditBonus(int _value, string _text){
|
CreditBonus::CreditBonus(int _value, string _text){
|
||||||
value = _value;
|
value = _value;
|
||||||
@@ -93,6 +94,14 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
|
|||||||
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
|
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
|
||||||
GameOptions::GetInstance()->values[OPTIONS_RANDOMDECK_MODE_UNLOCKED] = GameOption(1);
|
GameOptions::GetInstance()->values[OPTIONS_RANDOMDECK_MODE_UNLOCKED] = GameOption(1);
|
||||||
GameOptions::GetInstance()->save();
|
GameOptions::GetInstance()->save();
|
||||||
|
}else if(unlocked = unlockRandomSet()) {
|
||||||
|
unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/set_unlocked.png", TEX_TYPE_USE_VRAM);
|
||||||
|
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
|
||||||
|
char buffer[4096];
|
||||||
|
unlockedString = MtgSets::SetsList->values[unlocked -1];
|
||||||
|
sprintf(buffer,"unlocked_%s", unlockedString.c_str());
|
||||||
|
GameOptions::GetInstance()->values[buffer] = GameOption(1);
|
||||||
|
GameOptions::GetInstance()->save();
|
||||||
}
|
}
|
||||||
if (unlocked){
|
if (unlocked){
|
||||||
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/bonus.wav");
|
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/bonus.wav");
|
||||||
@@ -138,6 +147,9 @@ void Credits::Render(){
|
|||||||
showMsg = 0;
|
showMsg = 0;
|
||||||
r->RenderQuad(unlockedQuad, 20, 20);
|
r->RenderQuad(unlockedQuad, 20, 20);
|
||||||
}
|
}
|
||||||
|
if(unlockedString.size()){
|
||||||
|
f2->DrawString(unlockedString.c_str(),SCREEN_WIDTH/2, 80,JGETEXT_CENTER);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
sprintf (buffer, _("You have been defeated").c_str());
|
sprintf (buffer, _("You have been defeated").c_str());
|
||||||
}
|
}
|
||||||
@@ -215,3 +227,13 @@ int Credits::isRandomDeckUnlocked(){
|
|||||||
if (p1->life >= 20 ) return 1;
|
if (p1->life >= 20 ) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Credits::unlockRandomSet(){
|
||||||
|
if (rand() % 2) return 0;
|
||||||
|
int setId = rand() % MtgSets::SetsList->nb_items;
|
||||||
|
char buffer[4096];
|
||||||
|
string s = MtgSets::SetsList->values[setId];
|
||||||
|
sprintf(buffer,"unlocked_%s", s.c_str());
|
||||||
|
if (GameOptions::GetInstance()->values[buffer].getIntValue() == 1 ) return 0;
|
||||||
|
return setId+1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -119,15 +119,15 @@ void GameStateDuel::loadPlayerRandom(int playerId, int isAI, int mode){
|
|||||||
|
|
||||||
|
|
||||||
MTGDeck * tempDeck = NEW MTGDeck(NULL, mParent->collection);
|
MTGDeck * tempDeck = NEW MTGDeck(NULL, mParent->collection);
|
||||||
tempDeck->addRandomCards(9,-1,-1,lands[color1].c_str());
|
tempDeck->addRandomCards(9,0,0,-1,lands[color1].c_str());
|
||||||
tempDeck->addRandomCards(9,-1,-1,lands[color2].c_str());
|
tempDeck->addRandomCards(9,0,0,-1,lands[color2].c_str());
|
||||||
tempDeck->addRandomCards(1,-1,'U',"land",colors,nbcolors);
|
tempDeck->addRandomCards(1,0,0,'U',"land",colors,nbcolors);
|
||||||
tempDeck->addRandomCards(1,-1,'R',"land",colors,nbcolors);
|
tempDeck->addRandomCards(1,0,0,'R',"land",colors,nbcolors);
|
||||||
tempDeck->addRandomCards(12,-1,-1,"creature",colors,nbcolors);
|
tempDeck->addRandomCards(12,0,0,-1,"creature",colors,nbcolors);
|
||||||
tempDeck->addRandomCards(2,-1,-1,"sorcery",colors,nbcolors);
|
tempDeck->addRandomCards(2,0,0,-1,"sorcery",colors,nbcolors);
|
||||||
tempDeck->addRandomCards(2,-1,-1,"enchantment",colors,nbcolors);
|
tempDeck->addRandomCards(2,0,0,-1,"enchantment",colors,nbcolors);
|
||||||
tempDeck->addRandomCards(2,-1,-1,"instant",colors,nbcolors);
|
tempDeck->addRandomCards(2,0,0,-1,"instant",colors,nbcolors);
|
||||||
tempDeck->addRandomCards(2,-1,-1,"artifact",colors,nbcolors);
|
tempDeck->addRandomCards(2,0,0,-1,"artifact",colors,nbcolors);
|
||||||
|
|
||||||
char * deckFile = "random";
|
char * deckFile = "random";
|
||||||
string deckFileSmall = "random";
|
string deckFileSmall = "random";
|
||||||
|
|||||||
@@ -290,17 +290,24 @@ void GameStateMenu::Update(float dt)
|
|||||||
break;
|
break;
|
||||||
case MENU_STATE_MAJOR_FIRST_TIME :
|
case MENU_STATE_MAJOR_FIRST_TIME :
|
||||||
{
|
{
|
||||||
//Give the player cards from the set for which we have the most variety
|
//Give the player cards from the set for which we have the most variety
|
||||||
int setId = 0;
|
int setId = 0;
|
||||||
int maxcards = 0;
|
int maxcards = 0;
|
||||||
for (int i=0; i< MtgSets::SetsList->nb_items; i++){
|
for (int i=0; i< MtgSets::SetsList->nb_items; i++){
|
||||||
int value = mParent->collection->countBySet(i);
|
int value = mParent->collection->countBySet(i);
|
||||||
if (value > maxcards){
|
if (value > maxcards){
|
||||||
maxcards = value;
|
maxcards = value;
|
||||||
setId = i;
|
setId = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
createUsersFirstDeck(setId);
|
//Save this set as "unlocked"
|
||||||
|
string s = MtgSets::SetsList->values[setId];
|
||||||
|
char buffer[4096];
|
||||||
|
sprintf(buffer,"unlocked_%s", s.c_str());
|
||||||
|
GameOptions::GetInstance()->values[buffer] = GameOption(1);
|
||||||
|
GameOptions::GetInstance()->save();
|
||||||
|
|
||||||
|
createUsersFirstDeck(setId);
|
||||||
}
|
}
|
||||||
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
||||||
break;
|
break;
|
||||||
@@ -388,20 +395,21 @@ void GameStateMenu::createUsersFirstDeck(int setId){
|
|||||||
#endif
|
#endif
|
||||||
MTGDeck *mCollection = NEW MTGDeck(RESPATH"/player/collection.dat", mParent->cache, mParent->collection);
|
MTGDeck *mCollection = NEW MTGDeck(RESPATH"/player/collection.dat", mParent->cache, mParent->collection);
|
||||||
//10 lands of each
|
//10 lands of each
|
||||||
if (!mCollection->addRandomCards(10, setId,Constants::RARITY_L,"Forest")){
|
int sets[] = {setId};
|
||||||
mCollection->addRandomCards(10, -1,Constants::RARITY_L,"Forest");
|
if (!mCollection->addRandomCards(10, sets,1, Constants::RARITY_L,"Forest")){
|
||||||
|
mCollection->addRandomCards(10, 0,0,Constants::RARITY_L,"Forest");
|
||||||
}
|
}
|
||||||
if (!mCollection->addRandomCards(10, setId,Constants::RARITY_L,"Plains")){
|
if (!mCollection->addRandomCards(10, sets,1,Constants::RARITY_L,"Plains")){
|
||||||
mCollection->addRandomCards(10, -1,Constants::RARITY_L,"Plains");
|
mCollection->addRandomCards(10, 0,0,Constants::RARITY_L,"Plains");
|
||||||
}
|
}
|
||||||
if (!mCollection->addRandomCards(10, setId,Constants::RARITY_L,"Swamp")){
|
if (!mCollection->addRandomCards(10, sets,1,Constants::RARITY_L,"Swamp")){
|
||||||
mCollection->addRandomCards(10, -1,Constants::RARITY_L,"Swamp");
|
mCollection->addRandomCards(10, 0,0,Constants::RARITY_L,"Swamp");
|
||||||
}
|
}
|
||||||
if (!mCollection->addRandomCards(10, setId,Constants::RARITY_L,"Mountain")){
|
if (!mCollection->addRandomCards(10, sets,1,Constants::RARITY_L,"Mountain")){
|
||||||
mCollection->addRandomCards(10, -1,Constants::RARITY_L,"Mountain");
|
mCollection->addRandomCards(10, 0,0,Constants::RARITY_L,"Mountain");
|
||||||
}
|
}
|
||||||
if (!mCollection->addRandomCards(10, setId,Constants::RARITY_L,"Island")){
|
if (!mCollection->addRandomCards(10, sets,1,Constants::RARITY_L,"Island")){
|
||||||
mCollection->addRandomCards(10, -1,Constants::RARITY_L,"Island");
|
mCollection->addRandomCards(10, 0,0,Constants::RARITY_L,"Island");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -410,18 +418,18 @@ void GameStateMenu::createUsersFirstDeck(int setId){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Starter Deck
|
//Starter Deck
|
||||||
mCollection->addRandomCards(3, setId,Constants::RARITY_R,NULL);
|
mCollection->addRandomCards(3, sets,1,Constants::RARITY_R,NULL);
|
||||||
mCollection->addRandomCards(9, setId,Constants::RARITY_U,NULL);
|
mCollection->addRandomCards(9, sets,1,Constants::RARITY_U,NULL);
|
||||||
mCollection->addRandomCards(48, setId,Constants::RARITY_C,NULL);
|
mCollection->addRandomCards(48, sets,1,Constants::RARITY_C,NULL);
|
||||||
|
|
||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32) || defined (LINUX)
|
||||||
OutputDebugString("2\n");
|
OutputDebugString("2\n");
|
||||||
#endif
|
#endif
|
||||||
//Boosters
|
//Boosters
|
||||||
for (int i = 0; i< 2; i++){
|
for (int i = 0; i< 2; i++){
|
||||||
mCollection->addRandomCards(1, setId,Constants::RARITY_R);
|
mCollection->addRandomCards(1, sets,1,Constants::RARITY_R);
|
||||||
mCollection->addRandomCards(3, setId,Constants::RARITY_U);
|
mCollection->addRandomCards(3, sets,1,Constants::RARITY_U);
|
||||||
mCollection->addRandomCards(11, setId,Constants::RARITY_C);
|
mCollection->addRandomCards(11, sets,1,Constants::RARITY_C);
|
||||||
}
|
}
|
||||||
mCollection->save();
|
mCollection->save();
|
||||||
SAFE_DELETE(mCollection);
|
SAFE_DELETE(mCollection);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "../include/GameApp.h"
|
#include "../include/GameApp.h"
|
||||||
#include "../include/MTGDeck.h"
|
#include "../include/MTGDeck.h"
|
||||||
#include "../include/Translate.h"
|
#include "../include/Translate.h"
|
||||||
|
#include "../include/GameOptions.h"
|
||||||
|
|
||||||
GameStateShop::GameStateShop(GameApp* parent): GameState(parent) {}
|
GameStateShop::GameStateShop(GameApp* parent): GameState(parent) {}
|
||||||
|
|
||||||
@@ -40,17 +40,55 @@ void GameStateShop::Start()
|
|||||||
JRenderer::GetInstance()->EnableVSync(true);
|
JRenderer::GetInstance()->EnableVSync(true);
|
||||||
|
|
||||||
|
|
||||||
|
shop = NULL;
|
||||||
|
load();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GameStateShop::load(){
|
||||||
|
SAFE_DELETE(shop);
|
||||||
int sets[500];
|
int sets[500];
|
||||||
|
int boosterSets[500];
|
||||||
|
int unlocked[500];
|
||||||
int nbsets = 0;
|
int nbsets = 0;
|
||||||
|
int nbboostersets = 0;
|
||||||
|
|
||||||
|
//Unlock a default set if no set is unlocked
|
||||||
|
int ok = 0;
|
||||||
|
int defaultSet = 0;
|
||||||
for (int i = 0; i < MtgSets::SetsList->nb_items; i++){
|
for (int i = 0; i < MtgSets::SetsList->nb_items; i++){
|
||||||
if (mParent->collection->countBySet(i) > 80){ //Only sets with more than 80 cards can get boosters and starters
|
string s = MtgSets::SetsList->values[i];
|
||||||
sets[nbsets] = i;
|
if (s.compare("10E") == 0) defaultSet = i;
|
||||||
nbsets++;
|
char buffer[4096];
|
||||||
|
sprintf(buffer,"unlocked_%s", s.c_str());
|
||||||
|
unlocked[i] = GameOptions::GetInstance()->values[buffer].getIntValue();
|
||||||
|
if ( unlocked[i] ){
|
||||||
|
ok = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nbsets){
|
if (!ok){
|
||||||
|
unlocked[defaultSet] = 1;
|
||||||
|
string s = MtgSets::SetsList->values[defaultSet];
|
||||||
|
char buffer[4096];
|
||||||
|
sprintf(buffer,"unlocked_%s", s.c_str());
|
||||||
|
GameOptions::GetInstance()->values[buffer] = GameOption(1);
|
||||||
|
GameOptions::GetInstance()->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < MtgSets::SetsList->nb_items; i++){
|
||||||
|
if (unlocked[i] ){
|
||||||
|
sets[nbsets] = i;
|
||||||
|
nbsets++;
|
||||||
|
if (mParent->collection->countBySet(i) > 80){ //Only sets with more than 80 cards can get boosters and starters
|
||||||
|
boosterSets[nbboostersets] = i;
|
||||||
|
nbboostersets++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nbboostersets){
|
||||||
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
||||||
setIds[i] = sets[(rand() % nbsets)];
|
setIds[i] = boosterSets[(rand() % nbboostersets)];
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
||||||
@@ -59,21 +97,24 @@ void GameStateShop::Start()
|
|||||||
}
|
}
|
||||||
JQuad * mBackThumb = GameApp::CommonRes->GetQuad("back_thumb");
|
JQuad * mBackThumb = GameApp::CommonRes->GetQuad("back_thumb");
|
||||||
|
|
||||||
shop = NULL;
|
|
||||||
|
|
||||||
shop = NEW ShopItems(10, this, itemFont, 10, 0, mParent->collection, setIds);
|
shop = NEW ShopItems(10, this, itemFont, 10, 0, mParent->collection, setIds);
|
||||||
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
||||||
sprintf(setNames[i], "%s Booster (15 %s)",MtgSets::SetsList->values[setIds[i]].c_str(), _("cards").c_str());
|
sprintf(setNames[i], "%s Booster (15 %s)",MtgSets::SetsList->values[setIds[i]].c_str(), _("cards").c_str());
|
||||||
shop->Add(setNames[i],mBack,mBackThumb, 1200);
|
shop->Add(setNames[i],mBack,mBackThumb, 700);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++){
|
MTGDeck * tempDeck = NEW MTGDeck(NULL,mParent->collection);
|
||||||
shop->Add(mParent->collection->randomCardId());
|
tempDeck->addRandomCards(8,sets,nbsets);
|
||||||
|
for (map<int,int>::iterator it = tempDeck->cards.begin(); it!=tempDeck->cards.end(); it++){
|
||||||
|
for (int j = 0; j < it->second; j++){
|
||||||
|
shop->Add(it->first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
delete tempDeck;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameStateShop::End()
|
void GameStateShop::End()
|
||||||
{
|
{
|
||||||
JRenderer::GetInstance()->EnableVSync(false);
|
JRenderer::GetInstance()->EnableVSync(false);
|
||||||
@@ -103,6 +144,9 @@ void GameStateShop::Update(float dt)
|
|||||||
if (mEngine->GetButtonClick(PSP_CTRL_START)){
|
if (mEngine->GetButtonClick(PSP_CTRL_START)){
|
||||||
mStage = STAGE_SHOP_MENU;
|
mStage = STAGE_SHOP_MENU;
|
||||||
}
|
}
|
||||||
|
if (mEngine->GetButtonClick(PSP_CTRL_SQUARE)){
|
||||||
|
load();
|
||||||
|
}
|
||||||
if (shop)
|
if (shop)
|
||||||
shop->Update(dt);
|
shop->Update(dt);
|
||||||
}
|
}
|
||||||
@@ -112,10 +156,14 @@ void GameStateShop::Update(float dt)
|
|||||||
void GameStateShop::Render()
|
void GameStateShop::Render()
|
||||||
{
|
{
|
||||||
//Erase
|
//Erase
|
||||||
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
|
JRenderer * r = JRenderer::GetInstance();
|
||||||
|
r->ClearScreen(ARGB(0,0,0,0));
|
||||||
if (mBg)JRenderer::GetInstance()->RenderQuad(mBg,0,0);
|
if (mBg)JRenderer::GetInstance()->RenderQuad(mBg,0,0);
|
||||||
if (shop)
|
if (shop)
|
||||||
shop->Render();
|
shop->Render();
|
||||||
|
|
||||||
|
r->FillRect(5,SCREEN_HEIGHT-15,110,15,ARGB(200,0,0,0));
|
||||||
|
itemFont->DrawString(_("press [] to refresh").c_str(),10,SCREEN_HEIGHT-12);
|
||||||
if (mStage == STAGE_SHOP_MENU && menu){
|
if (mStage == STAGE_SHOP_MENU && menu){
|
||||||
menu->Render();
|
menu->Render();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ int MTGCardInstance::reset(){
|
|||||||
Player * MTGCardInstance::controller(){
|
Player * MTGCardInstance::controller(){
|
||||||
GameObserver * game = GameObserver::GetInstance();
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
if (!game) return NULL;
|
if (!game) return NULL;
|
||||||
for (int i = 0; i < 2; i++){
|
for (int i = 0; i < 2; ++i){
|
||||||
if (game->players[i]->game->inPlay->hasCard(this)) return game->players[i];
|
if (game->players[i]->game->inPlay->hasCard(this)) return game->players[i];
|
||||||
if (game->players[i]->game->stack->hasCard(this)) return game->players[i];
|
if (game->players[i]->game->stack->hasCard(this)) return game->players[i];
|
||||||
if (game->players[i]->game->graveyard->hasCard(this)) return game->players[i];
|
if (game->players[i]->game->graveyard->hasCard(this)) return game->players[i];
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ MTGCard * MTGDeck::getCardById(int mtgId){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int MTGDeck::addRandomCards(int howmany, int setId, int rarity, const char * _subtype, int * colors, int nbcolors){
|
int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, const char * _subtype, int * colors, int nbcolors){
|
||||||
int unallowedColors[Constants::MTG_NB_COLORS+1];
|
int unallowedColors[Constants::MTG_NB_COLORS+1];
|
||||||
for (int i=0; i < Constants::MTG_NB_COLORS; ++i){
|
for (int i=0; i < Constants::MTG_NB_COLORS; ++i){
|
||||||
if (nbcolors) unallowedColors[i] = 1;
|
if (nbcolors) unallowedColors[i] = 1;
|
||||||
@@ -433,7 +433,7 @@ int MTGDeck::addRandomCards(int howmany, int setId, int rarity, const char * _su
|
|||||||
|
|
||||||
int collectionTotal = database->totalCards();
|
int collectionTotal = database->totalCards();
|
||||||
if (!collectionTotal) return 0;
|
if (!collectionTotal) return 0;
|
||||||
if (setId == -1 && rarity == -1 && !_subtype && !nbcolors){
|
if (nbSets == 0 && rarity == -1 && !_subtype && !nbcolors){
|
||||||
for (int i = 0; i < howmany; i++){
|
for (int i = 0; i < howmany; i++){
|
||||||
add(database->randomCardId());
|
add(database->randomCardId());
|
||||||
}
|
}
|
||||||
@@ -448,17 +448,28 @@ int MTGDeck::addRandomCards(int howmany, int setId, int rarity, const char * _su
|
|||||||
int subtotal = 0;
|
int subtotal = 0;
|
||||||
for (int i = 0; i < collectionTotal; i++){
|
for (int i = 0; i < collectionTotal; i++){
|
||||||
MTGCard * card = database->_(i);
|
MTGCard * card = database->_(i);
|
||||||
if ((setId == -1 || card->setId == setId) &&
|
if ((rarity == -1 || card->getRarity()==rarity) &&
|
||||||
(rarity == -1 || card->getRarity()==rarity) &&
|
|
||||||
(!_subtype || card->hasSubtype(subtype))
|
(!_subtype || card->hasSubtype(subtype))
|
||||||
){
|
){
|
||||||
int ok = 1;
|
int ok = 0;
|
||||||
for (int j=0; j < Constants::MTG_NB_COLORS; ++j){
|
|
||||||
if (unallowedColors[j] && card->hasColor(j)){
|
if (!nbSets) ok = 1;
|
||||||
ok = 0;
|
for (int j=0; j < nbSets; ++j){
|
||||||
|
if (card->setId == setIds[j]){
|
||||||
|
ok = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ok){
|
||||||
|
for (int j=0; j < Constants::MTG_NB_COLORS; ++j){
|
||||||
|
if (unallowedColors[j] && card->hasColor(j)){
|
||||||
|
ok = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ok){
|
if (ok){
|
||||||
subcollection.push_back(card->getId());
|
subcollection.push_back(card->getId());
|
||||||
subtotal++;
|
subtotal++;
|
||||||
@@ -466,7 +477,7 @@ int MTGDeck::addRandomCards(int howmany, int setId, int rarity, const char * _su
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (subtotal == 0){
|
if (subtotal == 0){
|
||||||
if (rarity == Constants::RARITY_M) return addRandomCards(howmany, setId, Constants::RARITY_R, _subtype, colors, nbcolors);
|
if (rarity == Constants::RARITY_M) return addRandomCards(howmany, setIds, nbSets, Constants::RARITY_R, _subtype, colors, nbcolors);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < howmany; i++){
|
for (int i = 0; i < howmany; i++){
|
||||||
|
|||||||
@@ -256,9 +256,10 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
|
|||||||
int rare_or_mythic = Constants::RARITY_R;
|
int rare_or_mythic = Constants::RARITY_R;
|
||||||
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;
|
||||||
tempDeck->addRandomCards(1, setIds[showPriceDialog],rare_or_mythic);
|
int sets[] = {setIds[showPriceDialog]};
|
||||||
tempDeck->addRandomCards(3, setIds[showPriceDialog],Constants::RARITY_U);
|
tempDeck->addRandomCards(1, sets,1,rare_or_mythic);
|
||||||
tempDeck->addRandomCards(11, setIds[showPriceDialog],Constants::RARITY_C);
|
tempDeck->addRandomCards(3, sets,1,Constants::RARITY_U);
|
||||||
|
tempDeck->addRandomCards(11, sets,1,Constants::RARITY_C);
|
||||||
playerdata->collection->add(tempDeck);
|
playerdata->collection->add(tempDeck);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user