mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Simulation: fix wrong ActivatingPlayer
This commit is contained in:
@@ -27,6 +27,7 @@ import forge.game.card.CardFactory;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.card.token.TokenInfo;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.mana.Mana;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
@@ -90,7 +91,9 @@ public class GameCopier {
|
||||
newPlayer.setLifeLostLastTurn(origPlayer.getLifeLostLastTurn());
|
||||
newPlayer.setLifeLostThisTurn(origPlayer.getLifeLostThisTurn());
|
||||
newPlayer.setLifeGainedThisTurn(origPlayer.getLifeGainedThisTurn());
|
||||
newPlayer.getManaPool().add(origPlayer.getManaPool());
|
||||
for (Mana m : origPlayer.getManaPool()) {
|
||||
newPlayer.getManaPool().addMana(m, false);
|
||||
}
|
||||
newPlayer.setCommanders(origPlayer.getCommanders()); // will be fixed up below
|
||||
playerMap.put(origPlayer, newPlayer);
|
||||
}
|
||||
@@ -131,7 +134,7 @@ public class GameCopier {
|
||||
for (SpellAbility sa : c.getSpellAbilities()) {
|
||||
Player activatingPlayer = sa.getActivatingPlayer();
|
||||
if (activatingPlayer != null && activatingPlayer.getGame() != newGame) {
|
||||
sa.setActivatingPlayer(gameObjectMap.map(activatingPlayer));
|
||||
sa.setActivatingPlayer(gameObjectMap.map(activatingPlayer), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,7 +183,7 @@ public class GameCopier {
|
||||
}
|
||||
}
|
||||
if (newSa != null) {
|
||||
newSa.setActivatingPlayer(map.map(origSa.getActivatingPlayer()));
|
||||
newSa.setActivatingPlayer(map.map(origSa.getActivatingPlayer()), true);
|
||||
if (origSa.usesTargeting()) {
|
||||
for (GameObject o : origSa.getTargets()) {
|
||||
newSa.getTargets().add(map.map(o));
|
||||
|
||||
@@ -16,6 +16,7 @@ import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetChoices;
|
||||
import forge.util.collect.FCollectionView;
|
||||
|
||||
public class GameSimulator {
|
||||
public static boolean COPY_STACK = false;
|
||||
@@ -124,7 +125,7 @@ public class GameSimulator {
|
||||
}
|
||||
}
|
||||
|
||||
private SpellAbility findSaInSimGame(SpellAbility sa) {
|
||||
private SpellAbility findSaInSimGame(final SpellAbility sa) {
|
||||
// is already an ability from sim game
|
||||
if (sa.getHostCard().getGame().equals(this.simGame)) {
|
||||
return sa;
|
||||
@@ -132,7 +133,15 @@ public class GameSimulator {
|
||||
Card origHostCard = sa.getHostCard();
|
||||
Card hostCard = (Card) copier.find(origHostCard);
|
||||
String desc = sa.getDescription();
|
||||
for (SpellAbility cSa : hostCard.getSpellAbilities()) {
|
||||
FCollectionView<SpellAbility> candidates = hostCard.getSpellAbilities();
|
||||
// first pass for accuracy (spells with alternative costs)
|
||||
for (SpellAbility cSa : candidates) {
|
||||
if (desc.equals(cSa.getDescription())) {
|
||||
return cSa;
|
||||
}
|
||||
}
|
||||
// fall back for safety
|
||||
for (SpellAbility cSa : candidates) {
|
||||
if (desc.startsWith(cSa.getDescription())) {
|
||||
return cSa;
|
||||
}
|
||||
@@ -160,7 +169,7 @@ public class GameSimulator {
|
||||
}
|
||||
|
||||
debugPrint("Found SA " + sa + " on host card " + sa.getHostCard() + " with owner:"+ sa.getHostCard().getOwner());
|
||||
sa.setActivatingPlayer(aiPlayer);
|
||||
sa.setActivatingPlayer(aiPlayer, true);
|
||||
SpellAbility origSaOrSubSa = origSa;
|
||||
SpellAbility saOrSubSa = sa;
|
||||
do {
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import forge.game.event.GameEventDayTimeChanged;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
@@ -55,6 +54,7 @@ import forge.game.card.CardView;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.event.Event;
|
||||
import forge.game.event.GameEventDayTimeChanged;
|
||||
import forge.game.event.GameEventGameOutcome;
|
||||
import forge.game.phase.Phase;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
|
||||
@@ -434,7 +434,8 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
public boolean setActivatingPlayer(final Player player, final boolean lki) {
|
||||
// trickle down activating player
|
||||
boolean updated = false;
|
||||
if (player == null || !player.equals(activatingPlayer)) {
|
||||
// don't use equals because player might be from simulation
|
||||
if (player == null || player != activatingPlayer) {
|
||||
activatingPlayer = player;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user