diff --git a/tyrant.h b/tyrant.h index c3c37d81..06f4218b 100644 --- a/tyrant.h +++ b/tyrant.h @@ -259,6 +259,20 @@ inline PassiveBGE::PassiveBGE passive_bge_name_to_id(const std::string& name_) return PassiveBGE::no_bge; } +inline Faction faction_name_to_id(const std::string& name_) +{ + std::string name(name_); + name.erase(std::remove_if(name.begin(), name.end(), boost::is_any_of("-")), name.end()); //Mostly useless + for (unsigned i(allfactions); i < num_factions; ++i) + { + if (boost::iequals(faction_names[i], name)) + { + return static_cast(i); + } + } + return allfactions; +} + inline void map_keys_to_set(const std::unordered_map& m, std::unordered_set& s) { for (auto it = m.begin(); it != m.end(); ++it) diff --git a/tyrant_optimize.cpp b/tyrant_optimize.cpp index 6212bb56..910648a5 100644 --- a/tyrant_optimize.cpp +++ b/tyrant_optimize.cpp @@ -56,6 +56,7 @@ namespace { std::unordered_map owned_cards; const Card* owned_alpha_dominion{nullptr}; bool use_owned_cards{true}; + Faction faction = allfactions; unsigned min_deck_len{1}; unsigned max_deck_len{10}; unsigned freezed_cards{0}; @@ -1293,6 +1294,11 @@ void hill_climbing(unsigned num_min_iterations, unsigned num_iterations, Deck* d { continue; } + //mono + if(faction != allfactions && card->m_faction != faction) + { + continue; + } // enqueue candidate according to category & type if (card->m_type == CardType::commander) @@ -2056,6 +2062,11 @@ int main(int argc, char** argv) { opt_keep_commander = true; } + else if (strcmp(argv[argIndex], "mono") == 0 || strcmp(argv[argIndex], "-m") == 0) + { + faction = faction_name_to_id(argv[argIndex + 1]); + argIndex += 1; + } else if (strcmp(argv[argIndex], "effect") == 0 || strcmp(argv[argIndex], "-e") == 0) { opt_effects[2].push_back(argv[argIndex + 1]);