mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Refactor how MindSlaver logic works so mindSlaveMaster can view their cards in addition to those of the player they've taken over
This commit is contained in:
@@ -297,9 +297,7 @@ public class Game {
|
|||||||
public synchronized void setGameOver(GameEndReason reason) {
|
public synchronized void setGameOver(GameEndReason reason) {
|
||||||
this.age = GameStage.GameOver;
|
this.age = GameStage.GameOver;
|
||||||
for (Player p : allPlayers) {
|
for (Player p : allPlayers) {
|
||||||
if (p.isMindSlaved()) {
|
p.setMindSlaveMaster(null); // for correct totals
|
||||||
p.releaseControl(); // for correct totals
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player p : roIngamePlayers) {
|
for (Player p : roIngamePlayers) {
|
||||||
|
|||||||
@@ -30,24 +30,22 @@ public class ControlPlayerEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
List<Player> tgtPlayers = getTargetPlayers(sa);
|
List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||||
|
|
||||||
for(final Player pTarget: tgtPlayers) {
|
for (final Player pTarget: tgtPlayers) {
|
||||||
|
|
||||||
// on next untap gain control
|
// on next untap gain control
|
||||||
game.getUntap().addUntil(pTarget, new GameCommand() {
|
game.getUntap().addUntil(pTarget, new GameCommand() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
pTarget.setControllingPlayerController(activator.getLobbyPlayer().createControllerFor(pTarget));
|
pTarget.setMindSlaveMaster(activator);
|
||||||
|
|
||||||
// on following cleanup release control
|
// on following cleanup release control
|
||||||
game.getEndOfTurn().addUntil(new GameCommand() {
|
game.getEndOfTurn().addUntil(new GameCommand() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
pTarget.releaseControl();
|
pTarget.setMindSlaveMaster(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8578,6 +8578,12 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if viewer is controlled by another player, also check if card can be shown to that player
|
||||||
|
if (viewer.isMindSlaved()) {
|
||||||
|
return canBeShownTo(viewer.getMindSlaveMaster());
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
protected PlayerController controller;
|
protected PlayerController controller;
|
||||||
protected PlayerController controllerCreator = null;
|
protected PlayerController controllerCreator = null;
|
||||||
|
|
||||||
|
private Player mindSlaveMaster = null;
|
||||||
|
|
||||||
private int teamNumber = -1;
|
private int teamNumber = -1;
|
||||||
|
|
||||||
private Card activeScheme = null;
|
private Card activeScheme = null;
|
||||||
@@ -197,16 +199,17 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
|
|
||||||
private String chooseName(String originalName) {
|
private String chooseName(String originalName) {
|
||||||
String nameCandidate = originalName;
|
String nameCandidate = originalName;
|
||||||
for( int i = 2; i <= 8; i++) { // several tries, not matter how many
|
for (int i = 2; i <= 8; i++) { // several tries, not matter how many
|
||||||
boolean haveDuplicates = false;
|
boolean haveDuplicates = false;
|
||||||
for( Player p : game.getPlayers()) {
|
for (Player p : game.getPlayers()) {
|
||||||
if( p.getName().equals(nameCandidate)) {
|
if (p.getName().equals(nameCandidate)) {
|
||||||
haveDuplicates = true;
|
haveDuplicates = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!haveDuplicates)
|
if (!haveDuplicates) {
|
||||||
return nameCandidate;
|
return nameCandidate;
|
||||||
|
}
|
||||||
nameCandidate = Lang.getOrdinal(i) + " " + originalName;
|
nameCandidate = Lang.getOrdinal(i) + " " + originalName;
|
||||||
}
|
}
|
||||||
return nameCandidate;
|
return nameCandidate;
|
||||||
@@ -272,9 +275,10 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
*/
|
*/
|
||||||
public final Player getOpponent() {
|
public final Player getOpponent() {
|
||||||
for (Player p : game.getPlayers()) {
|
for (Player p : game.getPlayers()) {
|
||||||
if (p.isOpponentOf(this))
|
if (p.isOpponentOf(this)) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
throw new IllegalStateException("No opponents left ingame for " + this);
|
throw new IllegalStateException("No opponents left ingame for " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,9 +291,10 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
public final List<Player> getOpponents() {
|
public final List<Player> getOpponents() {
|
||||||
List<Player> result = new ArrayList<Player>();
|
List<Player> result = new ArrayList<Player>();
|
||||||
for (Player p : game.getPlayers()) {
|
for (Player p : game.getPlayers()) {
|
||||||
if (p.isOpponentOf(this))
|
if (p.isOpponentOf(this)) {
|
||||||
result.add(p);
|
result.add(p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,9 +306,10 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
public final List<Player> getAllies() {
|
public final List<Player> getAllies() {
|
||||||
List<Player> result = new ArrayList<Player>();
|
List<Player> result = new ArrayList<Player>();
|
||||||
for (Player p : game.getPlayers()) {
|
for (Player p : game.getPlayers()) {
|
||||||
if (!p.isOpponentOf(this))
|
if (!p.isOpponentOf(this)) {
|
||||||
result.add(p);
|
result.add(p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,12 +341,9 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOpponentOf(Player other) {
|
public boolean isOpponentOf(Player other) {
|
||||||
return other != this && other != null && ( other.teamNumber < 0 || other.teamNumber != this.teamNumber );
|
return other != this && other != null && (other.teamNumber < 0 || other.teamNumber != this.teamNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ////////////////////////
|
// ////////////////////////
|
||||||
//
|
//
|
||||||
// methods for manipulating life
|
// methods for manipulating life
|
||||||
@@ -418,7 +421,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean gainLife(final int toGain, final Card source) {
|
public final boolean gainLife(final int toGain, final Card source) {
|
||||||
|
|
||||||
// Run any applicable replacement effects.
|
// Run any applicable replacement effects.
|
||||||
final HashMap<String, Object> repParams = new HashMap<String, Object>();
|
final HashMap<String, Object> repParams = new HashMap<String, Object>();
|
||||||
repParams.put("Event", "GainLife");
|
repParams.put("Event", "GainLife");
|
||||||
@@ -615,14 +617,11 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(source.isCommander() && isCombat)
|
if (source.isCommander() && isCombat) {
|
||||||
{
|
if (!commanderDamage.containsKey(source)) {
|
||||||
if(!commanderDamage.containsKey(source))
|
|
||||||
{
|
|
||||||
commanderDamage.put(source, amount);
|
commanderDamage.put(source, amount);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
commanderDamage.put(source,commanderDamage.get(source) + amount);
|
commanderDamage.put(source,commanderDamage.get(source) + amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -670,7 +669,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final int staticDamagePrevention(final int damage, final Card source, final boolean isCombat, final boolean isTest) {
|
public final int staticDamagePrevention(final int damage, final Card source, final boolean isCombat, final boolean isTest) {
|
||||||
|
|
||||||
if (game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
if (game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
@@ -736,7 +734,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final int staticReplaceDamage(final int damage, final Card source, final boolean isCombat) {
|
public final int staticReplaceDamage(final int damage, final Card source, final boolean isCombat) {
|
||||||
|
|
||||||
int restDamage = damage;
|
int restDamage = damage;
|
||||||
|
|
||||||
if (this.hasKeyword("Damage that would reduce your life total to less than 1 reduces it to 1 instead.")) {
|
if (this.hasKeyword("Damage that would reduce your life total to less than 1 reduces it to 1 instead.")) {
|
||||||
@@ -823,7 +820,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final int replaceDamage(final int damage, final Card source, final boolean isCombat) {
|
public final int replaceDamage(final int damage, final Card source, final boolean isCombat) {
|
||||||
|
|
||||||
// Replacement effects
|
// Replacement effects
|
||||||
final HashMap<String, Object> repParams = new HashMap<String, Object>();
|
final HashMap<String, Object> repParams = new HashMap<String, Object>();
|
||||||
repParams.put("Event", "DamageDone");
|
repParams.put("Event", "DamageDone");
|
||||||
@@ -854,7 +850,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final int preventDamage(final int damage, final Card source, final boolean isCombat) {
|
public final int preventDamage(final int damage, final Card source, final boolean isCombat) {
|
||||||
|
|
||||||
if (game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)
|
if (game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)
|
||||||
|| source.hasKeyword("Damage that would be dealt by CARDNAME can't be prevented.")) {
|
|| source.hasKeyword("Damage that would be dealt by CARDNAME can't be prevented.")) {
|
||||||
return damage;
|
return damage;
|
||||||
@@ -1016,7 +1011,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
* a {@link forge.game.card.Card} object.
|
* a {@link forge.game.card.Card} object.
|
||||||
*/
|
*/
|
||||||
public final boolean addCombatDamage(final int damage, final Card source) {
|
public final boolean addCombatDamage(final int damage, final Card source) {
|
||||||
|
|
||||||
int damageToDo = damage;
|
int damageToDo = damage;
|
||||||
|
|
||||||
damageToDo = this.replaceDamage(damageToDo, source, true);
|
damageToDo = this.replaceDamage(damageToDo, source, true);
|
||||||
@@ -1245,7 +1239,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return this.drawCards(1);
|
return this.drawCards(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean canMulligan() {
|
public boolean canMulligan() {
|
||||||
return !getZone(ZoneType.Hand).isEmpty();
|
return !getZone(ZoneType.Hand).isEmpty();
|
||||||
}
|
}
|
||||||
@@ -1314,8 +1307,9 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
this.setLastDrawnCard(c);
|
this.setLastDrawnCard(c);
|
||||||
c.setDrawnThisTurn(true);
|
c.setDrawnThisTurn(true);
|
||||||
this.numDrawnThisTurn++;
|
this.numDrawnThisTurn++;
|
||||||
if ( game.getPhaseHandler().is(PhaseType.DRAW))
|
if (game.getPhaseHandler().is(PhaseType.DRAW)) {
|
||||||
this.numDrawnThisDrawStep++;
|
this.numDrawnThisDrawStep++;
|
||||||
|
}
|
||||||
|
|
||||||
// Miracle draws
|
// Miracle draws
|
||||||
if (this.numDrawnThisTurn == 1
|
if (this.numDrawnThisTurn == 1
|
||||||
@@ -1437,7 +1431,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return CardLists.filter(this.getCardsIn(zone), CardPredicates.nameEquals(cardName));
|
return CardLists.filter(this.getCardsIn(zone), CardPredicates.nameEquals(cardName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Card> getCardsActivableInExternalZones() {
|
public List<Card> getCardsActivableInExternalZones() {
|
||||||
final List<Card> cl = new ArrayList<Card>();
|
final List<Card> cl = new ArrayList<Card>();
|
||||||
|
|
||||||
@@ -1488,7 +1481,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dredge;
|
return dredge;
|
||||||
} // hasDredge()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -1507,7 +1500,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
// throw new RuntimeException("Input_Draw : getDredgeNumber() card doesn't have dredge - " + c.getName());
|
// throw new RuntimeException("Input_Draw : getDredgeNumber() card doesn't have dredge - " + c.getName());
|
||||||
} // getDredgeNumber()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -1602,7 +1595,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
game.getTriggerHandler().runTrigger(TriggerType.Discarded, runParams, false);
|
game.getTriggerHandler().runTrigger(TriggerType.Discarded, runParams, false);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // end doDiscard
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -1771,7 +1764,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean canPlayLand(Card land, final boolean ignoreZoneAndTiming) {
|
public final boolean canPlayLand(Card land, final boolean ignoreZoneAndTiming) {
|
||||||
|
|
||||||
if (!ignoreZoneAndTiming && !this.canCastSorcery()) {
|
if (!ignoreZoneAndTiming && !this.canCastSorcery()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1786,7 +1778,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( land != null && !ignoreZoneAndTiming) {
|
if (land != null && !ignoreZoneAndTiming) {
|
||||||
if (land.getOwner() != this && !land.hasKeyword("May be played by your opponent"))
|
if (land.getOwner() != this && !land.hasKeyword("May be played by your opponent"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -2094,7 +2086,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean checkLoseCondition() {
|
public final boolean checkLoseCondition() {
|
||||||
|
|
||||||
// Just in case player already lost
|
// Just in case player already lost
|
||||||
if (this.getOutcome() != null) {
|
if (this.getOutcome() != null) {
|
||||||
return this.getOutcome().lossState != null;
|
return this.getOutcome().lossState != null;
|
||||||
@@ -2120,12 +2111,12 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
|
|
||||||
if (game.getRules().hasAppliedVariant(GameType.Commander)) {
|
if (game.getRules().hasAppliedVariant(GameType.Commander)) {
|
||||||
Map<Card,Integer> cmdDmg = getCommanderDamage();
|
Map<Card,Integer> cmdDmg = getCommanderDamage();
|
||||||
for(Card c : cmdDmg.keySet())
|
for (Card c : cmdDmg.keySet()) {
|
||||||
{
|
if (cmdDmg.get(c) >= 21) {
|
||||||
if(cmdDmg.get(c) >= 21)
|
|
||||||
return this.loseConditionMet(GameLossReason.CommanderDamage, null);
|
return this.loseConditionMet(GameLossReason.CommanderDamage, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2272,7 +2263,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean isValid(final String restriction, final Player sourceController, final Card source) {
|
public final boolean isValid(final String restriction, final Player sourceController, final Card source) {
|
||||||
|
|
||||||
final String[] incR = restriction.split("\\.");
|
final String[] incR = restriction.split("\\.");
|
||||||
|
|
||||||
if (incR[0].equals("Opponent")) {
|
if (incR[0].equals("Opponent")) {
|
||||||
@@ -2663,7 +2653,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Predicates {
|
public static class Predicates {
|
||||||
|
|
||||||
public static final Predicate<Player> NOT_LOST = new Predicate<Player>() {
|
public static final Predicate<Player> NOT_LOST = new Predicate<Player>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Player p) {
|
public boolean apply(Player p) {
|
||||||
@@ -2673,14 +2662,12 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Accessors {
|
public static class Accessors {
|
||||||
|
|
||||||
public static Function<Player, String> FN_GET_NAME = new Function<Player, String>() {
|
public static Function<Player, String> FN_GET_NAME = new Function<Player, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String apply(Player input) {
|
public String apply(Player input) {
|
||||||
return input.getName();
|
return input.getName();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2696,34 +2683,37 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isMindSlaved() {
|
public final boolean isMindSlaved() {
|
||||||
return controller.getLobbyPlayer() != controllerCreator.getLobbyPlayer();
|
return mindSlaveMaster != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void releaseControl() {
|
public final Player getMindSlaveMaster() {
|
||||||
if ( controller == controllerCreator )
|
return mindSlaveMaster;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
public final void setMindSlaveMaster(Player mindSlaveMaster0) {
|
||||||
|
if (mindSlaveMaster == mindSlaveMaster0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mindSlaveMaster = mindSlaveMaster0;
|
||||||
|
|
||||||
|
if (mindSlaveMaster != null) {
|
||||||
|
LobbyPlayer oldLobbyPlayer = getLobbyPlayer();
|
||||||
|
controller = mindSlaveMaster.getLobbyPlayer().createControllerFor(this);
|
||||||
|
game.fireEvent(new GameEventPlayerControl(this, oldLobbyPlayer, getLobbyPlayer()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
controller = controllerCreator;
|
controller = controllerCreator;
|
||||||
game.fireEvent(new GameEventPlayerControl(this, getLobbyPlayer(), null));
|
game.fireEvent(new GameEventPlayerControl(this, getLobbyPlayer(), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setControllingPlayerController(PlayerController pc) {
|
|
||||||
LobbyPlayer oldController = getLobbyPlayer();
|
|
||||||
controller = pc;
|
|
||||||
game.fireEvent(new GameEventPlayerControl(this, oldController, pc.getLobbyPlayer()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOutcome(PlayerOutcome outcome) {
|
private void setOutcome(PlayerOutcome outcome) {
|
||||||
stats.setOutcome(outcome);
|
stats.setOutcome(outcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this method.
|
|
||||||
*/
|
|
||||||
public void onGameOver() {
|
public void onGameOver() {
|
||||||
if (null == stats.getOutcome()) {
|
if (null == stats.getOutcome()) {
|
||||||
|
setOutcome(PlayerOutcome.win());
|
||||||
setOutcome(PlayerOutcome.win()); // then won!
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2789,7 +2779,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return now.isPlayerTurn(this) && now.getPhase().isMain() && game.getStack().isEmpty();
|
return now.isPlayerTurn(this) && now.getPhase().isMain() && game.getStack().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* couldCastSorcery.
|
* couldCastSorcery.
|
||||||
@@ -2803,7 +2792,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
* @return a boolean .
|
* @return a boolean .
|
||||||
*/
|
*/
|
||||||
public boolean couldCastSorcery(final SpellAbility sa) {
|
public boolean couldCastSorcery(final SpellAbility sa) {
|
||||||
|
|
||||||
final Card source = sa.getRootAbility().getHostCard();
|
final Card source = sa.getRootAbility().getHostCard();
|
||||||
boolean onlyThis = true;
|
boolean onlyThis = true;
|
||||||
|
|
||||||
@@ -2821,10 +2809,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return onlyThis && now.isPlayerTurn(this) && now.getPhase().isMain();
|
return onlyThis && now.isPlayerTurn(this) && now.getPhase().isMain();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this method.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public final PlayerController getController() {
|
public final PlayerController getController() {
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
@@ -2878,12 +2862,10 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getStartingHandSize() {
|
public int getStartingHandSize() {
|
||||||
|
|
||||||
return this.startingHandSize;
|
return this.startingHandSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStartingHandSize(int shs) {
|
public void setStartingHandSize(int shs) {
|
||||||
|
|
||||||
this.startingHandSize = shs;
|
this.startingHandSize = shs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2892,8 +2874,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
* Takes the top plane of the planar deck and put it face up in the command zone.
|
* Takes the top plane of the planar deck and put it face up in the command zone.
|
||||||
* Then runs triggers.
|
* Then runs triggers.
|
||||||
*/
|
*/
|
||||||
public void planeswalk()
|
public void planeswalk() {
|
||||||
{
|
|
||||||
planeswalkTo(Arrays.asList(getZone(ZoneType.PlanarDeck).get(0)));
|
planeswalkTo(Arrays.asList(getZone(ZoneType.PlanarDeck).get(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2903,12 +2884,11 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
*
|
*
|
||||||
* @param destinations The planes to planeswalk to.
|
* @param destinations The planes to planeswalk to.
|
||||||
*/
|
*/
|
||||||
public void planeswalkTo(final List<Card> destinations)
|
public void planeswalkTo(final List<Card> destinations) {
|
||||||
{
|
|
||||||
System.out.println(this.getName() + ": planeswalk to " + destinations.toString());
|
System.out.println(this.getName() + ": planeswalk to " + destinations.toString());
|
||||||
currentPlanes.addAll(destinations);
|
currentPlanes.addAll(destinations);
|
||||||
|
|
||||||
for(Card c : currentPlanes) {
|
for (Card c : currentPlanes) {
|
||||||
getZone(ZoneType.PlanarDeck).remove(c);
|
getZone(ZoneType.PlanarDeck).remove(c);
|
||||||
getZone(ZoneType.Command).add(c);
|
getZone(ZoneType.Command).add(c);
|
||||||
}
|
}
|
||||||
@@ -2929,16 +2909,14 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
*
|
*
|
||||||
* Puts my currently active planes, if any, at the bottom of my planar deck.
|
* Puts my currently active planes, if any, at the bottom of my planar deck.
|
||||||
*/
|
*/
|
||||||
public void leaveCurrentPlane()
|
public void leaveCurrentPlane() {
|
||||||
{
|
if (!currentPlanes.isEmpty()) {
|
||||||
if(!currentPlanes.isEmpty())
|
|
||||||
{
|
|
||||||
//Run PlaneswalkedFrom triggers here.
|
//Run PlaneswalkedFrom triggers here.
|
||||||
HashMap<String,Object> runParams = new HashMap<String,Object>();
|
HashMap<String,Object> runParams = new HashMap<String,Object>();
|
||||||
runParams.put("Card", new ArrayList<Card>(currentPlanes));
|
runParams.put("Card", new ArrayList<Card>(currentPlanes));
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.PlaneswalkedFrom, runParams,false);
|
game.getTriggerHandler().runTrigger(TriggerType.PlaneswalkedFrom, runParams,false);
|
||||||
|
|
||||||
for(Card c : currentPlanes) {
|
for (Card c : currentPlanes) {
|
||||||
game.getZoneOf(c).remove(c);
|
game.getZoneOf(c).remove(c);
|
||||||
c.clearControllers();
|
c.clearControllers();
|
||||||
getZone(ZoneType.PlanarDeck).add(c);
|
getZone(ZoneType.PlanarDeck).add(c);
|
||||||
@@ -2956,19 +2934,15 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
*
|
*
|
||||||
* Sets up the first plane of a round.
|
* Sets up the first plane of a round.
|
||||||
*/
|
*/
|
||||||
public void initPlane()
|
public void initPlane() {
|
||||||
{
|
|
||||||
Card firstPlane = null;
|
Card firstPlane = null;
|
||||||
while(true)
|
while (true) {
|
||||||
{
|
|
||||||
firstPlane = getZone(ZoneType.PlanarDeck).get(0);
|
firstPlane = getZone(ZoneType.PlanarDeck).get(0);
|
||||||
getZone(ZoneType.PlanarDeck).remove(firstPlane);
|
getZone(ZoneType.PlanarDeck).remove(firstPlane);
|
||||||
if(firstPlane.getType().contains("Phenomenon"))
|
if (firstPlane.getType().contains("Phenomenon")) {
|
||||||
{
|
|
||||||
getZone(ZoneType.PlanarDeck).add(firstPlane);
|
getZone(ZoneType.PlanarDeck).add(firstPlane);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
currentPlanes.add(firstPlane);
|
currentPlanes.add(firstPlane);
|
||||||
getZone(ZoneType.Command).add(firstPlane);
|
getZone(ZoneType.Command).add(firstPlane);
|
||||||
break;
|
break;
|
||||||
@@ -3034,7 +3008,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSkippingDraw() {
|
public boolean isSkippingDraw() {
|
||||||
|
|
||||||
if (hasKeyword("Skip your next draw step.")) {
|
if (hasKeyword("Skip your next draw step.")) {
|
||||||
removeKeyword("Skip your next draw step.");
|
removeKeyword("Skip your next draw step.");
|
||||||
return true;
|
return true;
|
||||||
@@ -3047,20 +3020,14 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInboundToken(Card c)
|
public void addInboundToken(Card c) {
|
||||||
{
|
|
||||||
inboundTokens.add(c);
|
inboundTokens.add(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeInboundToken(Card c)
|
public void removeInboundToken(Card c) {
|
||||||
{
|
|
||||||
inboundTokens.remove(c);
|
inboundTokens.remove(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this type.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private final class MiracleTrigger extends Ability {
|
private final class MiracleTrigger extends Ability {
|
||||||
private final SpellAbility miracle;
|
private final SpellAbility miracle;
|
||||||
|
|
||||||
@@ -3083,9 +3050,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this method.
|
|
||||||
*/
|
|
||||||
public void onMulliganned() {
|
public void onMulliganned() {
|
||||||
game.fireEvent(new GameEventMulligan(this)); // quest listener may interfere here
|
game.fireEvent(new GameEventMulligan(this)); // quest listener may interfere here
|
||||||
final int newHand = getCardsIn(ZoneType.Hand).size();
|
final int newHand = getCardsIn(ZoneType.Hand).size();
|
||||||
@@ -3129,7 +3093,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initVariantsZones(RegisteredPlayer registeredPlayer) {
|
public void initVariantsZones(RegisteredPlayer registeredPlayer) {
|
||||||
|
|
||||||
PlayerZone bf = getZone(ZoneType.Battlefield);
|
PlayerZone bf = getZone(ZoneType.Battlefield);
|
||||||
Iterable<? extends IPaperCard> cards = registeredPlayer.getCardsOnBattlefield();
|
Iterable<? extends IPaperCard> cards = registeredPlayer.getCardsOnBattlefield();
|
||||||
if (cards != null) {
|
if (cards != null) {
|
||||||
@@ -3141,7 +3104,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlayerZone com = getZone(ZoneType.Command);
|
PlayerZone com = getZone(ZoneType.Command);
|
||||||
// Mainly for avatar, but might find something else here
|
// Mainly for avatar, but might find something else here
|
||||||
for (final IPaperCard cp : registeredPlayer.getCardsInCommand()) {
|
for (final IPaperCard cp : registeredPlayer.getCardsInCommand()) {
|
||||||
@@ -3150,30 +3112,30 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
|
|
||||||
// Schemes
|
// Schemes
|
||||||
List<Card> sd = new ArrayList<Card>();
|
List<Card> sd = new ArrayList<Card>();
|
||||||
for(IPaperCard cp : registeredPlayer.getSchemes())
|
for (IPaperCard cp : registeredPlayer.getSchemes()) {
|
||||||
sd.add(Card.fromPaperCard(cp, this));
|
sd.add(Card.fromPaperCard(cp, this));
|
||||||
if ( !sd.isEmpty()) {
|
}
|
||||||
for(Card c : sd) {
|
if (!sd.isEmpty()) {
|
||||||
|
for (Card c : sd) {
|
||||||
getZone(ZoneType.SchemeDeck).add(c);
|
getZone(ZoneType.SchemeDeck).add(c);
|
||||||
}
|
}
|
||||||
getZone(ZoneType.SchemeDeck).shuffle();
|
getZone(ZoneType.SchemeDeck).shuffle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Planes
|
// Planes
|
||||||
List<Card> l = new ArrayList<Card>();
|
List<Card> l = new ArrayList<Card>();
|
||||||
for(IPaperCard cp : registeredPlayer.getPlanes())
|
for (IPaperCard cp : registeredPlayer.getPlanes()) {
|
||||||
l.add(Card.fromPaperCard(cp, this));
|
l.add(Card.fromPaperCard(cp, this));
|
||||||
if ( !l.isEmpty() ) {
|
}
|
||||||
for(Card c : l) {
|
if (!l.isEmpty()) {
|
||||||
|
for (Card c : l) {
|
||||||
getZone(ZoneType.PlanarDeck).add(c);
|
getZone(ZoneType.PlanarDeck).add(c);
|
||||||
}
|
}
|
||||||
getZone(ZoneType.PlanarDeck).shuffle();
|
getZone(ZoneType.PlanarDeck).shuffle();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commander
|
// Commander
|
||||||
if(registeredPlayer.getCommander() != null)
|
if (registeredPlayer.getCommander() != null) {
|
||||||
{
|
|
||||||
Card cmd = Card.fromPaperCard(registeredPlayer.getCommander(), this);
|
Card cmd = Card.fromPaperCard(registeredPlayer.getCommander(), this);
|
||||||
cmd.setCommander(true);
|
cmd.setCommander(true);
|
||||||
com.add(cmd);
|
com.add(cmd);
|
||||||
@@ -3200,7 +3162,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
|
|
||||||
getZone(ZoneType.Command).add(eff);
|
getZone(ZoneType.Command).add(eff);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeOwnership(Card card) {
|
public void changeOwnership(Card card) {
|
||||||
|
|||||||
Reference in New Issue
Block a user