1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Make bonus stacking configurable + fix duplicate propagation/inheritance (#433)

Addresses several related problems:
* Propagation / unpropagation of duplicate bonuses is inconsistent, causing bugs
* Duplicate bonuses never stack, which is not always intended behaviour (e.g. multiple copies of resource generating artifacts)
* Different bonuses always stack, which is not always intended behaviour (e.g. Angel + Archangel morale bonuses)

This is addressed as follows:
* Duplicate bonuses are never eliminated during propagation/inheritance.
* Unpropagation eliminates only a single copy of duplicated bonus
* Bonus receives a new field stacking that determines stacking behaviour:
* * empty string = no stacking with duplicates (default)
* * "ALWAYS" = stacks with duplicates & everything else
* * some other value = no stacking with bonuses with same stacking value
Also Morale/Luck window now hides non-stacking bonuses.
This commit is contained in:
Henning Koehler
2018-03-27 20:54:58 +13:00
committed by ArseniyShestakov
parent 2b64bf29ed
commit 02b5a5e830
12 changed files with 177 additions and 85 deletions

View File

@@ -794,15 +794,24 @@ void processCommand(const std::string &message)
}
else if(cn == "bonuses")
{
bool jsonFormat = (message == "bonuses json");
auto format = [jsonFormat](const BonusList & b) -> std::string
{
if(jsonFormat)
return b.toJsonNode().toJson(true);
std::ostringstream ss;
ss << b;
return ss.str();
};
std::cout << "Bonuses of " << adventureInt->selection->getObjectName() << std::endl
<< adventureInt->selection->getBonusList() << std::endl;
<< format(adventureInt->selection->getBonusList()) << std::endl;
std::cout << "\nInherited bonuses:\n";
TCNodes parents;
adventureInt->selection->getParents(parents);
for(const CBonusSystemNode *parent : parents)
{
std::cout << "\nBonuses from " << typeid(*parent).name() << std::endl << parent->getBonusList() << std::endl;
std::cout << "\nBonuses from " << typeid(*parent).name() << std::endl << format(*parent->getAllBonuses(Selector::all, Selector::all)) << std::endl;
}
}
else if(cn == "not dialog")