support for wish cards and deck sideboard

This commit is contained in:
Anthony Calosa
2017-03-07 23:42:34 +08:00
parent 24e3fd3267
commit 030dca051a
16 changed files with 431 additions and 99 deletions

View File

@@ -293,17 +293,18 @@ static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[]
{ SDLK_DOWN, JGE_BTN_DOWN }, { SDLK_DOWN, JGE_BTN_DOWN },
{ SDLK_LEFT, JGE_BTN_LEFT }, { SDLK_LEFT, JGE_BTN_LEFT },
{ SDLK_RIGHT, JGE_BTN_RIGHT }, { SDLK_RIGHT, JGE_BTN_RIGHT },
{ SDLK_z, JGE_BTN_UP }, { SDLK_w, JGE_BTN_UP },
{ SDLK_d, JGE_BTN_RIGHT },
{ SDLK_s, JGE_BTN_DOWN }, { SDLK_s, JGE_BTN_DOWN },
{ SDLK_q, JGE_BTN_LEFT }, { SDLK_a, JGE_BTN_LEFT },
{ SDLK_a, JGE_BTN_PREV }, { SDLK_d, JGE_BTN_RIGHT },
{ SDLK_q, JGE_BTN_PREV },
{ SDLK_e, JGE_BTN_NEXT }, { SDLK_e, JGE_BTN_NEXT },
{ SDLK_i, JGE_BTN_CANCEL }, { SDLK_i, JGE_BTN_CANCEL },
{ SDLK_l, JGE_BTN_OK }, { SDLK_l, JGE_BTN_OK },
{ SDLK_SPACE, JGE_BTN_OK }, { SDLK_SPACE, JGE_BTN_OK },
{ SDLK_k, JGE_BTN_SEC }, { SDLK_k, JGE_BTN_SEC },
{ SDLK_j, JGE_BTN_PRI }, { SDLK_j, JGE_BTN_PRI },
{ SDLK_b, JGE_BTN_SOUND },
{ SDLK_f, JGE_BTN_FULLSCREEN }, { SDLK_f, JGE_BTN_FULLSCREEN },
/* old Qt ones, basically modified to comply with the N900 keyboard /* old Qt ones, basically modified to comply with the N900 keyboard

View File

@@ -15844,6 +15844,15 @@ mana={2}{R}
type=Enchantment type=Enchantment
[/card] [/card]
[card] [card]
name=Burning Wish
auto=moveTo(exile)
aicode=activate target(sorcery|mysideboard) moveto(myhand)
auto=name(search card) reveal:type:*:mysideboard revealzone(mysideboard) optionone name(choose card) target(<1>sorcery|reveal) moveto(myhand) and!(all(other *|reveal) moveto(ownersideboard))! optiononeend optiontwo name(put back) target(<1>*|reveal) moveto(ownersideboard) and!(all(other *|reveal) moveto(ownersideboard))! optiontwoend revealend
text=You may choose a sorcery card you own from outside the game, reveal that card, and put it into your hand. Exile Burning Wish.
mana={1}{R}
type=Sorcery
[/card]
[card]
name=Burning-Tree Emissary name=Burning-Tree Emissary
auto=Add{R}{G} auto=Add{R}{G}
text=When Burning-Tree Emissary enters the battlefield, add {R}{G} to your mana pool. text=When Burning-Tree Emissary enters the battlefield, add {R}{G} to your mana pool.
@@ -24844,6 +24853,15 @@ mana={3}{U}{R}
type=Instant type=Instant
[/card] [/card]
[card] [card]
name=Cunning Wish
auto=moveTo(exile)
aicode=activate target(instant|mysideboard) moveto(myhand)
auto=name(search card) reveal:type:*:mysideboard revealzone(mysideboard) optionone name(choose card) target(<1>instant|reveal) moveto(myhand) and!(all(other *|reveal) moveto(ownersideboard))! optiononeend optiontwo name(put back) target(<1>*|reveal) moveto(ownersideboard) and!(all(other *|reveal) moveto(ownersideboard))! optiontwoend revealend
text=You may choose an instant card you own from outside the game, reveal that card, and put it into your hand. Exile Cunning Wish.
mana={2}{U}
type=Instant
[/card]
[card]
name=Cunning name=Cunning
target=creature target=creature
auto=3/3 auto=3/3
@@ -27072,6 +27090,16 @@ mana={X}{B}
type=Instant type=Instant
[/card] [/card]
[card] [card]
name=Death Wish
auto=moveTo(exile)
auto=life:-halfdownlifetotal
aicode=activate target(*|mysideboard) moveto(myhand)
auto=name(search card) reveal:type:*:mysideboard revealzone(mysideboard) optionone name(choose card) target(<1>*|reveal) moveto(myhand) and!(all(other *|reveal) moveto(ownersideboard))! optiononeend optiontwo name(put back) target(<1>*|reveal) moveto(ownersideboard) and!(all(other *|reveal) moveto(ownersideboard))! optiontwoend revealend
text=You may choose a card you own from outside the game and put it into your hand. You lose half your life, rounded up. Exile Death Wish.
mana={1}{B}{B}
type=Sorcery
[/card]
[card]
name=Deathbellow Raider name=Deathbellow Raider
abilities=mustattack abilities=mustattack
auto={2}{B}:regenerate auto={2}{B}:regenerate
@@ -47043,6 +47071,15 @@ power=1
toughness=1 toughness=1
[/card] [/card]
[card] [card]
name=Glittering Wish
auto=moveTo(exile)
aicode=activate target(*[multicolor]|mysideboard) moveto(myhand)
auto=name(search card) reveal:type:*:mysideboard revealzone(mysideboard) optionone name(choose card) target(<1>*[multicolor]|reveal) moveto(myhand) and!(all(other *|reveal) moveto(ownersideboard))! optiononeend optiontwo name(put back) target(<1>*|reveal) moveto(ownersideboard) and!(all(other *|reveal) moveto(ownersideboard))! optiontwoend revealend
text=You may choose a multicolored card you own from outside the game, reveal that card, and put it into your hand. Exile Glittering Wish.
mana={G}{W}
type=Sorcery
[/card]
[card]
name=Gloomdrifter name=Gloomdrifter
abilities=flying abilities=flying
auto=aslongas(*|mygraveyard) -2/-2 target(creature) ueot >6 oneshot auto=aslongas(*|mygraveyard) -2/-2 target(creature) ueot >6 oneshot
@@ -48636,6 +48673,15 @@ mana={1}
type=Artifact type=Artifact
[/card] [/card]
[card] [card]
name=Golden Wish
auto=moveTo(exile)
aicode=activate target(*[artifact;enchantment]|mysideboard) moveto(myhand)
auto=name(search card) reveal:type:*:mysideboard revealzone(mysideboard) optionone name(choose card) target(<1>*[artifact;enchantment]|reveal) moveto(myhand) and!(all(other *|reveal) moveto(ownersideboard))! optiononeend optiontwo name(put back) target(<1>*|reveal) moveto(ownersideboard) and!(all(other *|reveal) moveto(ownersideboard))! optiontwoend revealend
text=You may choose an artifact or enchantment card you own from outside the game, reveal that card, and put it into your hand. Exile Golden Wish.
mana={3}{W}{W}
type=Sorcery
[/card]
[card]
name=Goldenglow Moth name=Goldenglow Moth
abilities=flying abilities=flying
auto=@combat(blocking) source(this):life:4 auto=@combat(blocking) source(this):life:4
@@ -67626,6 +67672,15 @@ power=0
toughness=6 toughness=6
[/card] [/card]
[card] [card]
name=Living Wish
auto=moveTo(exile)
aicode=activate target(*[land;creature]|mysideboard) moveto(myhand)
auto=name(search card) reveal:type:*:mysideboard revealzone(mysideboard) optionone name(choose card) target(<1>*[land;creature]|reveal) moveto(myhand) and!(all(other *|reveal) moveto(ownersideboard))! optiononeend optiontwo name(put back) target(<1>*|reveal) moveto(ownersideboard) and!(all(other *|reveal) moveto(ownersideboard))! optiontwoend revealend
text=You may choose a creature or land card you own from outside the game, reveal that card, and put it into your hand. Exile Living Wish.
mana={1}{G}
type=Sorcery
[/card]
[card]
name=Livonya Silone name=Livonya Silone
abilities=first strike,legendarylandwalk abilities=first strike,legendarylandwalk
text=First strike, legendary landwalk text=First strike, legendary landwalk
@@ -110150,15 +110205,16 @@ type=Land
[/card] [/card]
[card] [card]
name=Spawnsire of Ulamog name=Spawnsire of Ulamog
mana={10}
auto=@combat(attacking) source(this):name(Annihilate) ability$!name(sacrifice a permanent) notatarget(<1>*|mybattlefield) sacrifice!$ opponent auto=@combat(attacking) source(this):name(Annihilate) ability$!name(sacrifice a permanent) notatarget(<1>*|mybattlefield) sacrifice!$ opponent
auto={4}:token(Eldrazi Spawn,Creature Eldrazi Spawn,0/1) and!( transforms((,newability[{S}:Add{1}])) forever )!*2 auto={4}:token(Eldrazi Spawn,Creature Eldrazi Spawn,0/1) and!( transforms((,newability[{S}:Add{1}])) forever )!*2
auto={20}:name(Cast Eldrazi's) ability$!castcard(named!:Emrakul, the Aeons Torn:!) _ castcard(named!:It That Betrays:!) _ castcard(named!:Ulamog, the Infinite Gyre:!) _ castcard(named!:Kozilek, Butcher of Truth:!) _ castcard(named!:Spawnsire of Ulamog:!) _ castcard(named!:Artisan of Kozilek:!) _ castcard(named!:Hand of Emrakul:!) _ castcard(named!:Ulamog's Crusher:!)!$ controller aicode=activate target(<anyamount>*[eldrazi]|mysideboard) castcard(normal)
auto={20}:name(Cast Eldrazi's) reveal:type:*:mysideboard revealzone(mysideboard) optionone name(choose card) target(<anyamount>*[eldrazi]|reveal) moveto(ownersideboard) and!( becomes(tobecast) ueot )! optiononeend optiontwo name(put back) target(<1>*|reveal) moveto(ownersideboard) and!( all(*|reveal) moveto(ownersideboard) )! optiontwoend afterrevealed all(tobecast|mysideboard) moveto(ownersideboard) and!(activate castcard(normal))! afterrevealedend revealend
text=Annihilator 1 (Whenever this creature attacks, defending player sacrifices a permanent.) -- {4}: Put two 0/1 colorless Eldrazi Spawn creature tokens onto the battlefield. They have "Sacrifice this creature: Add {1} to your mana pool." -- {20}: Cast any number of Eldrazi cards you own from outside the game without paying their mana costs.
mana={10}
type=Creature type=Creature
subtype=Eldrazi subtype=Eldrazi
power=7 power=7
toughness=11 toughness=11
text=Annihilator 1 (Whenever this creature attacks, defending player sacrifices a permanent.) -- {4}: Put two 0/1 colorless Eldrazi Spawn creature tokens onto the battlefield. They have "Sacrifice this creature: Add {1} to your mana pool." -- {20}: Cast any number of Eldrazi cards you own from outside the game without paying their mana costs.
[/card] [/card]
[card] [card]
name=Spawnwrithe name=Spawnwrithe

View File

@@ -1668,12 +1668,6 @@ mana={2}{R}{R}{R}
type=Sorcery type=Sorcery
[/card] [/card]
[card] [card]
name=Burning Wish
text=You may choose a sorcery card you own from outside the game, reveal that card, and put it into your hand. Exile Burning Wish.
mana={1}{R}
type=Sorcery
[/card]
[card]
name=Burning-Eye Zubera name=Burning-Eye Zubera
text=When Burning-Eye Zubera dies, if 4 or more damage was dealt to it this turn, Burning-Eye Zubera deals 3 damage to target creature or player. text=When Burning-Eye Zubera dies, if 4 or more damage was dealt to it this turn, Burning-Eye Zubera deals 3 damage to target creature or player.
mana={2}{R}{R} mana={2}{R}{R}
@@ -3087,12 +3081,6 @@ mana={4}{U}{U}
type=Sorcery type=Sorcery
[/card] [/card]
[card] [card]
name=Cunning Wish
text=You may choose an instant card you own from outside the game, reveal that card, and put it into your hand. Exile Cunning Wish.
mana={2}{U}
type=Instant
[/card]
[card]
name=Curious Homunculus name=Curious Homunculus
text={T}: Add {C} to your mana pool. Spend this mana only to cast an instant or sorcery spell. -- At the beginning of your upkeep, if there are three or more instant and/or sorcery cards in your graveyard, transform Curious Homunculus. text={T}: Add {C} to your mana pool. Spend this mana only to cast an instant or sorcery spell. -- At the beginning of your upkeep, if there are three or more instant and/or sorcery cards in your graveyard, transform Curious Homunculus.
mana={1}{U} mana={1}{U}
@@ -3461,12 +3449,6 @@ mana={4}{W}
type=Sorcery type=Sorcery
[/card] [/card]
[card] [card]
name=Death Wish
text=You may choose a card you own from outside the game and put it into your hand. You lose half your life, rounded up. Exile Death Wish.
mana={1}{B}{B}
type=Sorcery
[/card]
[card]
name=Death-Mask Duplicant name=Death-Mask Duplicant
text=Imprint — {1}: Exile target creature card from your graveyard. -- As long as a card exiled with Death-Mask Duplicant has flying, Death-Mask Duplicant has flying. The same is true for fear, first strike, double strike, haste, landwalk, protection, and trample. text=Imprint — {1}: Exile target creature card from your graveyard. -- As long as a card exiled with Death-Mask Duplicant has flying, Death-Mask Duplicant has flying. The same is true for fear, first strike, double strike, haste, landwalk, protection, and trample.
mana={7} mana={7}
@@ -5865,12 +5847,6 @@ power=1
toughness=1 toughness=1
[/card] [/card]
[card] [card]
name=Glittering Wish
text=You may choose a multicolored card you own from outside the game, reveal that card, and put it into your hand. Exile Glittering Wish.
mana={G}{W}
type=Sorcery
[/card]
[card]
name=Global Ruin name=Global Ruin
text=Each player chooses from the lands he or she controls a land of each basic land type, then sacrifices the rest. text=Each player chooses from the lands he or she controls a land of each basic land type, then sacrifices the rest.
mana={4}{W} mana={4}{W}
@@ -6073,12 +6049,6 @@ type=Legendary Artifact
subtype=Equipment subtype=Equipment
[/card] [/card]
[card] [card]
name=Golden Wish
text=You may choose an artifact or enchantment card you own from outside the game, reveal that card, and put it into your hand. Exile Golden Wish.
mana={3}{W}{W}
type=Sorcery
[/card]
[card]
name=Goldenhide Ox name=Goldenhide Ox
text=Constellation — Whenever Goldenhide Ox or another enchantment enters the battlefield under your control, target creature must be blocked this turn if able. text=Constellation — Whenever Goldenhide Ox or another enchantment enters the battlefield under your control, target creature must be blocked this turn if able.
mana={5}{G} mana={5}{G}
@@ -8879,12 +8849,6 @@ power=*
toughness=* toughness=*
[/card] [/card]
[card] [card]
name=Living Wish
text=You may choose a creature or land card you own from outside the game, reveal that card, and put it into your hand. Exile Living Wish.
mana={1}{G}
type=Sorcery
[/card]
[card]
name=Loafing Giant name=Loafing Giant
text=Whenever Loafing Giant attacks or blocks, put the top card of your library into your graveyard. If that card is a land card, prevent all combat damage Loafing Giant would deal this turn. text=Whenever Loafing Giant attacks or blocks, put the top card of your library into your graveyard. If that card is a land card, prevent all combat damage Loafing Giant would deal this turn.
mana={4}{R} mana={4}{R}

View File

@@ -411,8 +411,8 @@ private:
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
Player * p = card->getObserver()->players[i]; Player * p = card->getObserver()->players[i];
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile }; MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->sideboard };//wish cards use sideboard
for (int k = 0; k < 5; k++) for (int k = 0; k < 6; k++)
{ {
MTGGameZone * zone = zones[k]; MTGGameZone * zone = zones[k];
if (tc->targetsZone(zone, card)) if (tc->targetsZone(zone, card))

View File

@@ -29,7 +29,11 @@ enum
MENU_DECK_SELECTION = 10, MENU_DECK_SELECTION = 10,
MENU_DECK_BUILDER = 11, MENU_DECK_BUILDER = 11,
MENU_FIRST_DUEL_SUBMENU = 102, MENU_FIRST_DUEL_SUBMENU = 102,
MENU_LANGUAGE_SELECTION = 103 MENU_LANGUAGE_SELECTION = 103,
SBMENU_CHOICE = 802,
SBMENU_ADD_NORMAL = 803,
SBMENU_ADD_SB = 804,
SBMENU_ADD_CANCEL = 805
}; };
// enums for menu options // enums for menu options
@@ -71,18 +75,20 @@ private:
DeckViewerStages mStage; DeckViewerStages mStage;
JMusic * bgMusic; JMusic * bgMusic;
InteractiveButton *toggleDeckButton, *sellCardButton, *statsPrevButton, *filterButton, *toggleViewButton, *toggleUpButton, *toggleDownButton, *toggleLeftButton, *toggleRightButton; InteractiveButton *toggleDeckButton, *sbButton, *sellCardButton, *statsPrevButton, *filterButton, *toggleViewButton, *toggleUpButton, *toggleDownButton, *toggleLeftButton, *toggleRightButton;
WGuiFilters * filterMenu; WGuiFilters * filterMenu;
WSrcDeckViewer * source; WSrcDeckViewer * source;
DeckEditorMenu * welcome_menu; DeckEditorMenu * welcome_menu;
SimpleMenu * subMenu; SimpleMenu * subMenu;
SimpleMenu * sbMenu;
DeckEditorMenu * deckMenu; DeckEditorMenu * deckMenu;
PriceList* pricelist; PriceList* pricelist;
PlayerData * playerdata; PlayerData * playerdata;
DeckDataWrapper * myDeck; DeckDataWrapper * myDeck;
DeckDataWrapper * myCollection; DeckDataWrapper * myCollection;
DeckDataWrapper * mySideboard;
StatsWrapper * mStatsWrapper; StatsWrapper * mStatsWrapper;
int hudAlpha; int hudAlpha;
@@ -105,6 +111,7 @@ private:
void RenderButtons(); void RenderButtons();
void setupView(AvailableView view, DeckDataWrapper *deck); void setupView(AvailableView view, DeckDataWrapper *deck);
void toggleView(); void toggleView();
void insertSideBoard();
public: public:
GameStateDeckViewer(GameApp* parent); GameStateDeckViewer(GameApp* parent);
virtual ~GameStateDeckViewer(); virtual ~GameStateDeckViewer();
@@ -112,9 +119,12 @@ public:
void updateFilters(); void updateFilters();
void rebuildFilters(); void rebuildFilters();
void toggleCollection(); void toggleCollection();
void toggleSideBoard();
void Start(); void Start();
virtual void End(); virtual void End();
void addRemove(MTGCard * card); void addRemove(MTGCard * card);
void SBaddRemove(MTGCard * card);
void choiceAddRemove(MTGCard * card);
virtual void Update(float dt); virtual void Update(float dt);
void renderOnScreenBasicInfo(); void renderOnScreenBasicInfo();
void renderSlideBar(); void renderSlideBar();

View File

@@ -22,17 +22,18 @@ using std::string;
const int kDismissButtonId = 10000; const int kDismissButtonId = 10000;
const int kToggleDeckActionId = 10001; const int kToggleDeckActionId = 10001;
const int kSellCardActionId = 10002; const int kSellCardActionId = 10002;
const int kMenuButtonId = 10003; const int kSBActionId = 10003;
const int kFilterButtonId = 10004; const int kMenuButtonId = 10004;
const int kNextStatsButtonId = 10005; const int kFilterButtonId = 10005;
const int kPrevStatsButtonId = 10006; const int kNextStatsButtonId = 10006;
const int kCycleCardsButtonId = 10007; const int kPrevStatsButtonId = 10007;
const int kShowCardListButtonId = 10008; const int kCycleCardsButtonId = 10008;
const int kSwitchViewButton = 10009; const int kShowCardListButtonId = 10009;
const int kToggleUpButton = 10010; const int kSwitchViewButton = 10010;
const int kToggleDownButton = 10011; const int kToggleUpButton = 10011;
const int kToggleLeftButton = 10012; const int kToggleDownButton = 10012;
const int kToggleRightButton = 10013; const int kToggleLeftButton = 10013;
const int kToggleRightButton = 10014;
class InteractiveButton: public SimpleButton class InteractiveButton: public SimpleButton
{ {

View File

@@ -214,6 +214,7 @@ public:
string meta_desc; string meta_desc;
string meta_name; string meta_name;
vector<string> meta_AIHints; vector<string> meta_AIHints;
vector<string> Sideboard;
string meta_unlockRequirements; string meta_unlockRequirements;
int meta_id; int meta_id;
@@ -230,6 +231,7 @@ public:
int removeAll(); int removeAll();
int add(MTGCard * card); int add(MTGCard * card);
int remove(MTGCard * card); int remove(MTGCard * card);
void replaceSB(vector<string> newSB = vector<string>());
string getFilename(); string getFilename();
int save(); int save();
int save(const string& destFileName, bool useExpandedDescriptions, const string& deckTitle, const string& deckDesc); int save(const string& destFileName, bool useExpandedDescriptions, const string& deckTitle, const string& deckDesc);

View File

@@ -80,6 +80,13 @@ class MTGGameZone {
OWNER_REVEAL = 76, OWNER_REVEAL = 76,
TARGETED_PLAYER_REVEAL = 77, TARGETED_PLAYER_REVEAL = 77,
MY_SIDEBOARD = 81,
OPPONENT_SIDEBOARD = 82,
TARGET_OWNER_SIDEBOARD = 83,
TARGET_CONTROLLER_SIDEBOARD = 84,
SIDEBOARD = 85,
OWNER_SIDEBOARD = 86,
TARGETED_PLAYER_SIDEBOARD = 87,
}; };
Player * owner; Player * owner;
@@ -204,6 +211,7 @@ public:
MTGGameZone * garbage; MTGGameZone * garbage;
MTGGameZone * garbageLastTurn; MTGGameZone * garbageLastTurn;
MTGGameZone * reveal; MTGGameZone * reveal;
MTGGameZone * sideboard;
MTGGameZone * temp; MTGGameZone * temp;
MTGPlayerCards(); MTGPlayerCards();

View File

@@ -1861,7 +1861,7 @@ int AIPlayerBaka::createAbilityTargets(MTGAbility * a, MTGCardInstance * c, Rank
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
Player * p = observer->players[i]; Player * p = observer->players[i];
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay,p->game->stack,p->game->exile, p->game->reveal }; MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay,p->game->stack,p->game->exile, p->game->reveal, p->game->sideboard };
if(a->getActionTc()->canTarget((Targetable*)p)) if(a->getActionTc()->canTarget((Targetable*)p))
{ {
if(a->getActionTc()->maxtargets == 1) if(a->getActionTc()->maxtargets == 1)
@@ -2344,8 +2344,8 @@ int AIPlayerBaka::chooseTarget(TargetChooser * _tc, Player * forceTarget,MTGCard
} }
} }
MTGPlayerCards * playerZones = target->game; MTGPlayerCards * playerZones = target->game;
MTGGameZone * zones[] = { playerZones->hand, playerZones->library, playerZones->inPlay, playerZones->graveyard,playerZones->stack,playerZones->exile,playerZones->reveal }; MTGGameZone * zones[] = { playerZones->hand, playerZones->library, playerZones->inPlay, playerZones->graveyard,playerZones->stack,playerZones->exile,playerZones->reveal, playerZones->sideboard };
for (int j = 0; j < 7; j++) for (int j = 0; j < 8; j++)
{ {
MTGGameZone * zone = zones[j]; MTGGameZone * zone = zones[j];
for (int k = 0; k < zone->nb_cards; k++) for (int k = 0; k < zone->nb_cards; k++)

View File

@@ -58,10 +58,11 @@ void DeckEditorMenu::Render()
DeckMenu::Render(); DeckMenu::Render();
if (deckTitle.size() > 0) if (deckTitle.size() > 0)
{ {
float modt = (float)deckTitle.size()/2;
WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT);
DWORD currentColor = mainFont->GetColor(); DWORD currentColor = mainFont->GetColor();
mainFont->SetColor(ARGB(255,255,255,255)); mainFont->SetColor(ARGB(255,255,255,255));
mainFont->DrawString(deckTitle.c_str(), (SCREEN_WIDTH_F / 2)-15, (statsHeight / 2)+4, JGETEXT_CENTER); mainFont->DrawString(deckTitle.c_str(), (SCREEN_WIDTH_F / 2)-modt, (statsHeight / 2)+4, JGETEXT_CENTER);
mainFont->SetColor(currentColor); mainFont->SetColor(currentColor);
} }
@@ -75,7 +76,7 @@ void DeckEditorMenu::drawDeckStatistics()
deckStatsString deckStatsString
<< _("------- Deck Summary -----") << endl << _("------- Deck Summary -----") << endl
<< _("Cards: ") << stw->cardCount << endl << _("Cards: ") << stw->cardCount << " Sideboard: " << selectedDeck->parent->Sideboard.size() << endl
<< _("Creatures: ") << setw(2) << stw->countCreatures << _("Creatures: ") << setw(2) << stw->countCreatures
<< _(" Enchantments: ") << stw->countEnchantments << endl << _(" Enchantments: ") << stw->countEnchantments << endl
<< _("Instants: ") << setw(4) << stw->countInstants << _("Instants: ") << setw(4) << stw->countInstants

View File

@@ -37,16 +37,19 @@ GameStateDeckViewer::GameStateDeckViewer(GameApp* parent) :
welcome_menu = NULL; welcome_menu = NULL;
myCollection = NULL; myCollection = NULL;
myDeck = NULL; myDeck = NULL;
mySideboard = NULL;
filterMenu = NULL; filterMenu = NULL;
source = NULL; source = NULL;
hudAlpha = 0; hudAlpha = 0;
subMenu = NULL; subMenu = NULL;
sbMenu = NULL;
deckMenu = NULL; deckMenu = NULL;
mStatsWrapper = NULL; mStatsWrapper = NULL;
statsPrevButton = NEW InteractiveButton(NULL, kPrevStatsButtonId, Fonts::MAIN_FONT, "Stats", SCREEN_WIDTH_F - 35, SCREEN_HEIGHT_F - 20, JGE_BTN_PREV); statsPrevButton = NEW InteractiveButton(NULL, kPrevStatsButtonId, Fonts::MAIN_FONT, "Stats", SCREEN_WIDTH_F - 35, SCREEN_HEIGHT_F - 20, JGE_BTN_PREV);
toggleDeckButton = NEW InteractiveButton(NULL, kToggleDeckActionId, Fonts::MAIN_FONT, "View Deck", 10, SCREEN_HEIGHT_F - 20, JGE_BTN_PRI); toggleDeckButton = NEW InteractiveButton(NULL, kToggleDeckActionId, Fonts::MAIN_FONT, "View Deck", 10, SCREEN_HEIGHT_F - 20, JGE_BTN_PRI);
sellCardButton = NEW InteractiveButton(NULL, kSellCardActionId, Fonts::MAIN_FONT, "Sell Card", (SCREEN_WIDTH_F/ 2) - 100, SCREEN_HEIGHT_F - 20, JGE_BTN_SEC); sellCardButton = NEW InteractiveButton(NULL, kSellCardActionId, Fonts::MAIN_FONT, "Sell Card", (SCREEN_WIDTH_F/ 2) - 125, SCREEN_HEIGHT_F - 20, JGE_BTN_SEC);
sbButton = NEW InteractiveButton(NULL, kSBActionId, Fonts::MAIN_FONT, "View SB", (SCREEN_WIDTH_F/ 2) - 35, SCREEN_HEIGHT_F - 20, JGE_BTN_SOUND);
filterButton = NEW InteractiveButton(NULL, kFilterButtonId, Fonts::MAIN_FONT, "Filter", (SCREEN_WIDTH_F - 116), SCREEN_HEIGHT_F - 20, JGE_BTN_CTRL); filterButton = NEW InteractiveButton(NULL, kFilterButtonId, Fonts::MAIN_FONT, "Filter", (SCREEN_WIDTH_F - 116), SCREEN_HEIGHT_F - 20, JGE_BTN_CTRL);
//TODO: Check if that button is available: //TODO: Check if that button is available:
toggleViewButton = NEW InteractiveButton(NULL, kSwitchViewButton, Fonts::MAIN_FONT, "Grid", (SCREEN_WIDTH_F/ 2) + 50, SCREEN_HEIGHT_F - 20, JGE_BTN_MAX); toggleViewButton = NEW InteractiveButton(NULL, kSwitchViewButton, Fonts::MAIN_FONT, "Grid", (SCREEN_WIDTH_F/ 2) + 50, SCREEN_HEIGHT_F - 20, JGE_BTN_MAX);
@@ -61,6 +64,7 @@ GameStateDeckViewer::~GameStateDeckViewer()
SAFE_DELETE(bgMusic); SAFE_DELETE(bgMusic);
SAFE_DELETE(toggleDeckButton); SAFE_DELETE(toggleDeckButton);
SAFE_DELETE(sellCardButton); SAFE_DELETE(sellCardButton);
SAFE_DELETE(sbButton);
SAFE_DELETE(statsPrevButton); SAFE_DELETE(statsPrevButton);
SAFE_DELETE(filterButton); SAFE_DELETE(filterButton);
SAFE_DELETE(toggleViewButton); SAFE_DELETE(toggleViewButton);
@@ -75,6 +79,11 @@ GameStateDeckViewer::~GameStateDeckViewer()
SAFE_DELETE(myDeck->parent); SAFE_DELETE(myDeck->parent);
SAFE_DELETE(myDeck); SAFE_DELETE(myDeck);
} }
if (mySideboard)
{
SAFE_DELETE(mySideboard->parent);
SAFE_DELETE(mySideboard);
}
if (myCollection) if (myCollection)
{ {
SAFE_DELETE(myCollection->parent); SAFE_DELETE(myCollection->parent);
@@ -110,9 +119,12 @@ void GameStateDeckViewer::updateFilters()
void GameStateDeckViewer::toggleCollection() void GameStateDeckViewer::toggleCollection()
{ {
if(mView->deck() == mySideboard)
return;
if (mView->deck() == myCollection) if (mView->deck() == myCollection)
{ {
toggleDeckButton->setText("View Collection"); toggleDeckButton->setText("Collection");
mView->SetDeck(myDeck); mView->SetDeck(myDeck);
} }
else else
@@ -124,6 +136,23 @@ void GameStateDeckViewer::toggleCollection()
updateFilters(); updateFilters();
} }
void GameStateDeckViewer::toggleSideBoard()
{
if(mView->deck() == myDeck)
return;
if (mView->deck() == myCollection)
{
mView->SetDeck(mySideboard);
}
else
{
mView->SetDeck(myCollection);
}
//source->swapSrc();
//updateFilters();
}
//after renaming and on the first start. //after renaming and on the first start.
//reloadWelcomeMenu //reloadWelcomeMenu
void GameStateDeckViewer::updateDecks() void GameStateDeckViewer::updateDecks()
@@ -164,7 +193,9 @@ void GameStateDeckViewer::Start()
hudAlpha = 0; hudAlpha = 0;
mSwitching = false; mSwitching = false;
subMenu = NULL; subMenu = NULL;
sbMenu = NULL;
myDeck = NULL; myDeck = NULL;
mySideboard = NULL;
mStage = STAGE_WELCOME; mStage = STAGE_WELCOME;
last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1; last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1;
@@ -215,6 +246,7 @@ void GameStateDeckViewer::End()
SAFE_DELETE(welcome_menu); SAFE_DELETE(welcome_menu);
SAFE_DELETE(deckMenu); SAFE_DELETE(deckMenu);
SAFE_DELETE(subMenu); SAFE_DELETE(subMenu);
SAFE_DELETE(sbMenu);
WResourceManager::Instance()->Release(pspIconsTexture); WResourceManager::Instance()->Release(pspIconsTexture);
if (myCollection) if (myCollection)
@@ -226,6 +258,11 @@ void GameStateDeckViewer::End()
SAFE_DELETE(myDeck->parent); SAFE_DELETE(myDeck->parent);
SAFE_DELETE(myDeck); SAFE_DELETE(myDeck);
} }
if (mySideboard)
{
SAFE_DELETE(mySideboard->parent);
SAFE_DELETE(mySideboard);
}
SAFE_DELETE(pricelist); SAFE_DELETE(pricelist);
SAFE_DELETE(playerdata); SAFE_DELETE(playerdata);
SAFE_DELETE(filterMenu); SAFE_DELETE(filterMenu);
@@ -254,6 +291,75 @@ void GameStateDeckViewer::addRemove(MTGCard * card)
mView->reloadIndexes(); mView->reloadIndexes();
} }
void GameStateDeckViewer::SBaddRemove(MTGCard * card)
{
if (!card) return;
if ((card->getRarity() == Constants::RARITY_T) || (card->getId() < 1)) return;
if (mView->deck()->Remove(card, 1, (mView->deck() == mySideboard)))
{
if (mView->deck() == myCollection)
{
mySideboard->Add(card);
mySideboard->Sort(WSrcCards::SORT_ALPHA);
}
else
{
myCollection->Add(card);
}
}
myCollection->validate();
mySideboard->validate();
mStatsWrapper->needUpdate = true;
mView->reloadIndexes();
}
void GameStateDeckViewer::choiceAddRemove(MTGCard * card)
{
if (!card) return;
if ((card->getRarity() == Constants::RARITY_T) || (card->getId() < 1)) return;
last_user_activity = 0;
const float menuXOffset = SCREEN_WIDTH_F - 300;
const float menuYOffset = SCREEN_HEIGHT_F / 2;
SAFE_DELETE(sbMenu);
{
if (mView->deck() == myCollection)
{
sbMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), SBMENU_CHOICE, this, Fonts::MAIN_FONT, menuXOffset, menuYOffset, "Add/Remove Cards");
sbMenu->Add(SBMENU_ADD_NORMAL, "Add to Deck");
sbMenu->Add(SBMENU_ADD_SB, "Add to Sideboard");
sbMenu->Add(SBMENU_ADD_CANCEL, "Cancel");
}
else
{
sbMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), SBMENU_CHOICE, this, Fonts::MAIN_FONT, menuXOffset, menuYOffset, "Add/Remove Cards");
sbMenu->Add(SBMENU_ADD_NORMAL, "Remove Card");
//sbMenu->Add(SBMENU_ADD_SB, "Add to Sideboard");
sbMenu->Add(SBMENU_ADD_CANCEL, "Cancel");
}
}
mStatsWrapper->needUpdate = true;
}
void GameStateDeckViewer::insertSideBoard()
{
if(mySideboard->getCount())
{
vector<string> newSB;
for (int i = 0; i < mySideboard->Size(true); i++)
{
MTGCard * current = mySideboard->getCard(i, true);
int howmanyinDeck = mySideboard->count(current);
for (int i = 0; i < howmanyinDeck; i++)
{
stringstream cid;
cid << current->getMTGId();
newSB.push_back(cid.str());
}
}
myDeck->parent->replaceSB(newSB);
}
}
void GameStateDeckViewer::saveDeck() void GameStateDeckViewer::saveDeck()
{ {
//update the corresponding meta data object //update the corresponding meta data object
@@ -261,6 +367,9 @@ void GameStateDeckViewer::saveDeck()
if ( newDeckname.length() > 0 ) if ( newDeckname.length() > 0 )
metaData->setDeckName( newDeckname ); metaData->setDeckName( newDeckname );
mSwitching = true; mSwitching = true;
//insert sideboards to mydeck parents
insertSideBoard();
//save deck
myDeck->save(); myDeck->save();
playerdata->save(); playerdata->save();
pricelist->save(); pricelist->save();
@@ -315,6 +424,7 @@ bool GameStateDeckViewer::userPressedButton()
{ {
return ((toggleDeckButton->ButtonPressed()) return ((toggleDeckButton->ButtonPressed())
|| (sellCardButton->ButtonPressed()) || (sellCardButton->ButtonPressed())
|| (sbButton->ButtonPressed())
|| (statsPrevButton->ButtonPressed()) || (statsPrevButton->ButtonPressed())
|| (filterButton->ButtonPressed()) || (filterButton->ButtonPressed())
|| (toggleViewButton->ButtonPressed()) || (toggleViewButton->ButtonPressed())
@@ -329,6 +439,7 @@ void GameStateDeckViewer::setButtonState(bool state)
{ {
toggleDeckButton->setIsSelectionValid(state); toggleDeckButton->setIsSelectionValid(state);
sellCardButton->setIsSelectionValid(state); sellCardButton->setIsSelectionValid(state);
sbButton->setIsSelectionValid(state);
statsPrevButton->setIsSelectionValid(state); statsPrevButton->setIsSelectionValid(state);
filterButton->setIsSelectionValid(state); filterButton->setIsSelectionValid(state);
toggleViewButton->setIsSelectionValid(state); toggleViewButton->setIsSelectionValid(state);
@@ -340,9 +451,13 @@ void GameStateDeckViewer::setButtonState(bool state)
void GameStateDeckViewer::RenderButtons() void GameStateDeckViewer::RenderButtons()
{ {
toggleDeckButton->Render(); if(mView->deck() != mySideboard)
toggleDeckButton->Render();
sellCardButton->Render(); sellCardButton->Render();
filterButton->Render(); if(mView->deck() != myDeck)
sbButton->Render();
if(mView->deck() != mySideboard)
filterButton->Render();
statsPrevButton->Render(); statsPrevButton->Render();
toggleViewButton->Render(); toggleViewButton->Render();
toggleUpButton->Render(); toggleUpButton->Render();
@@ -418,6 +533,15 @@ void GameStateDeckViewer::Update(float dt)
} }
return; return;
} }
if (sbMenu)
{
sbMenu->Update(dt);
if (sbMenu->isClosed())
{
SAFE_DELETE(sbMenu);
}
return;
}
if (mStage == STAGE_WAITING || mStage == STAGE_ONSCREEN_MENU) if (mStage == STAGE_WAITING || mStage == STAGE_ONSCREEN_MENU)
{ {
JButton button = mEngine->ReadButton(); JButton button = mEngine->ReadButton();
@@ -436,6 +560,13 @@ void GameStateDeckViewer::Update(float dt)
case JGE_BTN_CANCEL: case JGE_BTN_CANCEL:
options[Options::DISABLECARDS].number = !options[Options::DISABLECARDS].number; options[Options::DISABLECARDS].number = !options[Options::DISABLECARDS].number;
break; break;
case JGE_BTN_SOUND:
if (last_user_activity > 0.2)
{
last_user_activity = 0;
toggleSideBoard();
}
break;
case JGE_BTN_PRI: case JGE_BTN_PRI:
if (last_user_activity > 0.2) if (last_user_activity > 0.2)
{ {
@@ -465,14 +596,16 @@ void GameStateDeckViewer::Update(float dt)
mEngine->LeftClickedProcessed(); mEngine->LeftClickedProcessed();
if(mView->Click(x, y) != NULL) if(mView->Click(x, y) != NULL)
{ {
addRemove(mView->getActiveCard()); //addRemove(mView->getActiveCard());
choiceAddRemove(mView->getActiveCard());
} }
} }
else else
{ {
if(mView->Click() != NULL) if(mView->Click() != NULL)
{ {
addRemove(mView->getActiveCard()); //addRemove(mView->getActiveCard());
choiceAddRemove(mView->getActiveCard());
} }
} }
@@ -485,11 +618,20 @@ void GameStateDeckViewer::Update(float dt)
break; break;
case JGE_BTN_MENU: case JGE_BTN_MENU:
mStage = STAGE_MENU; if(mView->deck() == mySideboard)
buildEditorMenu(); {
toggleSideBoard();
}
else
{
mStage = STAGE_MENU;
buildEditorMenu();
}
break; break;
case JGE_BTN_CTRL: case JGE_BTN_CTRL:
if(!mView->ButtonPressed(JGE_BTN_CTRL)) if (mView->deck() == mySideboard)
break;//SB is for viewing add or remove only
else if(!mView->ButtonPressed(JGE_BTN_CTRL))
{ {
mStage = STAGE_FILTERS; mStage = STAGE_FILTERS;
if (!filterMenu) if (!filterMenu)
@@ -774,27 +916,21 @@ void GameStateDeckViewer::renderOnScreenMenu()
char buffer[300]; char buffer[300];
int nb_letters = 0; int nb_letters = 0;
int value = myDeck->getCount(WSrcDeck::UNFILTERED_COPIES); int value = myDeck->getCount(WSrcDeck::UNFILTERED_COPIES);
int sb_value = mySideboard->getCount(WSrcDeck::UNFILTERED_COPIES);
sprintf(buffer, _("Your Deck: %i cards").c_str(), value);
font->DrawString(buffer, SCREEN_WIDTH - 200 + rightTransition, SCREEN_HEIGHT / 2 + 25); sprintf(buffer, _("Your Deck: %i cards.\nSideboard: %i cards").c_str(), value, sb_value);
font->DrawString(buffer, SCREEN_WIDTH - 200 + rightTransition, SCREEN_HEIGHT / 2 + 15);
for (int j = 0; j < Constants::NB_Colors; j++) for (int j = 0; j < Constants::NB_Colors; j++)
{ {
int value = myDeck->getCount(j); int value = myDeck->getCount(j);
if (value > 0) if(value > 0)
{ {
int modx = value < 9?2:0;
r->RenderQuad(mIcons[j].get(), SCREEN_WIDTH - 190 + rightTransition + nb_letters * 8, SCREEN_HEIGHT / 2 + 49, 0, 0.45f,0.45f);
sprintf(buffer, "%i", value); sprintf(buffer, "%i", value);
font->DrawString(buffer, SCREEN_WIDTH - 190 + rightTransition + nb_letters * 13, SCREEN_HEIGHT / 2 + 40); font->DrawString(buffer, SCREEN_WIDTH - 195 + rightTransition + modx + nb_letters * 8, SCREEN_HEIGHT / 2 + 55);
r->RenderQuad(mIcons[j].get(), SCREEN_WIDTH - 197 + rightTransition + nb_letters * 13, SCREEN_HEIGHT / 2 + 46, 0, 0.5, nb_letters += 3;
0.5);
if (value > 9)
{
nb_letters += 3;
}
else
{
nb_letters += 2;
}
} }
} }
@@ -1330,6 +1466,8 @@ void GameStateDeckViewer::Render()
if (subMenu) subMenu->Render(); if (subMenu) subMenu->Render();
if (sbMenu) sbMenu->Render();
if (filterMenu && !filterMenu->isFinished()) if (filterMenu && !filterMenu->isFinished())
{ {
setButtonState(false); setButtonState(false);
@@ -1372,6 +1510,7 @@ int GameStateDeckViewer::loadDeck(int deckid)
// Check whether the cards in the deck are actually available in the player's collection: // Check whether the cards in the deck are actually available in the player's collection:
int cheatmode = options[Options::CHEATMODE].number; int cheatmode = options[Options::CHEATMODE].number;
bool bPure = true; bool bPure = true;
bool cPure = true;
for (int i = 0; i < myDeck->Size(true); i++) for (int i = 0; i < myDeck->Size(true); i++)
{ {
MTGCard * current = myDeck->getCard(i, true); MTGCard * current = myDeck->getCard(i, true);
@@ -1398,8 +1537,56 @@ int GameStateDeckViewer::loadDeck(int deckid)
myDeck->validate(); myDeck->validate();
myCollection->validate(); myCollection->validate();
} }
//sb
if (mySideboard)
{
SAFE_DELETE(mySideboard->parent);
SAFE_DELETE(mySideboard);
}
//temp deck for sb?
MTGDeck * tempDeck = NEW MTGDeck(MTGCollection());
if(myDeck->parent)
{//add cards from sdeboard lists
if(myDeck->parent->Sideboard.size())
{
for(unsigned int j = 0; j < myDeck->parent->Sideboard.size(); j++)
{
string cardID = myDeck->parent->Sideboard[j];
tempDeck->add(atoi(cardID.c_str()));
}
}
}
mySideboard = NEW DeckDataWrapper(tempDeck);
for (int i = 0; i < mySideboard->Size(true); i++)
{
MTGCard * current = mySideboard->getCard(i, true);
int howmanyinDeck = mySideboard->count(current);
for (int i = myCollection->count(current); i < howmanyinDeck; i++)
{
cPure = false;
if (cheatmode)
{ //Are we cheating?
playerdata->collection->add(current); //Yup, add it to collection permanently.
myCollection->Add(current);
}
else
{
mySideboard->Remove(current,howmanyinDeck-i); //Nope. Remove it from sb.
break;
}
}
myCollection->Remove(current, mySideboard->count(current));
}
if (!cPure)
{
mySideboard->validate();
myCollection->validate();
}
//endsb
myDeck->Sort(WSrcCards::SORT_ALPHA); myDeck->Sort(WSrcCards::SORT_ALPHA);
mySideboard->Sort(WSrcCards::SORT_ALPHA);
SAFE_DELETE(filterMenu); SAFE_DELETE(filterMenu);
rebuildFilters(); rebuildFilters();
mView->reloadIndexes(); mView->reloadIndexes();
@@ -1537,6 +1724,30 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
subMenu->Close(); subMenu->Close();
break; break;
} }
case SBMENU_CHOICE: // sideboard
switch (controlId)
{
case SBMENU_ADD_NORMAL:
{
MTGCard * card = mView->getActiveCard();
if (card)
addRemove(card);
sbMenu->Close();
break;
}
case SBMENU_ADD_SB:
{
MTGCard * card = mView->getActiveCard();
if (card)
SBaddRemove(card);
sbMenu->Close();
break;
}
case SBMENU_ADD_CANCEL:
sbMenu->Close();
break;
}
} }
} }

View File

@@ -6081,8 +6081,8 @@ void ListMaintainerAbility::updateTargets()
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
Player * p = game->players[i]; Player * p = game->players[i];
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile ,p->game->reveal }; MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile ,p->game->reveal, p->game->sideboard };
for (int k = 0; k < 7; k++) for (int k = 0; k < 8; k++)
{ {
MTGGameZone * zone = zones[k]; MTGGameZone * zone = zones[k];
if (canTarget(zone)) if (canTarget(zone))
@@ -6153,8 +6153,8 @@ void ListMaintainerAbility::checkTargets()
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
Player * p = game->players[i]; Player * p = game->players[i];
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile, p->game->reveal }; MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile, p->game->reveal, p->game->sideboard };
for (int k = 0; k < 7; k++) for (int k = 0; k < 8; k++)
{ {
MTGGameZone * zone = zones[k]; MTGGameZone * zone = zones[k];
if (canTarget(zone)) if (canTarget(zone))

View File

@@ -880,6 +880,12 @@ MTGDeck::MTGDeck(const string& config_file, MTGAllCards * _allcards, int meta_on
meta_unlockRequirements = s.substr(found + 7); meta_unlockRequirements = s.substr(found + 7);
continue; continue;
} }
found = s.find("SB:");
if (found != string::npos)
{
Sideboard.push_back(s.substr(found + 3));
continue;
}
continue; continue;
} }
if (meta_only) break; if (meta_only) break;
@@ -1101,6 +1107,16 @@ int MTGDeck::removeAll()
return 1; return 1;
} }
void MTGDeck::replaceSB(vector<string> newSB)
{
if(newSB.size())
{
Sideboard.clear();
Sideboard = newSB;
}
return;
}
int MTGDeck::remove(int cardid) int MTGDeck::remove(int cardid)
{ {
if (cards.find(cardid) == cards.end() || cards[cardid] == 0) return 0; if (cards.find(cardid) == cards.end() || cards[cardid] == 0) return 0;
@@ -1170,6 +1186,18 @@ int MTGDeck::save(const string& destFileName, bool useExpandedDescriptions, cons
} }
} }
} }
//save sideboards
if(Sideboard.size())
{
sort(Sideboard.begin(), Sideboard.end());
for(unsigned int k = 0; k < Sideboard.size(); k++)
{
int checkID = atoi(Sideboard[k].c_str());
if(checkID)
file << "#SB:" << checkID << "\n";
}
}
file.close(); file.close();
JFileSystem::GetInstance()->Rename(tmp, destFileName); JFileSystem::GetInstance()->Rename(tmp, destFileName);
} }

View File

@@ -63,6 +63,21 @@ void MTGPlayerCards::initDeck(MTGDeck * deck)
} }
} }
} }
//sb init
if(deck->Sideboard.size())
{
for(unsigned int j = 0; j < deck->Sideboard.size(); j++)
{
string cardID = deck->Sideboard[j];
MTGCard * card = MTGCollection()->getCardById(atoi(cardID.c_str()));
if(card)
{
MTGCardInstance * newCard = NEW MTGCardInstance(card, this);
//sb zone
sideboard->addCard(newCard);
}
}
}
} }
MTGPlayerCards::~MTGPlayerCards() MTGPlayerCards::~MTGPlayerCards()
@@ -75,6 +90,7 @@ MTGPlayerCards::~MTGPlayerCards()
SAFE_DELETE(removedFromGame); SAFE_DELETE(removedFromGame);
SAFE_DELETE(garbage); SAFE_DELETE(garbage);
SAFE_DELETE(reveal); SAFE_DELETE(reveal);
SAFE_DELETE(sideboard);
SAFE_DELETE(temp); SAFE_DELETE(temp);
SAFE_DELETE(playRestrictions); SAFE_DELETE(playRestrictions);
} }
@@ -93,6 +109,7 @@ void MTGPlayerCards::beforeBeginPhase()
removedFromGame->beforeBeginPhase(); removedFromGame->beforeBeginPhase();
garbage->beforeBeginPhase(); garbage->beforeBeginPhase();
reveal->beforeBeginPhase(); reveal->beforeBeginPhase();
sideboard->beforeBeginPhase();
temp->beforeBeginPhase(); temp->beforeBeginPhase();
} }
@@ -108,6 +125,7 @@ void MTGPlayerCards::setOwner(Player * player)
garbage->setOwner(player); garbage->setOwner(player);
garbageLastTurn->setOwner(player); garbageLastTurn->setOwner(player);
reveal->setOwner(player); reveal->setOwner(player);
sideboard->setOwner(player);
temp->setOwner(player); temp->setOwner(player);
} }
@@ -276,6 +294,7 @@ void MTGPlayerCards::init()
garbage = NEW MTGGameZone(); garbage = NEW MTGGameZone();
garbageLastTurn = garbage; garbageLastTurn = garbage;
reveal = NEW MTGGameZone(); reveal = NEW MTGGameZone();
sideboard = NEW MTGGameZone();
temp = NEW MTGGameZone(); temp = NEW MTGGameZone();
playRestrictions = NEW PlayRestrictions(); playRestrictions = NEW PlayRestrictions();
@@ -1084,6 +1103,13 @@ MTGGameZone * MTGGameZone::intToZone(int zoneId, Player * p, Player * p2)
case REVEAL: case REVEAL:
return p->game->reveal; return p->game->reveal;
case MY_SIDEBOARD:
return p->game->sideboard;
case OPPONENT_SIDEBOARD:
return p->opponent()->game->sideboard;
case SIDEBOARD:
return p->game->sideboard;
} }
if (!p2) return NULL; if (!p2) return NULL;
switch (zoneId) switch (zoneId)
@@ -1109,6 +1135,9 @@ MTGGameZone * MTGGameZone::intToZone(int zoneId, Player * p, Player * p2)
case TARGET_CONTROLLER_REVEAL: case TARGET_CONTROLLER_REVEAL:
return p2->game->reveal; return p2->game->reveal;
case TARGET_CONTROLLER_SIDEBOARD:
return p2->game->sideboard;
default: default:
return NULL; return NULL;
} }
@@ -1218,6 +1247,17 @@ MTGGameZone * MTGGameZone::intToZone(GameObserver *g, int zoneId, MTGCardInstanc
return source->playerTarget->game->reveal; return source->playerTarget->game->reveal;
else return source->controller()->game->reveal; else return source->controller()->game->reveal;
case TARGET_OWNER_SIDEBOARD:
return target->owner->game->sideboard;
case SIDEBOARD:
return target->owner->game->sideboard;
case OWNER_SIDEBOARD:
return target->owner->game->sideboard;
case TARGETED_PLAYER_SIDEBOARD:
if (source->playerTarget)
return source->playerTarget->game->sideboard;
else return source->controller()->game->sideboard;
default: default:
return NULL; return NULL;
} }
@@ -1245,7 +1285,9 @@ int MTGGameZone::zoneStringToId(string zoneName)
"mystack", "opponentstack", "targetownerstack", "targetcontrollerstack", "ownerstack", "stack","targetedpersonsstack", "mystack", "opponentstack", "targetownerstack", "targetcontrollerstack", "ownerstack", "stack","targetedpersonsstack",
"myreveal", "opponentreveal", "targetownerreveal", "targetcontrollerreveal", "ownerreveal", "reveal","targetedpersonsreveal", "myreveal", "opponentreveal", "targetownerreveal", "targetcontrollerreveal", "ownerreveal", "reveal","targetedpersonsreveal",
"mysideboard", "opponentsideboard", "targetownersideboard", "targetcontrollersideboard", "ownersideboard", "sideboard","targetedpersonssideboard",
}; };
@@ -1268,7 +1310,9 @@ int MTGGameZone::zoneStringToId(string zoneName)
MY_STACK, OPPONENT_STACK, TARGET_OWNER_STACK, TARGET_CONTROLLER_STACK, OWNER_STACK, STACK,TARGETED_PLAYER_STACK, MY_STACK, OPPONENT_STACK, TARGET_OWNER_STACK, TARGET_CONTROLLER_STACK, OWNER_STACK, STACK,TARGETED_PLAYER_STACK,
MY_REVEAL, OPPONENT_REVEAL, TARGET_OWNER_REVEAL, TARGET_CONTROLLER_REVEAL, OWNER_REVEAL, REVEAL,TARGETED_PLAYER_REVEAL }; MY_REVEAL, OPPONENT_REVEAL, TARGET_OWNER_REVEAL, TARGET_CONTROLLER_REVEAL, OWNER_REVEAL, REVEAL,TARGETED_PLAYER_REVEAL,
MY_SIDEBOARD, OPPONENT_SIDEBOARD, TARGET_OWNER_SIDEBOARD, TARGET_CONTROLLER_SIDEBOARD, OWNER_SIDEBOARD, SIDEBOARD,TARGETED_PLAYER_SIDEBOARD };
int max = sizeof(values) / sizeof *(values); int max = sizeof(values) / sizeof *(values);

View File

@@ -414,13 +414,14 @@ void Rules::initGame(GameObserver *g, bool currentPlayerSet)
{ {
p->mAvatarName = initState.playerData[i].player->mAvatarName; p->mAvatarName = initState.playerData[i].player->mAvatarName;
} }
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->exile , p->game->reveal }; MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->exile , p->game->reveal, p->game->sideboard };
MTGGameZone * loadedPlayerZones[] = { initState.playerData[i].player->game->graveyard, MTGGameZone * loadedPlayerZones[] = { initState.playerData[i].player->game->graveyard,
initState.playerData[i].player->game->library, initState.playerData[i].player->game->library,
initState.playerData[i].player->game->hand, initState.playerData[i].player->game->hand,
initState.playerData[i].player->game->inPlay, initState.playerData[i].player->game->inPlay,
initState.playerData[i].player->game->exile, initState.playerData[i].player->game->exile,
initState.playerData[i].player->game->reveal }; initState.playerData[i].player->game->reveal,
initState.playerData[i].player->game->sideboard };
for (int j = 0; j < 5; j++) for (int j = 0; j < 5; j++)
{ {
MTGGameZone * zone = playerZones[j]; MTGGameZone * zone = playerZones[j];

View File

@@ -156,6 +156,11 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
{ {
zones[nbzones++] = MTGGameZone::ALL_ZONES; zones[nbzones++] = MTGGameZone::ALL_ZONES;
} }
else if (zoneName.compare("sideboard") == 0)
{
zones[nbzones++] = MTGGameZone::MY_SIDEBOARD;
zones[nbzones++] = MTGGameZone::OPPONENT_SIDEBOARD;
}
else if (zoneName.compare("reveal") == 0) else if (zoneName.compare("reveal") == 0)
{ {
zones[nbzones++] = MTGGameZone::MY_REVEAL; zones[nbzones++] = MTGGameZone::MY_REVEAL;
@@ -1111,8 +1116,8 @@ bool TargetChooser::validTargetsExist(int maxTargets)
int maxAmount = 0; int maxAmount = 0;
Player *p = observer->players[i]; Player *p = observer->players[i];
if (canTarget(p)) return true; if (canTarget(p)) return true;
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->stack, p->game->reveal }; MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->stack, p->game->reveal, p->game->sideboard };
for (int k = 0; k < 7; k++) for (int k = 0; k < 8; k++)
{ {
MTGGameZone * z = zones[k]; MTGGameZone * z = zones[k];
if (targetsZone(z)) if (targetsZone(z))
@@ -1145,8 +1150,8 @@ int TargetChooser::countValidTargets(bool withoutProtections)
Player *p = observer->players[i]; Player *p = observer->players[i];
if(canTarget(p)) if(canTarget(p))
result++; result++;
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->stack, p->game->reveal }; MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->stack, p->game->reveal, p->game->sideboard };
for (int k = 0; k < 7; k++) for (int k = 0; k < 8; k++)
{ {
MTGGameZone * z = zones[k]; MTGGameZone * z = zones[k];
if (targetsZone(z)) if (targetsZone(z))