Improved Commander format card selection rule, added new keyword

"autocommandzone=" to trigger abilities from Command Zone (e.g. Commander Ninjutsu), added/fixed some primitives, added a new GUI Button to show Player's Sideboard.
This commit is contained in:
valfieri
2020-12-08 20:48:11 +01:00
parent d18232df10
commit 7c696ac213
25 changed files with 207 additions and 74 deletions
+2 -2
View File
@@ -1908,7 +1908,7 @@ int AIPlayerBaka::createAbilityTargets(MTGAbility * a, MTGCardInstance * c, Rank
for (int i = 0; i < 2; 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, p->game->sideboard, p->game->commandzone };
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay,p->game->stack,p->game->exile, p->game->commandzone, p->game->sideboard, p->game->reveal };
if(a->getActionTc()->canTarget((Targetable*)p))
{
if(a->getActionTc()->maxtargets == 1)
@@ -2395,7 +2395,7 @@ int AIPlayerBaka::chooseTarget(TargetChooser * _tc, Player * forceTarget,MTGCard
}
}
MTGPlayerCards * playerZones = target->game;
MTGGameZone * zones[] = { playerZones->hand, playerZones->library, playerZones->inPlay, playerZones->graveyard,playerZones->stack,playerZones->exile,playerZones->reveal, playerZones->sideboard, playerZones->commandzone };
MTGGameZone * zones[] = { playerZones->hand, playerZones->library, playerZones->inPlay, playerZones->graveyard,playerZones->stack,playerZones->exile,playerZones->commandzone, playerZones->sideboard, playerZones->reveal };
for (int j = 0; j < 9; j++)
{
MTGGameZone * zone = zones[j];
+14
View File
@@ -908,6 +908,7 @@ void GameObserver::gameStateBasedEffects()
{
card->graveEffects = false;
card->exileEffects = false;
card->commandZoneEffects = false;
if(card->isCreature())
{
@@ -1348,6 +1349,8 @@ void GameObserver::ButtonPressed(PlayGuiObject * target)
exile->toggleDisplay();
else if (GuiCommandZone* commandzone = dynamic_cast<GuiCommandZone*>(target))
commandzone->toggleDisplay();
else if (GuiSideboard* sideboard = dynamic_cast<GuiSideboard*>(target))
sideboard->toggleDisplay();
//opponenthand
else if (GuiOpponentHand* opponentHand = dynamic_cast<GuiOpponentHand*>(target))
if (opponentHand->showCards)
@@ -1683,6 +1686,17 @@ int GameObserver::isInExile(MTGCardInstance * card)
}
return 0;
}
int GameObserver::isInCommandZone(MTGCardInstance * card)
{
for (int i = 0; i < 2; i++)
{
MTGGameZone * commandzone = players[i]->game->commandzone;
if (players[i]->game->isInZone(card,commandzone))
return 1;
}
return 0;
}
int GameObserver::isInHand(MTGCardInstance * card)
{
+11 -10
View File
@@ -211,7 +211,7 @@ void GameStateDuel::Start()
// match mode is available in classic and demo mode.
// in both modes player 1 is from type PLAYER_TYPE_CPU
if (mParent->players[1] == PLAYER_TYPE_CPU && (mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO))
if (mParent->players[1] == PLAYER_TYPE_CPU && (mParent->gameType == GAME_TYPE_COMMANDER || mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO))
{
//initialize match
// only reset "Played Games" and "Victories" info if we didn't come here from within a match
@@ -385,7 +385,7 @@ void GameStateDuel::ConstructOpponentMenu()
GameStateDuel::selectedAIDeckId, true);
int nbUnlockedDecks = options[Options::CHEATMODEAIDECK].number ? 1000 : options[Options::AIDECKS_UNLOCKED].number;
if ((mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO)&&mParent->players[1] == PLAYER_TYPE_CPU)
if ((mParent->gameType == GAME_TYPE_COMMANDER || mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO) && mParent->players[1] == PLAYER_TYPE_CPU)
{
if (!tournamentSelection)
{
@@ -618,7 +618,7 @@ void GameStateDuel::Update(float dt)
}
else
{
if (mParent->players[1] == PLAYER_TYPE_CPU && (mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO))
if (mParent->players[1] == PLAYER_TYPE_CPU && (mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_COMMANDER || mParent->gameType == GAME_TYPE_DEMO))
{
if (deckmenu && (!popupScreen || popupScreen->isClosed())) deckmenu->Update(dt);
}
@@ -675,7 +675,7 @@ void GameStateDuel::Update(float dt)
}
else
{
if (mParent->players[1] == PLAYER_TYPE_CPU && (mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO))
if (mParent->players[1] == PLAYER_TYPE_CPU && (mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_COMMANDER || mParent->gameType == GAME_TYPE_DEMO))
{
ConstructOpponentMenu();
opponentMenu->Update(dt);
@@ -766,7 +766,7 @@ void GameStateDuel::Update(float dt)
sprintf(temp, "ai_baka_music%i.mp3", OpponentsDeckid);
musictrack.assign(temp);
}
else if (mParent->gameType == GAME_TYPE_CLASSIC)
else if (mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_COMMANDER)
musictrack = "ai_baka_music.mp3";
else if (mParent->gameType == GAME_TYPE_MOMIR)
musictrack = "ai_baka_music_momir.mp3";
@@ -781,7 +781,7 @@ void GameStateDuel::Update(float dt)
GameApp::playMusic(musictrack);
// init Score table
if ( (mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO)&& mParent->players[1] == PLAYER_TYPE_CPU)
if ( (mParent->gameType == GAME_TYPE_COMMANDER || mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO) && mParent->players[1] == PLAYER_TYPE_CPU)
{
tournament->updateScoreTable(game->players[0], game->players[1], mParent->gameType);
tournament->setScoreDisplayed(false);
@@ -799,7 +799,7 @@ void GameStateDuel::Update(float dt)
if (game->didWin())
{
//the following section will be called only in a classic or demo gamemode and if a tournament or match with more than one game is activ
if ( (mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO)&& mParent->players[1] == PLAYER_TYPE_CPU && (tournament->isTournament() || tournament->getGamesToPlay()>1 ))
if ( (mParent->gameType == GAME_TYPE_COMMANDER || mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO) && mParent->players[1] == PLAYER_TYPE_CPU && (tournament->isTournament() || tournament->getGamesToPlay()>1 ))
{
setGamePhase(DUEL_STATE_SHOW_SCORE);
/* Determine the winner of this game.
@@ -950,7 +950,7 @@ void GameStateDuel::Update(float dt)
menu->Add(MENUITEM_LOAD, "Load");
#endif
if (mParent->players[1] == PLAYER_TYPE_CPU && (mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO))
if (mParent->players[1] == PLAYER_TYPE_CPU && (mParent->gameType == GAME_TYPE_COMMANDER || mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO))
{
menu->Add(MENUITEM_SHOW_SCORE, "Show current score");
if (mParent->players[0] == PLAYER_TYPE_CPU)
@@ -1180,6 +1180,7 @@ void GameStateDuel::Render()
&& mParent->gameType != GAME_TYPE_SLAVE
#endif //NETWORK_SUPPORT
&& mParent->gameType != GAME_TYPE_STONEHEWER
&& mParent->gameType != GAME_TYPE_COMMANDER
&& mParent->gameType != GAME_TYPE_HERMIT)
mFont->DrawString(_("LOADING DECKS").c_str(), 0, SCREEN_HEIGHT / 2);
else
@@ -2693,7 +2694,7 @@ void Tournament::renderScoreTable()
// For some reason, there's currently no player avatar prepared in-game:
if (p1IsAI)
{
if (mgameType == GAME_TYPE_CLASSIC || mgameType == GAME_TYPE_DEMO)
if (mgameType == GAME_TYPE_COMMANDER || mgameType == GAME_TYPE_CLASSIC || mgameType == GAME_TYPE_DEMO)
r->RenderQuad(p1Quad.get(), x_score, 70, 0,1,1);
}
else
@@ -2703,7 +2704,7 @@ void Tournament::renderScoreTable()
}
if (p0IsAI)
{
if (mgameType == GAME_TYPE_CLASSIC || mgameType == GAME_TYPE_DEMO)
if (mgameType == GAME_TYPE_COMMANDER || mgameType == GAME_TYPE_CLASSIC || mgameType == GAME_TYPE_DEMO)
r->RenderQuad(p0Quad.get(), x_score+190, 215, 0,1,1);
}
else
+15 -8
View File
@@ -18,6 +18,8 @@ GuiAvatars::GuiAvatars(DuelLayers* duelLayers) :
Add(selfExile = NEW GuiExile(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 30, false, mpDuelLayers->getRenderedPlayer(), this));
//mycommandZone
Add(selfCommandZone = NEW GuiCommandZone(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 + 9, SCREEN_HEIGHT - GuiAvatar::Height - 30, false, mpDuelLayers->getRenderedPlayer(), this));
//mySideboard
Add(selfSideboard = NEW GuiSideboard(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 + 29, SCREEN_HEIGHT - GuiAvatar::Height - 30, false, mpDuelLayers->getRenderedPlayer(), this));
Add(opponent = NEW GuiAvatar(0, 0, false, mpDuelLayers->getRenderedPlayerOpponent(), GuiAvatar::TOP_LEFT, this));
opponent->zoom = 0.9f;
@@ -42,13 +44,14 @@ GuiAvatars::GuiAvatars(DuelLayers* duelLayers) :
observer->getCardSelector()->Add(selfExile);
observer->getCardSelector()->Add(selfCommandZone);
observer->getCardSelector()->Add(selfLibrary);
observer->getCardSelector()->Add(selfSideboard);
observer->getCardSelector()->Add(opponent);
observer->getCardSelector()->Add(opponentGraveyard);
observer->getCardSelector()->Add(opponentExile);
observer->getCardSelector()->Add(opponentCommandZone);
observer->getCardSelector()->Add(opponentLibrary);
observer->getCardSelector()->Add(opponentHand);
selfGraveyard->alpha = selfExile->alpha = selfCommandZone->alpha = opponentCommandZone->alpha = opponentExile->alpha = selfLibrary->alpha = opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0;
selfGraveyard->alpha = selfExile->alpha = selfCommandZone->alpha = selfSideboard->alpha = opponentCommandZone->alpha = opponentExile->alpha = selfLibrary->alpha = opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0;
}
float GuiAvatars::LeftBoundarySelf()
@@ -71,9 +74,9 @@ void GuiAvatars::Activate(PlayGuiObject* c)
active = opponent;
opponent->zoom = 1.2f;
}
else if ((selfGraveyard == c) || (selfExile == c) || (selfCommandZone == c) || (selfLibrary == c) || (self == c))
else if ((selfGraveyard == c) || (selfExile == c) || (selfCommandZone == c) || (selfSideboard == c) || (selfLibrary == c) || (self == c))
{
selfGraveyard->alpha = selfExile->alpha = selfCommandZone->alpha = selfLibrary->alpha = 128.0f;
selfGraveyard->alpha = selfExile->alpha = selfSideboard->alpha = selfCommandZone->alpha = selfLibrary->alpha = 128.0f;
self->zoom = 1.0f;
active = self;
}
@@ -90,9 +93,9 @@ void GuiAvatars::Deactivate(PlayGuiObject* c)
opponent->zoom = 0.9f;
active = NULL;
}
else if ((selfGraveyard == c) || (selfExile == c) || (selfCommandZone == c) || (selfLibrary == c) || (self == c))
else if ((selfGraveyard == c) || (selfExile == c) || (selfCommandZone == c) || (selfSideboard == c) || (selfLibrary == c) || (self == c))
{
selfGraveyard->alpha = selfExile->alpha = selfCommandZone->alpha = selfLibrary->alpha = 0;
selfGraveyard->alpha = selfExile->alpha = selfSideboard->alpha = selfCommandZone->alpha = selfLibrary->alpha = 0;
self->zoom = 0.5f;
active = NULL;
}
@@ -100,7 +103,7 @@ void GuiAvatars::Deactivate(PlayGuiObject* c)
int GuiAvatars::receiveEventPlus(WEvent* e)
{
return selfGraveyard->receiveEventPlus(e) | selfExile->receiveEventPlus(e) | selfCommandZone->receiveEventPlus(e) | opponentExile->receiveEventPlus(e) | opponentCommandZone->receiveEventPlus(e) | opponentGraveyard->receiveEventPlus(e) | opponentHand->receiveEventPlus(e);
return selfGraveyard->receiveEventPlus(e) | selfExile->receiveEventPlus(e) | selfSideboard->receiveEventPlus(e) | selfCommandZone->receiveEventPlus(e) | opponentExile->receiveEventPlus(e) | opponentCommandZone->receiveEventPlus(e) | opponentGraveyard->receiveEventPlus(e) | opponentHand->receiveEventPlus(e);
}
int GuiAvatars::receiveEventMinus(WEvent* e)
@@ -108,6 +111,7 @@ int GuiAvatars::receiveEventMinus(WEvent* e)
selfGraveyard->receiveEventMinus(e);
selfExile->receiveEventMinus(e);
selfCommandZone->receiveEventMinus(e);
selfSideboard->receiveEventMinus(e);
opponentGraveyard->receiveEventMinus(e);
opponentExile->receiveEventMinus(e);
opponentCommandZone->receiveEventMinus(e);
@@ -127,6 +131,8 @@ bool GuiAvatars::CheckUserInput(JButton key)
return true;
if (selfCommandZone->CheckUserInput(key))
return true;
if (selfSideboard->CheckUserInput(key))
return true;
if (opponentGraveyard->CheckUserInput(key))
return true;
if (opponentExile->CheckUserInput(key))
@@ -149,6 +155,7 @@ void GuiAvatars::Update(float dt)
selfGraveyard->Update(dt);
selfExile->Update(dt);
selfCommandZone->Update(dt);
selfSideboard->Update(dt);
opponentHand->Update(dt);
opponentGraveyard->Update(dt);
opponentExile->Update(dt);
@@ -169,8 +176,8 @@ void GuiAvatars::Render()
}
else if (self == active)
{
r->FillRect(self->actX - w * self->actZ - 4.5f, self->actY - h-28 * self->actZ, 24 * self->actZ + 19, h+28 * self->actZ, ARGB(200,0,0,0));
//r->FillRect(self->actX - w * self->actZ - 4.5f, self->actY - h * self->actZ, w * self->actZ, h * self->actZ, ARGB(200,0,0,0));
r->FillRect(self->actX - w * self->actZ - 4.5f, self->actY - h-28 * self->actZ, 24 * self->actZ + 35, h+28 * self->actZ, ARGB(200,0,0,0));
r->FillRect(self->actX - w * self->actZ - 4.5f, self->actY - h * self->actZ, w * self->actZ, h * self->actZ, ARGB(200,0,0,0));
}
GuiLayer::Render();
+56 -1
View File
@@ -207,7 +207,7 @@ void GuiGameZone::Render()
bool showopponenttop = (zone && zone->owner->opponent()->game->battlefield->nb_cards && zone->owner->opponent()->game->battlefield->hasAbility(Constants::SHOWOPPONENTTOPLIBRARY))?true:false;
quad->SetColor(ARGB((int)(actA),255,255,255));
if(type == GUI_EXILE || type == GUI_COMMANDZONE)
if(type == GUI_EXILE || type == GUI_COMMANDZONE || type == GUI_SIDEBOARD)
{
quad->SetColor(ARGB((int)(actA),255,240,255));
}
@@ -218,6 +218,7 @@ void GuiGameZone::Render()
JQuadPtr iconlibrary = WResourceManager::Instance()->RetrieveTempQuad("iconlibrary.png");
JQuadPtr iconexile = WResourceManager::Instance()->RetrieveTempQuad("iconexile.png");
JQuadPtr iconcommandzone = WResourceManager::Instance()->RetrieveTempQuad("iconcommandzone.png");
JQuadPtr iconsideboard = WResourceManager::Instance()->RetrieveTempQuad("iconsideboard.png");
if(iconlibrary && type == GUI_LIBRARY)
{
@@ -259,6 +260,14 @@ void GuiGameZone::Render()
iconcommandzone->SetColor(ARGB((int)(actA),255,255,255));
quad = iconcommandzone;
}
if(iconsideboard && type == GUI_SIDEBOARD)
{
scale2 = defaultHeight / iconsideboard->mHeight;
modx = -0.f;
mody = -2.f;
iconsideboard->SetColor(ARGB((int)(actA),255,255,255));
quad = iconsideboard;
}
//
if(type == GUI_LIBRARY && zone->nb_cards && !showCards)
@@ -575,6 +584,52 @@ ostream& GuiCommandZone::toString(ostream& out) const
return out << "GuiCommandZone :::";
}
GuiSideboard::GuiSideboard(float x, float y, bool hasFocus, Player * player, GuiAvatars* parent) :
GuiGameZone(x, y, hasFocus, player->game->sideboard, parent), player(player)
{
type = GUI_SIDEBOARD;
}
int GuiSideboard::receiveEventPlus(WEvent* e)
{
if (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e))
if (event->to == zone)
{
CardView* t;
if (event->card->view)
t = NEW CardView(CardView::nullZone, event->card, *(event->card->view));
else
t = NEW CardView(CardView::nullZone, event->card, x, y);
t->x = x + Width / 2;
t->y = y + Height / 2;
t->zoom = 0.6f;
t->alpha = 0;
cards.push_back(t);
return 1;
}
return 0;
}
int GuiSideboard::receiveEventMinus(WEvent* e)
{
if (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e))
if (event->from == zone)
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
if (event->card->previous == (*it)->card)
{
CardView* cv = *it;
cards.erase(it);
zone->owner->getObserver()->mTrash->trash(cv);
return 1;
}
return 0;
}
ostream& GuiSideboard::toString(ostream& out) const
{
return out << "GuiSideboard :::";
}
//opponenthand begins
GuiOpponentHand::GuiOpponentHand(float x, float y, bool hasFocus, Player * player, GuiAvatars* parent) :
GuiGameZone(x, y, hasFocus, player->game->hand, parent), player(player)
+12 -3
View File
@@ -4918,6 +4918,7 @@ int AbilityFactory::getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCar
{
card->graveEffects = false;
card->exileEffects = false;
card->commandZoneEffects = false;
card->handEffects = false;
for (int i = 0; i < 2; ++i)
{
@@ -4945,7 +4946,13 @@ int AbilityFactory::getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCar
card->exileEffects = true;
break;
}
if (dest == zones->library)
if (dest == zones->commandzone)
{
magicText = card->magicTexts["commandzone"];
card->commandZoneEffects = true;
break;
}
if (dest == zones->library)
{
magicText = card->magicTexts["library"];
break;
@@ -5847,6 +5854,8 @@ int MTGAbility::testDestroy()
return 0;
if(source->exileEffects && game->isInExile(source))
return 0;
if(source->commandZoneEffects && game->isInCommandZone(source))
return 0;
if(this->forcedAlive == 1)
return 0;
if (!game->isInPlay(source))
@@ -6506,7 +6515,7 @@ void ListMaintainerAbility::updateTargets()
for (int i = 0; i < 2; 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, p->game->sideboard, p->game->commandzone };
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile, p->game->commandzone, p->game->sideboard, p->game->reveal };
for (int k = 0; k < 9; k++)
{
MTGGameZone * zone = zones[k];
@@ -6578,7 +6587,7 @@ void ListMaintainerAbility::checkTargets()
for (int i = 0; i < 2; 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, p->game->sideboard, p->game->commandzone };
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile, p->game->commandzone, p->game->sideboard, p->game->reveal };
for (int k = 0; k < 9; k++)
{
MTGGameZone * zone = zones[k];
+1
View File
@@ -320,6 +320,7 @@ void MTGCardInstance::initMTGCI()
blocked = false;
graveEffects = false;
exileEffects = false;
commandZoneEffects = false;
currentZone = NULL;
cardsAbilities = vector<MTGAbility *>();
//cardsAbilitiesFilter = vector<MTGAbility *>();
+35 -31
View File
@@ -60,9 +60,9 @@ void MTGPlayerCards::initDeck(MTGDeck * deck)
if(card)
{
MTGCardInstance * newCard = NEW MTGCardInstance(card, this);
//commander zone
//the card is marked as commander ad added to library.
newCard->basicAbilities[Constants::ISCOMMANDER] = 1;
commandzone->addCard(newCard);
library->addCard(newCard);
}
}
}
@@ -75,43 +75,47 @@ void MTGPlayerCards::initDeck(MTGDeck * deck)
for (int j = 0; j < it->second; j++)
{
MTGCardInstance * newCard = NEW MTGCardInstance(card, this);
if(!commandzone->cards.size()){ //If no commander in Deck there are no limitations for cards.
if(!deck->CommandZone.size()){ //If no commander format there are no limitations for cards.
library->addCard(newCard);
} else {
if(newCard->hasType("Land") && newCard->hasType("Basic")){ //There are no limitations for basic lands cards.
library->addCard(newCard);
} else{
bool colorFound = false; // All the cards have to share at least one color with commander identity color (any symbol in manacost or magic text).
bool colorless = false; // Colorless card can be always added to deck.
for(unsigned int i = 0; i < commandzone->cards.size() && !colorFound; i++){
if((newCard->hasColor(Constants::MTG_COLOR_WHITE) && commandzone->cards[i]->hasColor(Constants::MTG_COLOR_WHITE)) ||
(newCard->hasColor(Constants::MTG_COLOR_BLACK) && commandzone->cards[i]->hasColor(Constants::MTG_COLOR_BLACK)) ||
(newCard->hasColor(Constants::MTG_COLOR_RED) && commandzone->cards[i]->hasColor(Constants::MTG_COLOR_RED)) ||
(newCard->hasColor(Constants::MTG_COLOR_BLUE) && commandzone->cards[i]->hasColor(Constants::MTG_COLOR_BLUE)) ||
(newCard->hasColor(Constants::MTG_COLOR_GREEN) && commandzone->cards[i]->hasColor(Constants::MTG_COLOR_GREEN)) ||
(newCard->hasColor(Constants::MTG_COLOR_WHITE) && commandzone->cards[i]->magicText.find("{w}") != std::string::npos) ||
(newCard->hasColor(Constants::MTG_COLOR_BLACK) && commandzone->cards[i]->magicText.find("{b}") != std::string::npos)||
(newCard->hasColor(Constants::MTG_COLOR_RED) && commandzone->cards[i]->magicText.find("{r}") != std::string::npos) ||
(newCard->hasColor(Constants::MTG_COLOR_BLUE) && commandzone->cards[i]->magicText.find("{u}") != std::string::npos) ||
(newCard->hasColor(Constants::MTG_COLOR_GREEN) && commandzone->cards[i]->magicText.find("{g}") != std::string::npos) ||
(newCard->magicText.find("{w}") != std::string::npos && commandzone->cards[i]->hasColor(Constants::MTG_COLOR_WHITE)) ||
(newCard->magicText.find("{b}") != std::string::npos && commandzone->cards[i]->hasColor(Constants::MTG_COLOR_BLACK)) ||
(newCard->magicText.find("{r}") != std::string::npos && commandzone->cards[i]->hasColor(Constants::MTG_COLOR_RED)) ||
(newCard->magicText.find("{u}") != std::string::npos && commandzone->cards[i]->hasColor(Constants::MTG_COLOR_BLUE)) ||
(newCard->magicText.find("{g}") != std::string::npos && commandzone->cards[i]->hasColor(Constants::MTG_COLOR_GREEN)) ||
(newCard->magicText.find("{w}") != std::string::npos && commandzone->cards[i]->magicText.find("{w}") != std::string::npos) ||
(newCard->magicText.find("{b}") != std::string::npos && commandzone->cards[i]->magicText.find("{b}") != std::string::npos)||
(newCard->magicText.find("{r}") != std::string::npos && commandzone->cards[i]->magicText.find("{r}") != std::string::npos) ||
(newCard->magicText.find("{u}") != std::string::npos && commandzone->cards[i]->magicText.find("{u}") != std::string::npos) ||
(newCard->magicText.find("{g}") != std::string::npos && commandzone->cards[i]->magicText.find("{g}") != std::string::npos)){
colorFound = true;
bool colorless = false; // Colorless card can be always added to deck.
for(unsigned int i = 0; i < deck->CommandZone.size() && !colorFound; i++){
MTGCard * cmdcard = MTGCollection()->getCardById(atoi(deck->CommandZone[i].c_str()));
if(cmdcard){
MTGCardInstance * commander = NEW MTGCardInstance(cmdcard, this);
if((newCard->hasColor(Constants::MTG_COLOR_WHITE) && commander->hasColor(Constants::MTG_COLOR_WHITE)) ||
(newCard->hasColor(Constants::MTG_COLOR_BLACK) && commander->hasColor(Constants::MTG_COLOR_BLACK)) ||
(newCard->hasColor(Constants::MTG_COLOR_RED) && commander->hasColor(Constants::MTG_COLOR_RED)) ||
(newCard->hasColor(Constants::MTG_COLOR_BLUE) && commander->hasColor(Constants::MTG_COLOR_BLUE)) ||
(newCard->hasColor(Constants::MTG_COLOR_GREEN) && commander->hasColor(Constants::MTG_COLOR_GREEN)) ||
(newCard->hasColor(Constants::MTG_COLOR_WHITE) && commander->magicText.find("{w}") != std::string::npos) ||
(newCard->hasColor(Constants::MTG_COLOR_BLACK) && commander->magicText.find("{b}") != std::string::npos)||
(newCard->hasColor(Constants::MTG_COLOR_RED) && commander->magicText.find("{r}") != std::string::npos) ||
(newCard->hasColor(Constants::MTG_COLOR_BLUE) && commander->magicText.find("{u}") != std::string::npos) ||
(newCard->hasColor(Constants::MTG_COLOR_GREEN) && commander->magicText.find("{g}") != std::string::npos) ||
(newCard->magicText.find("{w}") != std::string::npos && commander->hasColor(Constants::MTG_COLOR_WHITE)) ||
(newCard->magicText.find("{b}") != std::string::npos && commander->hasColor(Constants::MTG_COLOR_BLACK)) ||
(newCard->magicText.find("{r}") != std::string::npos && commander->hasColor(Constants::MTG_COLOR_RED)) ||
(newCard->magicText.find("{u}") != std::string::npos && commander->hasColor(Constants::MTG_COLOR_BLUE)) ||
(newCard->magicText.find("{g}") != std::string::npos && commander->hasColor(Constants::MTG_COLOR_GREEN)) ||
(newCard->magicText.find("{w}") != std::string::npos && commander->magicText.find("{w}") != std::string::npos) ||
(newCard->magicText.find("{b}") != std::string::npos && commander->magicText.find("{b}") != std::string::npos)||
(newCard->magicText.find("{r}") != std::string::npos && commander->magicText.find("{r}") != std::string::npos) ||
(newCard->magicText.find("{u}") != std::string::npos && commander->magicText.find("{u}") != std::string::npos) ||
(newCard->magicText.find("{g}") != std::string::npos && commander->magicText.find("{g}") != std::string::npos)){
colorFound = true;
}
}
}
if(!colorFound)
if(!colorFound)
colorless = (newCard->magicText.find("{g}") == std::string::npos && newCard->magicText.find("{w}") == std::string::npos && newCard->magicText.find("{b}") == std::string::npos &&
newCard->magicText.find("{r}") == std::string::npos && newCard->magicText.find("{u}") == std::string::npos && !newCard->hasColor(Constants::MTG_COLOR_BLUE) &&
!newCard->hasColor(Constants::MTG_COLOR_RED) && !newCard->hasColor(Constants::MTG_COLOR_WHITE) && !newCard->hasColor(Constants::MTG_COLOR_GREEN) &&
!newCard->hasColor(Constants::MTG_COLOR_BLACK));
newCard->magicText.find("{r}") == std::string::npos && newCard->magicText.find("{u}") == std::string::npos && !newCard->hasColor(Constants::MTG_COLOR_BLUE) &&
!newCard->hasColor(Constants::MTG_COLOR_RED) && !newCard->hasColor(Constants::MTG_COLOR_WHITE) && !newCard->hasColor(Constants::MTG_COLOR_GREEN) &&
!newCard->hasColor(Constants::MTG_COLOR_BLACK));
if(colorFound || colorless){
bool onlyInstance = true; // In commander format only single cards are allowed if they are not basic lands.
for(unsigned int k = 0; k < library->cards.size() && onlyInstance; k++){
@@ -460,7 +464,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
}
//close the currently open MAIN display.
if (from == g->players[i]->game->library || from == g->players[i]->game->graveyard || from == g->players[i]->game->exile || from == g->players[i]->game->commandzone)
if (from == g->players[i]->game->library || from == g->players[i]->game->graveyard || from == g->players[i]->game->exile || from == g->players[i]->game->commandzone || from == g->players[i]->game->sideboard)
{
if (g->guiOpenDisplay)
{
+1 -1
View File
@@ -439,7 +439,7 @@ bool Player::parseLine(const string& s)
void HumanPlayer::End()
{
if(!premade && opponent() && (observer->gameType() == GAME_TYPE_CLASSIC))
if(!premade && opponent() && (observer->gameType() == GAME_TYPE_CLASSIC || observer->gameType() == GAME_TYPE_COMMANDER))
DeckStats::GetInstance()->saveStats(this, opponent(), observer);
}
+13 -7
View File
@@ -497,6 +497,8 @@ Player * Rules::initPlayer(GameObserver *g, int playerId)
return loadPlayerMomir(g, isAI);
case GAME_TYPE_CLASSIC:
return NULL; //Error for the time being
case GAME_TYPE_COMMANDER:
return NULL; //Error for the time being
case GAME_TYPE_RANDOM1:
return loadPlayerRandom(g, isAI, GAME_TYPE_RANDOM1);
case GAME_TYPE_RANDOM2:
@@ -528,9 +530,12 @@ MTGDeck * Rules::buildDeck(int playerId)
initState.playerData[playerId].player->game->library,
initState.playerData[playerId].player->game->hand,
initState.playerData[playerId].player->game->inPlay,
initState.playerData[playerId].player->game->exile };
initState.playerData[playerId].player->game->exile,
initState.playerData[playerId].player->game->commandzone,
initState.playerData[playerId].player->game->sideboard,
initState.playerData[playerId].player->game->reveal };
for (int j = 0; j < 5; j++)
for (int j = 0; j < 7; j++)
{
for (size_t k = 0; k < loadedPlayerZones[j]->cards.size(); k++)
{
@@ -605,16 +610,16 @@ void Rules::initGame(GameObserver *g, bool currentPlayerSet)
{
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, p->game->sideboard, p->game->commandzone };
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->exile , p->game->commandzone, p->game->sideboard, p->game->reveal };
MTGGameZone * loadedPlayerZones[] = { initState.playerData[i].player->game->graveyard,
initState.playerData[i].player->game->library,
initState.playerData[i].player->game->hand,
initState.playerData[i].player->game->inPlay,
initState.playerData[i].player->game->exile,
initState.playerData[i].player->game->reveal,
initState.playerData[i].player->game->commandzone,
initState.playerData[i].player->game->sideboard,
initState.playerData[i].player->game->commandzone };
for (int j = 0; j < 5; j++)
initState.playerData[i].player->game->reveal };
for (int j = 0; j < 7; j++)
{
MTGGameZone * zone = playerZones[j];
for (size_t k = 0; k < loadedPlayerZones[j]->cards.size(); k++)
@@ -699,7 +704,7 @@ Rules::Rules(string _bg)
bool Rules::canChooseDeck()
{
return (gamemode == GAME_TYPE_CLASSIC || gamemode == GAME_TYPE_STONEHEWER || gamemode == GAME_TYPE_HERMIT);
return (gamemode == GAME_TYPE_CLASSIC || gamemode == GAME_TYPE_STONEHEWER || gamemode == GAME_TYPE_HERMIT || gamemode == GAME_TYPE_COMMANDER);
}
int Rules::load(string _filename)
@@ -826,5 +831,6 @@ GameType Rules::strToGameMode(string s)
if (s.compare("story") == 0) return GAME_TYPE_STORY;
if (s.compare("stonehewer") == 0) return GAME_TYPE_STONEHEWER;
if (s.compare("hermit") == 0) return GAME_TYPE_HERMIT;
if (s.compare("commander") == 0) return GAME_TYPE_COMMANDER;
return GAME_TYPE_CLASSIC;
}
+2 -2
View File
@@ -1170,7 +1170,7 @@ bool TargetChooser::validTargetsExist(int maxTargets)
int maxAmount = 0;
Player *p = observer->players[i];
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, p->game->sideboard, p->game->commandzone };
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->stack, p->game->commandzone, p->game->sideboard, p->game->reveal };
for (int k = 0; k < 9; k++)
{
MTGGameZone * z = zones[k];
@@ -1204,7 +1204,7 @@ int TargetChooser::countValidTargets(bool withoutProtections)
Player *p = observer->players[i];
if(canTarget(p))
result++;
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, p->game->commandzone };
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->stack, p->game->commandzone, p->game->sideboard, p->game->reveal };
for (int k = 0; k < 9; k++)
{
MTGGameZone * z = zones[k];