Skip to content

Commit

Permalink
Modify CreatePhaseRulesEffect.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjenryin committed Aug 11, 2023
1 parent e56c90b commit 2737f4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/banquetRuleGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,13 @@ Rule *getRuleFromJson(const Json::Value &intent, int dish,
e = new NextRuleEffect(newRule);

} else if (effectType == "CreateBuff") {
// 下(两)阶段blahblah
auto newIntent = getBuffById(allBuffs, effectValue);
int lastRounds = getInt(newIntent["lastRounds"]);
auto newRule = getRuleFromJson(newIntent, dish + DISH_PER_CHEF,
allIntents, allBuffs, 1);
e = new CreateRulesEffect(newRule, DISH_PER_CHEF * lastRounds, true);
e = new CreatePhaseRulesEffect(newRule, DISH_PER_CHEF * lastRounds,
true);
}
return new SingleConditionRule(c, e);
}
Expand Down
10 changes: 6 additions & 4 deletions src/banquetRuleGen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class GroupCondition : public Condition {
}
}

return start + DISH_PER_CHEF;
return start;
}
};
class RankCondition : public Condition {
Expand Down Expand Up @@ -186,21 +186,23 @@ class NextRuleEffect : public Effect {
}
~NextRuleEffect() override { delete rule; }
};
class CreateRulesEffect : public Effect {
class CreatePhaseRulesEffect : public Effect {
public:
Rule *rule;
int len;
CreateRulesEffect(Rule *rule, int len, bool strict = false)
CreatePhaseRulesEffect(Rule *rule, int len, bool strict = false)
: rule(rule), len(len) {
for (int i = 0; i < len; i++)
rule->effect->strict = strict;
}
void operator()(BanquetRuleTogether *brt, int i, States &s) const override {
// Starting from next phase.
i = (i / DISH_PER_CHEF + 1) * DISH_PER_CHEF;
for (int j = 0; j < len; j++) {
(*rule)(brt, s, i + j);
}
}
~CreateRulesEffect() override { delete rule; }
~CreatePhaseRulesEffect() override { delete rule; }
};
class FullAddEffect : public Effect {
public:
Expand Down

0 comments on commit 2737f4b

Please sign in to comment.