1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Configurable multi-hex attacks

- Added bonus type MULTIHEX_UNIT_ATTACK - configurable version of Dragon
Breath.
- Added bonus type MULTIHEX_ENEMY_ATTACK - configurable version of
Cerberi multi-headed attack that only hits enemies
- Added bonus type MULTIHEX_ANIMATION - optional bonus that does not
affects gameplay, but allows to define in which cases game should use
alternative attack animation.
- All existing multi-hex attack bonuses other than ATTACKS_ALL_ADJACENT
are presumable deprecated, but will be supported for now.
- It is now possible to precisely configure which hexes are targeted by
MULTIHEX_XXX bonuses. See docs for details.
- Unified logic of all multi-hex attacks, all existing bonuses are now
implemented as specific case of MULTIHEX_XXX bonus
- Added tests to cover Cerberi attack logic, and fixed incorrect edge
case of Dragon Breath
This commit is contained in:
Ivan Savenko
2025-05-20 14:54:45 +03:00
parent 95ac124dc9
commit e90d8c318d
14 changed files with 348 additions and 132 deletions

View File

@@ -237,6 +237,24 @@ static void loadBonusAddInfo(CAddInfo & var, BonusType type, const JsonNode & no
var[1] = value[1].Integer();
var[2] = value[2].Integer();
break;
case BonusType::MULTIHEX_UNIT_ATTACK:
case BonusType::MULTIHEX_ENEMY_ATTACK:
case BonusType::MULTIHEX_ANIMATION:
for (const auto & sequence : value.Vector())
{
static const std::map<char, int> charToDirection = {
{ 'f', 1 }, { 'l', 6}, {'r', 2}, {'b', 4}
};
int converted = 0;
for (const auto & ch : boost::adaptors::reverse(sequence.String()))
{
char chLower = std::tolower(ch);
if (charToDirection.count(chLower))
converted = 10 * converted + charToDirection.at(chLower);
}
var.push_back(converted);
}
break;
default:
for(const auto & i : bonusNameMap)
if(i.second == type)