forked from External/mage
* Fixed a problem with check playable methods causing e.g. endless loop if Shared Fate was on the battlefield.
This commit is contained in:
parent
32bd88a6c0
commit
133cc7342d
19 changed files with 227 additions and 230 deletions
|
|
@ -1,5 +1,9 @@
|
|||
package mage.game;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import mage.MageException;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.*;
|
||||
|
|
@ -65,11 +69,6 @@ import mage.util.functions.ApplyToPermanent;
|
|||
import mage.watchers.common.*;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public abstract class GameImpl implements Game, Serializable {
|
||||
|
||||
private static final int ROLLBACK_TURNS_MAX = 4;
|
||||
|
|
@ -77,7 +76,9 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
private static final Logger logger = Logger.getLogger(GameImpl.class);
|
||||
|
||||
private transient Object customData;
|
||||
|
||||
protected boolean simulation = false;
|
||||
protected boolean checkPlayableState = false;
|
||||
|
||||
protected final UUID id;
|
||||
|
||||
|
|
@ -163,6 +164,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
this.state = game.state.copy();
|
||||
this.gameCards = game.gameCards;
|
||||
this.simulation = game.simulation;
|
||||
this.checkPlayableState = game.checkPlayableState;
|
||||
this.gameOptions = game.gameOptions;
|
||||
this.lki.putAll(game.lki);
|
||||
this.lkiExtended.putAll(game.lkiExtended);
|
||||
|
|
@ -188,6 +190,16 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
this.simulation = simulation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCheckPlayableState(boolean checkPlayableState) {
|
||||
this.checkPlayableState = checkPlayableState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inCheckPlayableState() {
|
||||
return checkPlayableState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
|
@ -1480,7 +1492,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
/**
|
||||
* @param emblem
|
||||
* @param sourceObject
|
||||
* @param toPlayerId controller and owner of the emblem
|
||||
* @param toPlayerId controller and owner of the emblem
|
||||
*/
|
||||
@Override
|
||||
public void addEmblem(Emblem emblem, MageObject sourceObject, UUID toPlayerId) {
|
||||
|
|
@ -1498,8 +1510,8 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
/**
|
||||
* @param plane
|
||||
* @param sourceObject
|
||||
* @param toPlayerId controller and owner of the plane (may only be one per
|
||||
* game..)
|
||||
* @param toPlayerId controller and owner of the plane (may only be one per
|
||||
* game..)
|
||||
* @return boolean - whether the plane was added successfully or not
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -1728,7 +1740,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
break;
|
||||
}
|
||||
// triggered abilities that don't use the stack have to be executed first (e.g. Banisher Priest Return exiled creature
|
||||
for (Iterator<TriggeredAbility> it = abilities.iterator(); it.hasNext(); ) {
|
||||
for (Iterator<TriggeredAbility> it = abilities.iterator(); it.hasNext();) {
|
||||
TriggeredAbility triggeredAbility = it.next();
|
||||
if (!triggeredAbility.isUsesStack()) {
|
||||
state.removeTriggeredAbility(triggeredAbility);
|
||||
|
|
@ -2444,8 +2456,8 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
* exist. Then, if there are any objects still controlled by that player,
|
||||
* those objects are exiled. This is not a state-based action. It happens as
|
||||
* soon as the player leaves the game. If the player who left the game had
|
||||
* priority at the time they left, priority passes to the next player
|
||||
* in turn order who's still in the game. #
|
||||
* priority at the time they left, priority passes to the next player in
|
||||
* turn order who's still in the game. #
|
||||
*
|
||||
* @param playerId
|
||||
*/
|
||||
|
|
@ -2463,7 +2475,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
//20100423 - 800.4a
|
||||
Set<Card> toOutside = new HashSet<>();
|
||||
for (Iterator<Permanent> it = getBattlefield().getAllPermanents().iterator(); it.hasNext(); ) {
|
||||
for (Iterator<Permanent> it = getBattlefield().getAllPermanents().iterator(); it.hasNext();) {
|
||||
Permanent perm = it.next();
|
||||
if (perm.isOwnedBy(playerId)) {
|
||||
if (perm.getAttachedTo() != null) {
|
||||
|
|
@ -2506,7 +2518,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
player.moveCards(toOutside, Zone.OUTSIDE, null, this);
|
||||
// triggered abilities that don't use the stack have to be executed
|
||||
List<TriggeredAbility> abilities = state.getTriggered(player.getId());
|
||||
for (Iterator<TriggeredAbility> it = abilities.iterator(); it.hasNext(); ) {
|
||||
for (Iterator<TriggeredAbility> it = abilities.iterator(); it.hasNext();) {
|
||||
TriggeredAbility triggeredAbility = it.next();
|
||||
if (!triggeredAbility.isUsesStack()) {
|
||||
state.removeTriggeredAbility(triggeredAbility);
|
||||
|
|
@ -2526,7 +2538,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
|
||||
// Remove cards from the player in all exile zones
|
||||
for (ExileZone exile : this.getExile().getExileZones()) {
|
||||
for (Iterator<UUID> it = exile.iterator(); it.hasNext(); ) {
|
||||
for (Iterator<UUID> it = exile.iterator(); it.hasNext();) {
|
||||
Card card = this.getCard(it.next());
|
||||
if (card != null && card.isOwnedBy(playerId)) {
|
||||
it.remove();
|
||||
|
|
@ -2536,7 +2548,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
|
||||
//Remove all commander/emblems/plane the player controls
|
||||
boolean addPlaneAgain = false;
|
||||
for (Iterator<CommandObject> it = this.getState().getCommand().iterator(); it.hasNext(); ) {
|
||||
for (Iterator<CommandObject> it = this.getState().getCommand().iterator(); it.hasNext();) {
|
||||
CommandObject obj = it.next();
|
||||
if (obj.isControlledBy(playerId)) {
|
||||
if (obj instanceof Emblem) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue