Added a new Random Commander game mode and fix to special rarity filter

You get a random legendary creature and get a 99 cards deck at random in the commander colors.

Some limitations by the engine makes you only get cards based on the mana cost of the card, not the full color identity.

Also sometimes you get fewer than 99 cards. Possible that you are getting repeated cards and end up with less than the desired 99?

Special rarity no longer shows basic land types.
This commit is contained in:
Eduardo MG
2022-10-26 15:49:57 -05:00
parent 5c691afe33
commit 51ede6a37f
4 changed files with 70 additions and 8 deletions

View File

@@ -17,6 +17,7 @@ typedef enum
GAME_TYPE_RANDOM2,
GAME_TYPE_RANDOM3,
GAME_TYPE_RANDOM5,
GAME_TYPE_RANDOMCOMMANDER,
GAME_TYPE_HORDE,
GAME_TYPE_SET_LIMITED,
GAME_TYPE_STORY,

View File

@@ -44,6 +44,7 @@ protected:
Player * loadPlayerRandom(GameObserver* observer, int isAI, int mode);
Player * loadPlayerRandomThree(GameObserver* observer, int isAI);
Player * loadPlayerRandomFive(GameObserver* observer, int isAI);
Player * loadPlayerRandomCommander(GameObserver* observer, int isAI);
Player * loadPlayerHorde(GameObserver* observer, int isAI);
Player * loadRandomSetLimited(GameObserver* observer, int isAI);
Player * initPlayer(GameObserver *observer, int playerId);

View File

