Improved zones management for commandzone and sideboard (e.g. now the game consider those zone as all the others for every ability such as "lord" and "aslongas").

This commit is contained in:
Vittorio Alfieri
2021-11-22 16:17:10 +01:00
parent 217a5aa93e
commit e47f3f5471
8 changed files with 40 additions and 31 deletions

View File

@@ -2878,8 +2878,8 @@ public:
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->exile };
for (int k = 0; k < 5; k++)
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->commandzone, p->game->sideboard };
for (int k = 0; k < 7; k++)
{
MTGGameZone * zone = zones[k];
Value = zone->countByCanTarget(tc);

View File

@@ -543,13 +543,15 @@ bool GameObserver::operator==(const GameObserver& aGame)
{
error++;
}
MTGGameZone * aZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->exile };
MTGGameZone * aZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->exile, p->game->commandzone, p->game->sideboard };
MTGGameZone * thisZones[] = { players[i]->game->graveyard,
players[i]->game->library,
players[i]->game->hand,
players[i]->game->inPlay,
players[i]->game->exile };
for (int j = 0; j < 5; j++)
players[i]->game->exile,
players[i]->game->commandzone,
players[i]->game->sideboard };
for (int j = 0; j < 7; j++)
{
MTGGameZone * zone = aZones[j];
if (zone->nb_cards != thisZones[j]->nb_cards)
@@ -649,8 +651,8 @@ void GameObserver::gameStateBasedEffects()
if (players[d]->snowManaW < 0)
players[d]->snowManaW = 0;
MTGGameZone * dzones[] = { players[d]->game->inPlay, players[d]->game->graveyard, players[d]->game->hand, players[d]->game->library, players[d]->game->exile, players[d]->game->stack };
for (int k = 0; k < 6; k++)
MTGGameZone * dzones[] = { players[d]->game->inPlay, players[d]->game->graveyard, players[d]->game->hand, players[d]->game->library, players[d]->game->exile, players[d]->game->stack, players[d]->game->commandzone, players[d]->game->sideboard, players[d]->game->reveal };
for (int k = 0; k < 9; k++)
{
MTGGameZone * zone = dzones[k];
if (mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0)

View File

@@ -229,8 +229,8 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
for (int w = 0; w < 2; ++w)
{
Player *p = observer->players[w];
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile };
for (int k = 0; k < 6; k++)
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 * z = zones[k];
if (stc->targetsZone(z))
@@ -946,8 +946,8 @@ int AbilityFactory::countCards(TargetChooser * tc, Player * player, int option)
{
if (player && player != observer->players[i])
continue;
MTGGameZone * zones[] = { observer->players[i]->game->inPlay, observer->players[i]->game->graveyard, observer->players[i]->game->hand, observer->players[i]->game->exile };
for (int k = 0; k < 4; k++)
MTGGameZone * zones[] = { observer->players[i]->game->inPlay, observer->players[i]->game->graveyard, observer->players[i]->game->hand, observer->players[i]->game->exile, observer->players[i]->game->commandzone };
for (int k = 0; k < 5; k++)
{
for (int j = zones[k]->nb_cards - 1; j >= 0; j--)
{

View File

@@ -1249,8 +1249,8 @@ ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * Cos
for (int w = 0; w < 2; ++w)
{
Player *p = getObserver()->players[w];
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile };
for (int k = 0; k < 6; k++)
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 * z = zones[k];
if (tcn->targetsZone(z))

View File

@@ -79,8 +79,8 @@ MTGCardInstance * Rules::getCardByMTGId(GameObserver* g, int mtgid)
for (int i = 0; i < 2; i++)
{
Player * p = g->players[i];
MTGGameZone * zones[] = { p->game->library, p->game->hand, p->game->inPlay, p->game->graveyard, p->game->exile };
for (int j = 0; j < 5; j++)
MTGGameZone * zones[] = { p->game->library, p->game->hand, p->game->inPlay, p->game->graveyard, p->game->exile, p->game->commandzone, p->game->sideboard };
for (int j = 0; j < 7; j++)
{
MTGGameZone * zone = zones[j];
for (int k = 0; k < zone->nb_cards; k++)
@@ -533,8 +533,7 @@ MTGDeck * Rules::buildDeck(int playerId)
initState.playerData[playerId].player->game->inPlay,
initState.playerData[playerId].player->game->exile,
initState.playerData[playerId].player->game->commandzone,
initState.playerData[playerId].player->game->sideboard,
initState.playerData[playerId].player->game->reveal };
initState.playerData[playerId].player->game->sideboard };
for (int j = 0; j < 7; j++)
{
@@ -615,15 +614,14 @@ 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->commandzone, p->game->sideboard, p->game->reveal };
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->exile , p->game->commandzone, p->game->sideboard };
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->commandzone,
initState.playerData[i].player->game->sideboard,
initState.playerData[i].player->game->reveal };
initState.playerData[i].player->game->sideboard };
for (int j = 0; j < 7; j++)
{
MTGGameZone * zone = playerZones[j];

View File

@@ -49,8 +49,8 @@ MTGCardInstance * TestSuiteAI::getCard(string action)
for (int i = 0; i < 2; i++)
{
Player * p = observer->players[i];
MTGGameZone * zones[] = { p->game->library, p->game->hand, p->game->inPlay, p->game->graveyard, p->game->removedFromGame };
for (int j = 0; j < 5; j++)
MTGGameZone * zones[] = { p->game->library, p->game->hand, p->game->inPlay, p->game->graveyard, p->game->commandzone, p->game->sideboard, p->game->removedFromGame };
for (int j = 0; j < 7; j++)
{
MTGGameZone * zone = zones[j];
for (int k = 0; k < zone->nb_cards; k++)
@@ -397,13 +397,15 @@ void TestSuiteGame::assertGame()
error++;
}
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->removedFromGame };
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->commandzone, p->game->sideboard, p->game->removedFromGame };
MTGGameZone * endstateZones[] = { endState.players[i]->game->graveyard,
endState.players[i]->game->library,
endState.players[i]->game->hand,
endState.players[i]->game->inPlay,
endState.players[i]->game->commandzone,
endState.players[i]->game->sideboard,
endState.players[i]->game->removedFromGame };
for (int j = 0; j < 5; j++)
for (int j = 0; j < 7; j++)
{
MTGGameZone * zone = playerZones[j];
if (zone->nb_cards != endstateZones[j]->nb_cards)
@@ -857,13 +859,15 @@ void TestSuiteGame::initGame()
stringstream stream;
initState.players[i]->getRandomGenerator()->saveLoadedRandValues(stream);
p->getRandomGenerator()->loadRandValues(stream.str());
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->removedFromGame };
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay, p->game->commandzone, p->game->sideboard, p->game->removedFromGame };
MTGGameZone * loadedPlayerZones[] = { initState.players[i]->game->graveyard,
initState.players[i]->game->library,
initState.players[i]->game->hand,
initState.players[i]->game->inPlay,
initState.players[i]->game->commandzone,
initState.players[i]->game->sideboard,
initState.players[i]->game->removedFromGame };
for (int j = 0; j < 5; j++)
for (int j = 0; j < 7; j++)
{
MTGGameZone * zone = playerZones[j];
for (size_t k = 0; k < loadedPlayerZones[j]->cards.size(); k++)
@@ -918,9 +922,11 @@ MTGPlayerCards * TestSuiteGame::buildDeck(Player* player, int playerId)
initState.players[playerId]->game->library,
initState.players[playerId]->game->hand,
initState.players[playerId]->game->removedFromGame,
initState.players[playerId]->game->commandzone,
initState.players[playerId]->game->sideboard,
initState.players[playerId]->game->inPlay };
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++)
{

View File

@@ -285,7 +285,7 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
for (int i = 0; i < 2; i++)
{
Player * p = card->getObserver()->players[i];
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->commandzone, p->game->sideboard };//wish cards use sideboard
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->commandzone, p->game->sideboard };
for (int k = 0; k < 7; k++)
{
MTGGameZone * zone = zones[k];
@@ -384,8 +384,8 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
for (int i = 0; i < 2; i++)
{
Player * p = card->getObserver()->players[i];
MTGGameZone * zones[] = { p->game->battlefield, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->reveal };
for (int k = 0; k < 6; k++)
MTGGameZone * zones[] = { p->game->battlefield, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->commandzone, p->game->sideboard, p->game->reveal, p->game->stack };
for (int k = 0; k < 9; k++)
{
MTGGameZone * zone = zones[k];
if(tc->targetsZone(zone,target))