|
@@ -108,72 +108,53 @@ JsonNode TimesHeroLevelUpdater::toJsonNode() const
|
|
|
return JsonNode("TIMES_HERO_LEVEL");
|
|
|
}
|
|
|
|
|
|
-ArmyMovementUpdater::ArmyMovementUpdater():
|
|
|
- base(20),
|
|
|
- divider(3),
|
|
|
- multiplier(10),
|
|
|
- max(700)
|
|
|
+std::shared_ptr<Bonus> TimesHeroLevelDivideStackLevelUpdater::createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context)
|
|
|
{
|
|
|
+ if(context.getNodeType() == CBonusSystemNode::HERO)
|
|
|
+ {
|
|
|
+ auto newBonus = TimesHeroLevelUpdater::createUpdatedBonus(b, context);
|
|
|
+ newBonus->updater = divideStackLevel;
|
|
|
+ return newBonus;
|
|
|
+ }
|
|
|
+ return b;
|
|
|
}
|
|
|
|
|
|
-ArmyMovementUpdater::ArmyMovementUpdater(int base, int divider, int multiplier, int max):
|
|
|
- base(base),
|
|
|
- divider(divider),
|
|
|
- multiplier(multiplier),
|
|
|
- max(max)
|
|
|
+std::string TimesHeroLevelDivideStackLevelUpdater::toString() const
|
|
|
{
|
|
|
+ return "TimesHeroLevelDivideStackLevelUpdater";
|
|
|
}
|
|
|
|
|
|
-std::shared_ptr<Bonus> ArmyMovementUpdater::createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context)
|
|
|
+JsonNode TimesHeroLevelDivideStackLevelUpdater::toJsonNode() const
|
|
|
{
|
|
|
- return b;
|
|
|
+ return JsonNode("TIMES_HERO_LEVEL_DIVIDE_STACK_LEVEL");
|
|
|
}
|
|
|
|
|
|
-std::string ArmyMovementUpdater::toString() const
|
|
|
+std::shared_ptr<Bonus> TimesStackLevelUpdater::apply(const std::shared_ptr<Bonus> & b, int level) const
|
|
|
{
|
|
|
- return "ArmyMovementUpdater";
|
|
|
+ auto newBonus = std::make_shared<Bonus>(*b);
|
|
|
+ newBonus->val *= level;
|
|
|
+ newBonus->updater = nullptr; // prevent double-apply
|
|
|
+ return newBonus;
|
|
|
}
|
|
|
|
|
|
-JsonNode ArmyMovementUpdater::toJsonNode() const
|
|
|
-{
|
|
|
- JsonNode root;
|
|
|
-
|
|
|
- root["type"].String() = "ARMY_MOVEMENT";
|
|
|
- root["parameters"].Vector().emplace_back(base);
|
|
|
- root["parameters"].Vector().emplace_back(divider);
|
|
|
- root["parameters"].Vector().emplace_back(multiplier);
|
|
|
- root["parameters"].Vector().emplace_back(max);
|
|
|
-
|
|
|
- return root;
|
|
|
-}
|
|
|
std::shared_ptr<Bonus> TimesStackLevelUpdater::createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context)
|
|
|
{
|
|
|
if(context.getNodeType() == CBonusSystemNode::STACK_INSTANCE || context.getNodeType() == CBonusSystemNode::COMMANDER)
|
|
|
{
|
|
|
int level = dynamic_cast<const CStackInstance &>(context).getLevel();
|
|
|
- auto newBonus = std::make_shared<Bonus>(*b);
|
|
|
- newBonus->val *= level;
|
|
|
- return newBonus;
|
|
|
+ return apply(b, level);
|
|
|
}
|
|
|
- else if(context.getNodeType() == CBonusSystemNode::STACK_BATTLE)
|
|
|
+
|
|
|
+ if(context.getNodeType() == CBonusSystemNode::STACK_BATTLE)
|
|
|
{
|
|
|
const auto & stack = dynamic_cast<const CStack &>(context);
|
|
|
//update if stack doesn't have an instance (summons, war machines)
|
|
|
if(stack.base == nullptr)
|
|
|
- {
|
|
|
- int level = stack.unitType()->getLevel();
|
|
|
- auto newBonus = std::make_shared<Bonus>(*b);
|
|
|
- newBonus->val *= level;
|
|
|
- return newBonus;
|
|
|
- }
|
|
|
+ return apply(b, stack.unitType()->getLevel());
|
|
|
+
|
|
|
// If these are not handled here, the final outcome may potentially be incorrect.
|
|
|
- else
|
|
|
- {
|
|
|
- int level = dynamic_cast<const CStackInstance*>(stack.base)->getLevel();
|
|
|
- auto newBonus = std::make_shared<Bonus>(*b);
|
|
|
- newBonus->val *= level;
|
|
|
- return newBonus;
|
|
|
- }
|
|
|
+ int level = dynamic_cast<const CStackInstance*>(stack.base)->getLevel();
|
|
|
+ return apply(b, level);
|
|
|
}
|
|
|
return b;
|
|
|
}
|
|
@@ -188,6 +169,46 @@ JsonNode TimesStackLevelUpdater::toJsonNode() const
|
|
|
return JsonNode("TIMES_STACK_LEVEL");
|
|
|
}
|
|
|
|
|
|
+std::shared_ptr<Bonus> DivideStackLevelUpdater::apply(const std::shared_ptr<Bonus> & b, int level) const
|
|
|
+{
|
|
|
+ auto newBonus = std::make_shared<Bonus>(*b);
|
|
|
+ newBonus->val /= level;
|
|
|
+ newBonus->updater = nullptr; // prevent double-apply
|
|
|
+ return newBonus;
|
|
|
+}
|
|
|
+
|
|
|
+std::shared_ptr<Bonus> DivideStackLevelUpdater::createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context)
|
|
|
+{
|
|
|
+ if(context.getNodeType() == CBonusSystemNode::STACK_INSTANCE || context.getNodeType() == CBonusSystemNode::COMMANDER)
|
|
|
+ {
|
|
|
+ int level = dynamic_cast<const CStackInstance &>(context).getLevel();
|
|
|
+ return apply(b, level);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(context.getNodeType() == CBonusSystemNode::STACK_BATTLE)
|
|
|
+ {
|
|
|
+ const auto & stack = dynamic_cast<const CStack &>(context);
|
|
|
+ //update if stack doesn't have an instance (summons, war machines)
|
|
|
+ if(stack.base == nullptr)
|
|
|
+ return apply(b, stack.unitType()->getLevel());
|
|
|
+
|
|
|
+ // If these are not handled here, the final outcome may potentially be incorrect.
|
|
|
+ int level = dynamic_cast<const CStackInstance*>(stack.base)->getLevel();
|
|
|
+ return apply(b, level);
|
|
|
+ }
|
|
|
+ return b;
|
|
|
+}
|
|
|
+
|
|
|
+std::string DivideStackLevelUpdater::toString() const
|
|
|
+{
|
|
|
+ return "DivideStackLevelUpdater";
|
|
|
+}
|
|
|
+
|
|
|
+JsonNode DivideStackLevelUpdater::toJsonNode() const
|
|
|
+{
|
|
|
+ return JsonNode("DIVIDE_STACK_LEVEL");
|
|
|
+}
|
|
|
+
|
|
|
std::string OwnerUpdater::toString() const
|
|
|
{
|
|
|
return "OwnerUpdater";
|