Merge branch 'sentry-bug-fixes' into 'master'

Sentry bug fixes

See merge request core-developers/forge!948
This commit is contained in:
Michael Kamensky
2018-09-26 05:25:58 +00:00
3 changed files with 26 additions and 18 deletions

View File

@@ -1484,22 +1484,24 @@ public class AiController {
boolean hasLeyline1 = false; boolean hasLeyline1 = false;
SpellAbility saGemstones = null; SpellAbility saGemstones = null;
for(int i = 0; i < result.size(); i++) { List<SpellAbility> toRemove = Lists.newArrayList();
SpellAbility sa = result.get(i); for(SpellAbility sa : result) {
String srcName = sa.getHostCard().getName(); String srcName = sa.getHostCard().getName();
if ("Gemstone Caverns".equals(srcName)) { if ("Gemstone Caverns".equals(srcName)) {
if (saGemstones == null) if (saGemstones == null)
saGemstones = sa; saGemstones = sa;
else else
result.remove(i--); toRemove.add(sa);
} else if ("Leyline of Singularity".equals(srcName)) { } else if ("Leyline of Singularity".equals(srcName)) {
if (!hasLeyline1) if (!hasLeyline1)
hasLeyline1 = true; hasLeyline1 = true;
else else
result.remove(i--); toRemove.add(sa);
} }
} }
for(SpellAbility sa : toRemove) {
result.remove(sa);
}
// Play them last // Play them last
if (saGemstones != null) { if (saGemstones != null) {

View File

@@ -798,16 +798,18 @@ public class GameAction {
public boolean visit(final Card c) { public boolean visit(final Card c) {
// need to get Card from preList if able // need to get Card from preList if able
final Card co = preList.get(c); final Card co = preList.get(c);
for (int i = 0; i < co.getStaticAbilities().size(); i++) { List<StaticAbility> toRemove = Lists.newArrayList();
final StaticAbility stAb = co.getStaticAbilities().get(i); for (StaticAbility stAb : co.getStaticAbilities()) {
if (stAb.getMapParams().get("Mode").equals("Continuous")) { if (stAb.getMapParams().get("Mode").equals("Continuous")) {
staticAbilities.add(stAb); staticAbilities.add(stAb);
} }
if (stAb.isTemporary()) { if (stAb.isTemporary()) {
co.removeStaticAbility(stAb); toRemove.add(stAb);
i--;
} }
} }
for (StaticAbility stAb : toRemove) {
co.removeStaticAbility(stAb);
}
if (!co.getStaticCommandList().isEmpty()) { if (!co.getStaticCommandList().isEmpty()) {
staticList.add(co); staticList.add(co);
} }
@@ -851,8 +853,8 @@ public class GameAction {
} }
for (final Card c : staticList) { for (final Card c : staticList) {
for (int i = 0; i < c.getStaticCommandList().size(); i++) { List<Object[]> toRemove = Lists.newArrayList();
final Object[] staticCheck = c.getStaticCommandList().get(i); for (Object[] staticCheck : c.getStaticCommandList()) {
final String leftVar = (String) staticCheck[0]; final String leftVar = (String) staticCheck[0];
final String rightVar = (String) staticCheck[1]; final String rightVar = (String) staticCheck[1];
final Card affected = (Card) staticCheck[2]; final Card affected = (Card) staticCheck[2];
@@ -863,11 +865,13 @@ public class GameAction {
final int operandValue = AbilityUtils.calculateAmount(c, svarOperand, null); final int operandValue = AbilityUtils.calculateAmount(c, svarOperand, null);
if (Expressions.compare(sVar, svarOperator, operandValue)) { if (Expressions.compare(sVar, svarOperator, operandValue)) {
((GameCommand) staticCheck[3]).run(); ((GameCommand) staticCheck[3]).run();
c.getStaticCommandList().remove(i); toRemove.add(staticCheck);
i--;
affectedCards.add(c); affectedCards.add(c);
} }
} }
for (Object[] staticCheck : c.getStaticCommandList()) {
c.getStaticCommandList().remove(staticCheck);
}
} }
// Exclude cards in hidden zones from update // Exclude cards in hidden zones from update
Iterator<Card> it = affectedCards.iterator(); Iterator<Card> it = affectedCards.iterator();

View File

@@ -309,13 +309,15 @@ public class ReplacementHandler {
game.forEachCardInGame(new Visitor<Card>() { game.forEachCardInGame(new Visitor<Card>() {
@Override @Override
public boolean visit(Card c) { public boolean visit(Card c) {
for (int i = 0; i < c.getReplacementEffects().size(); i++) { List<ReplacementEffect> toRemove = Lists.newArrayList();
ReplacementEffect rep = c.getReplacementEffects().get(i); for (ReplacementEffect rep : c.getReplacementEffects()) {
if (rep.isTemporary()) { if (rep.isTemporary()) {
c.removeReplacementEffect(rep); toRemove.add(rep);
i--;
} }
} }
for (ReplacementEffect rep : toRemove) {
c.removeReplacementEffect(rep);
}
return true; return true;
} }
}); });