Performance cleanup

This commit is contained in:
tool4EvEr
2022-02-19 20:18:31 +01:00
parent 797e9a3b66
commit 4c4e7c7723
7 changed files with 25 additions and 27 deletions

View File

@@ -275,11 +275,9 @@ public class AiBlockController {
} }
if (mode == TriggerType.DamageDone) { if (mode == TriggerType.DamageDone) {
if ((!trigParams.containsKey("ValidSource") if (trigger.matchesValidParam("ValidSource", attacker)
|| trigger.matchesValid(attacker, trigParams.get("ValidSource").split(",")))
&& attacker.getNetCombatDamage() > 0 && attacker.getNetCombatDamage() > 0
&& (!trigParams.containsKey("ValidTarget") && trigger.matchesValidParam("ValidTarget", combat.getDefenderByAttacker(attacker))) {
|| trigger.matchesValid(combat.getDefenderByAttacker(attacker), trigParams.get("ValidTarget").split(",")))) {
value += 50; value += 50;
} }
} else if (mode == TriggerType.AttackerUnblocked) { } else if (mode == TriggerType.AttackerUnblocked) {

View File

@@ -2664,15 +2664,15 @@ public class ComputerUtil {
for (Trigger trigger : theTriggers) { for (Trigger trigger : theTriggers) {
final Card source = trigger.getHostCard(); final Card source = trigger.getHostCard();
if (trigger.getMode() != TriggerType.SpellCast) {
continue;
}
if (!trigger.zonesCheck(game.getZoneOf(source))) { if (!trigger.zonesCheck(game.getZoneOf(source))) {
continue; continue;
} }
if (!trigger.requirementsCheck(game)) { if (!trigger.requirementsCheck(game)) {
continue; continue;
} }
if (trigger.getMode() != TriggerType.SpellCast) {
continue;
}
if (trigger.hasParam("ValidCard")) { if (trigger.hasParam("ValidCard")) {
if (!card.isValid(trigger.getParam("ValidCard").split(","), source.getController(), source, sa)) { if (!card.isValid(trigger.getParam("ValidCard").split(","), source.getController(), source, sa)) {
continue; continue;
@@ -2724,6 +2724,12 @@ public class ComputerUtil {
for (Trigger trigger : theTriggers) { for (Trigger trigger : theTriggers) {
final Card source = trigger.getHostCard(); final Card source = trigger.getHostCard();
if (trigger.getMode() != TriggerType.ChangesZone) {
continue;
}
if (!"Battlefield".equals(trigger.getParam("Destination"))) {
continue;
}
if (!trigger.zonesCheck(game.getZoneOf(source))) { if (!trigger.zonesCheck(game.getZoneOf(source))) {
continue; continue;
} }
@@ -2734,12 +2740,6 @@ public class ComputerUtil {
&& AbilityUtils.getDefinedCards(permanent, source.getSVar(trigger.getParam("CheckOnTriggeredCard").split(" ")[0]), null).isEmpty()) { && AbilityUtils.getDefinedCards(permanent, source.getSVar(trigger.getParam("CheckOnTriggeredCard").split(" ")[0]), null).isEmpty()) {
continue; continue;
} }
if (trigger.getMode() != TriggerType.ChangesZone) {
continue;
}
if (!"Battlefield".equals(trigger.getParam("Destination"))) {
continue;
}
if (trigger.hasParam("ValidCard")) { if (trigger.hasParam("ValidCard")) {
if (!permanent.isValid(trigger.getParam("ValidCard"), source.getController(), source, null)) { if (!permanent.isValid(trigger.getParam("ValidCard"), source.getController(), source, null)) {
continue; continue;

View File

@@ -356,19 +356,19 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView,
} }
CardCollection list = new CardCollection(); CardCollection list = new CardCollection();
if (presentPlayer.equals("You") || presentPlayer.equals("Any")) { if (presentPlayer.equals("You") || presentPlayer.equals("Any")) {
list.addAll(this.getHostCard().getController().getCardsIn(presentZone)); list.addAll(hostController.getCardsIn(presentZone));
} }
if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) { if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) {
for (final Player p : this.getHostCard().getController().getOpponents()) { for (final Player p : hostController.getOpponents()) {
list.addAll(p.getCardsIn(presentZone)); list.addAll(p.getCardsIn(presentZone));
} }
} }
if (presentPlayer.equals("Any")) { if (presentPlayer.equals("Any")) {
for (final Player p : this.getHostCard().getController().getAllies()) { for (final Player p : hostController.getAllies()) {
list.addAll(p.getCardsIn(presentZone)); list.addAll(p.getCardsIn(presentZone));
} }
} }
list = CardLists.getValidCards(list, sIsPresent, this.getHostCard().getController(), this.getHostCard(), this); list = CardLists.getValidCards(list, sIsPresent, hostController, this.getHostCard(), this);
final String rightString = presentCompare.substring(2); final String rightString = presentCompare.substring(2);
int right = AbilityUtils.calculateAmount(getHostCard(), rightString, this); int right = AbilityUtils.calculateAmount(getHostCard(), rightString, this);
@@ -389,15 +389,15 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView,
} }
CardCollection list = new CardCollection(); CardCollection list = new CardCollection();
if (presentPlayer.equals("You") || presentPlayer.equals("Any")) { if (presentPlayer.equals("You") || presentPlayer.equals("Any")) {
list.addAll(this.getHostCard().getController().getCardsIn(presentZone)); list.addAll(hostController.getCardsIn(presentZone));
} }
if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) { if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) {
for (final Player p : this.getHostCard().getController().getOpponents()) { for (final Player p : hostController.getOpponents()) {
list.addAll(p.getCardsIn(presentZone)); list.addAll(p.getCardsIn(presentZone));
} }
} }
list = CardLists.getValidCards(list, sIsPresent, this.getHostCard().getController(), this.getHostCard(), this); list = CardLists.getValidCards(list, sIsPresent, hostController, this.getHostCard(), this);
final String rightString = presentCompare.substring(2); final String rightString = presentCompare.substring(2);
int right = AbilityUtils.calculateAmount(getHostCard(), rightString, this); int right = AbilityUtils.calculateAmount(getHostCard(), rightString, this);

View File

@@ -614,8 +614,8 @@ public class AbilityManaPart implements java.io.Serializable {
for (final Player p : g.getPlayers()) { for (final Player p : g.getPlayers()) {
for (final Card crd : p.getAllCards()) { for (final Card crd : p.getAllCards()) {
for (final ReplacementEffect replacementEffect : crd.getReplacementEffects()) { for (final ReplacementEffect replacementEffect : crd.getReplacementEffects()) {
if (replacementEffect.requirementsCheck(g) if (replacementEffect.getMode() == ReplacementType.ProduceMana
&& replacementEffect.getMode() == ReplacementType.ProduceMana && replacementEffect.requirementsCheck(g)
&& replacementEffect.canReplace(repParams) && replacementEffect.canReplace(repParams)
&& replacementEffect.zonesCheck(g.getZoneOf(crd))) { && replacementEffect.zonesCheck(g.getZoneOf(crd))) {
return true; return true;

View File

@@ -272,7 +272,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
return true; return true;
} }
return this.subAbility != null ? this.subAbility.canProduce(s) : false; return this.subAbility != null && this.subAbility.canProduce(s);
} }
public boolean isManaAbilityFor(SpellAbility saPaidFor, byte colorNeeded) { public boolean isManaAbilityFor(SpellAbility saPaidFor, byte colorNeeded) {
@@ -290,7 +290,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
if (mp != null && metConditions() && mp.meetsManaRestrictions(saPaidFor) && mp.abilityProducesManaColor(this, colorNeeded)) { if (mp != null && metConditions() && mp.meetsManaRestrictions(saPaidFor) && mp.abilityProducesManaColor(this, colorNeeded)) {
return true; return true;
} }
return this.subAbility != null ? this.subAbility.isManaAbilityFor(saPaidFor, colorNeeded) : false; return this.subAbility != null && this.subAbility.isManaAbilityFor(saPaidFor, colorNeeded);
} }
public boolean isManaCannotCounter(SpellAbility saPaidFor) { public boolean isManaCannotCounter(SpellAbility saPaidFor) {
@@ -298,7 +298,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
if (mp != null && metConditions() && mp.meetsManaRestrictions(saPaidFor) && mp.cannotCounterPaidWith(saPaidFor)) { if (mp != null && metConditions() && mp.meetsManaRestrictions(saPaidFor) && mp.cannotCounterPaidWith(saPaidFor)) {
return true; return true;
} }
return this.subAbility != null ? this.subAbility.isManaCannotCounter(saPaidFor) : false; return this.subAbility != null && this.subAbility.isManaCannotCounter(saPaidFor);
} }
public int amountOfManaGenerated(boolean multiply) { public int amountOfManaGenerated(boolean multiply) {

View File

@@ -369,7 +369,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
if (getPresentDefined() != null) { if (getPresentDefined() != null) {
list = AbilityUtils.getDefinedObjects(host, getPresentDefined(), sa); list = AbilityUtils.getDefinedObjects(host, getPresentDefined(), sa);
} else { } else {
list = new FCollection<GameObject>(game.getCardsIn(getPresentZone())); list = new FCollection<>(game.getCardsIn(getPresentZone()));
} }
final int left = Iterables.size(Iterables.filter(list, GameObjectPredicates.restriction(getIsPresent().split(","), sa.getActivatingPlayer(), host, sa))); final int left = Iterables.size(Iterables.filter(list, GameObjectPredicates.restriction(getIsPresent().split(","), sa.getActivatingPlayer(), host, sa)));