@@ -168,7 +168,7 @@ void Rules::addExtraRules(GameObserver* g)
difficultyRating = 0;
else if(g->mRules->gamemode == GAME_TYPE_RANDOM1 || g->mRules->gamemode == GAME_TYPE_RANDOM2)
difficultyRating = 0;
else if(g->mRules->gamemode == GAME_TYPE_RANDOM3 || g->mRules->gamemode == GAME_TYPE_RANDOM5)
else if(g->mRules->gamemode == GAME_TYPE_RANDOM3 || g->mRules->gamemode == GAME_TYPE_RANDOM5 || g->mRules->gamemode == GAME_TYPE_RANDOMCOMMANDER)
difficultyRating = 0;
else if(g->mRules->gamemode == GAME_TYPE_HORDE || g->mRules->gamemode == GAME_TYPE_SET_LIMITED)
difficultyRating = 0;
@@ -200,7 +200,7 @@ void Rules::addExtraRules(GameObserver* g)
a->resolve();
else if(g->mRules->gamemode == GAME_TYPE_RANDOM1 || g->mRules->gamemode == GAME_TYPE_RANDOM2)
a->resolve();
else if(g->mRules->gamemode == GAME_TYPE_RANDOM3 || g->mRules->gamemode == GAME_TYPE_RANDOM5)
else if(g->mRules->gamemode == GAME_TYPE_RANDOM3 || g->mRules->gamemode == GAME_TYPE_RANDOM5 || g->mRules->gamemode == GAME_TYPE_RANDOMCOMMANDER)
a->resolve();
else if (g->mRules->gamemode == GAME_TYPE_STORY)
a->resolve();
@@ -365,7 +365,7 @@ Player * Rules::loadPlayerRandomThree(GameObserver* observer, int isAI)
int colors[] = { color1, color2, color3, color0 };
int nbcolors = 4;
string lands[] = { "", "forest", "island", "mountain", "swamp", "plains", "" };
string lands[] = { "", "forest", "island", "mountain", "swamp", "plains" };
MTGDeck * tempDeck = NEW MTGDeck(MTGCollection());
tempDeck->addRandomCards(5, 0, 0, -1, lands[color1].c_str());
@@ -402,8 +402,65 @@ Player * Rules::loadPlayerRandomFive(GameObserver* observer, int isAI)
MTGDeck * tempDeck = NEW MTGDeck(MTGCollection());
tempDeck->addRandomCards(24, 0, 0, -1, "land");
tempDeck->addRandomCards(10, 0, 0, -1, "legendary");
tempDeck->addRandomCards(26, 0, 0, -1, "");
tempDeck->addRandomCards(36, 0, 0, -1, "");
string deckFile = "random";
string deckFileSmall = "random";
Player *player = NULL;
if (!isAI) // Human Player
player = NEW HumanPlayer(observer, deckFile, deckFileSmall, false, tempDeck);
else
player = NEW AIPlayerBaka(observer, deckFile, deckFileSmall, "", tempDeck);
return player;
}
Player * Rules::loadPlayerRandomCommander(GameObserver* observer, int isAI)
{
MTGDeck * cmdTempDeck = NEW MTGDeck(MTGCollection());
MTGDeck * tempDeck = NEW MTGDeck(MTGCollection());
tempDeck->meta_commander = true;
string lands[] = { "", "forest", "island", "mountain", "swamp", "plains", "basic", "basic" };
cmdTempDeck->addRandomCards(1, 0, 0, -1, "legendary");
DeckDataWrapper * myCommandZone = NEW DeckDataWrapper(cmdTempDeck);
MTGCard * commander = myCommandZone->getCard(0, true);
while(!commander->data->isCreature())
{
cmdTempDeck->addRandomCards(1, 0, 0, -1, "legendary");
myCommandZone = NEW DeckDataWrapper(cmdTempDeck);
commander = myCommandZone->getCard(0, true);
}
stringstream cid;
cid << commander->getMTGId();
vector<string> newCMD;
newCMD.push_back(cid.str());
tempDeck->replaceCMD(newCMD);
std::vector< int > colors;
for (int i = 0; i < Constants::NB_Colors; i++)
{
if (commander->data->getManaCost()->hasColor(i))
colors.push_back(i);
}
if(colors.data()[0] != 0) { colors.insert(colors.begin(),0); }
if(colors.size() > 1)
{
for (unsigned int i = 1; i < colors.size(); i++)
{
tempDeck->addRandomCards(40/(colors.size()-1), 0, 0, 'L', lands[colors.data()[i]].c_str());
}
}
else { tempDeck->addRandomCards(40, 0, 0, -1, "basic"); }
tempDeck->addRandomCards(59, 0, 0, -1, "", colors.data(), colors.size());
string deckFile = "random";
string deckFileSmall = "random";
@@ -429,9 +486,9 @@ Player * Rules::loadPlayerHorde(GameObserver* observer, int isAI)
"Sliver", "Spellshaper", "Spirit", "Wizard" };
const char* const whiteTribes[] = { "Angel", "Archer", "Bird", "Cat", "Cleric", "Griffin", "Kithkin", "Knight", "Kor", "Monk", "Rebel", "Samurai", "Scout", "Soldier", "Spirit" };
const char* const blueTribes[] = { "Artificer", "Bird", "Drake", "Faerie", "Illusion", "Merfolk", "Mutant", "Nightmare", "Pirate", "Shapeshifter", "Sphinx", "Spirit", "Vedalken", "Wizard" };
const char* const blackTribes[] = { "Assassin", "Cleric", "Demon", "Faerie", "Horror", "Insect", "Knight", "Nightmare", "Orc", "Pirate", "Rat", "Rogue", "Shade", "Skeleton", "Spirit", "Vampire", "Wizard", "Zombie" };
const char* const blackTribes[] = { "Assassin", "Cleric", "Demon", "Faerie", "Horror", "Insect", "Knight", "Nightmare", "Orc", "Phyrexian", "Pirate", "Rat", "Rogue", "Shade", "Skeleton", "Spirit", "Vampire", "Wizard", "Zombie" };
const char* const redTribes[] = { "Artificer", "Beast", "Berserker", "Devil", "Dinosaur", "Dragon", "Dwarf", "Goblin", "Kavu", "Lizard", "Minotaur", "Ogre", "Orc", "Shaman", "Viashino", "Warrior", "Werewolf" };
const char* const greenTribes[] = { "Archer", "Beast", "Cat", "Centaur", "Dinosaur", "Druid", "Dryad", "Elf", "Fungus", "Insect", "Kavu", "Lizard", "Mutant", "Plant", "Scout", "Shaman", "Snake", "Spider", "Treefolk", "Warrior", "Werewolf", "Wurm" };
const char* const greenTribes[] = { "Archer", "Beast", "Cat", "Centaur", "Dinosaur", "Druid", "Dryad", "Elf", "Fungus", "Insect", "Kavu", "Lizard", "Mutant", "Plant", "Ranger", "Scout", "Shaman", "Snake", "Spider", "Treefolk", "Warrior", "Werewolf", "Wurm" };
int multicolorTribesSize = sizeof(multicolorTribes)/sizeof(multicolorTribes[0]);
int whiteTribesSize = sizeof(whiteTribes)/sizeof(whiteTribes[0]);
@@ -508,6 +565,8 @@ Player * Rules::initPlayer(GameObserver *g, int playerId)
return loadPlayerRandomThree(g, isAI);
case GAME_TYPE_RANDOM5:
return loadPlayerRandomFive(g, isAI);
case GAME_TYPE_RANDOMCOMMANDER:
return loadPlayerRandomCommander(g, isAI);
case GAME_TYPE_HORDE:
return loadPlayerHorde(g, isAI);
case GAME_TYPE_SET_LIMITED:
@@ -829,6 +888,7 @@ GameType Rules::strToGameMode(string s)
if (s.compare("random2") == 0) return GAME_TYPE_RANDOM2;
if (s.compare("random3") == 0) return GAME_TYPE_RANDOM3;
if (s.compare("random5") == 0) return GAME_TYPE_RANDOM5;
if (s.compare("random_commander") == 0) return GAME_TYPE_RANDOMCOMMANDER;
if (s.compare("horde") == 0) return GAME_TYPE_HORDE;
if (s.compare("set_limited") == 0) return GAME_TYPE_SET_LIMITED;
if (s.compare("story") == 0) return GAME_TYPE_STORY;

View File

@@ -2145,7 +2145,7 @@ void WGuiFilterItem::updateValue()
mParent->addArg("Rare", "r:r;");
mParent->addArg("Uncommon", "r:u;");
mParent->addArg("Common", "r:c;");
mParent->addArg("Special Rarity", "{r:m;|r:t;|r:r;|r:u;|r:c;}");
mParent->addArg("Special Rarity", "{r:m;|r:t;|r:r;|r:u;|r:c;|r:l;}");
}
else if (filterType == FILTER_CMC)
{