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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user