Performance fixes

This commit is contained in:
tool4EvEr
2022-07-11 19:15:26 +02:00
parent cf03361a62
commit cb2fc04f6a

View File

@@ -111,12 +111,18 @@ public final class StaticAbilityContinuous {
final List<Player> affectedPlayers = StaticAbilityContinuous.getAffectedPlayers(stAb);
final Game game = hostCard.getGame();
final StaticEffect se = game.getStaticEffects().getStaticEffect(stAb);
final StaticEffects effects = game.getStaticEffects();
final StaticEffect se = effects.getStaticEffect(stAb);
se.setAffectedCards(affectedCards);
se.setAffectedPlayers(affectedPlayers);
se.setParams(params);
se.setTimestamp(hostCard.getTimestamp());
// nothing more to do
if (stAb.hasParam("Affected") && affectedPlayers.isEmpty() && affectedCards.isEmpty()) {
return affectedCards;
}
String addP = "";
int powerBonus = 0;
String addT = "";
@@ -161,7 +167,6 @@ public final class StaticAbilityContinuous {
//Global rules changes
if (layer == StaticAbilityLayer.RULES && params.containsKey("GlobalRule")) {
final StaticEffects effects = game.getStaticEffects();
effects.setGlobalRuleChange(GlobalRuleChange.fromString(params.get("GlobalRule")));
}
@@ -197,8 +202,6 @@ public final class StaticAbilityContinuous {
// update keywords with Chosen parts
final String hostCardUID = Integer.toString(hostCard.getId()); // Protection with "doesn't remove" effect
final ColorSet colorsYouCtrl = CardUtil.getColorsYouCtrl(controller);
Iterables.removeIf(addKeywords, new Predicate<String>() {
@Override
public boolean apply(String input) {
@@ -246,6 +249,8 @@ public final class StaticAbilityContinuous {
}
// two variants for Red vs. red in keyword
if (input.contains("ColorsYouCtrl") || input.contains("colorsYouCtrl")) {
final ColorSet colorsYouCtrl = CardUtil.getColorsYouCtrl(controller);
for (byte color : colorsYouCtrl) {
final String colorWord = MagicColor.toLongString(color);
String y = input.replaceAll("ColorsYouCtrl", StringUtils.capitalize(colorWord));
@@ -718,6 +723,7 @@ public final class StaticAbilityContinuous {
// add P/T bonus
if (layer == StaticAbilityLayer.MODIFYPT) {
if (addP.contains("Affected")) {
// TODO don't calculate these above if this gets used instead
powerBonus = AbilityUtils.calculateAmount(affectedCard, addP, stAb, true);
}
if (addT.contains("Affected")) {