mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Merge branch 'fixCommanderReplacement' into 'master'
commander LTB triggers before returning to command zone Closes #1493 See merge request core-developers/forge!3565
This commit is contained in:
@@ -33,6 +33,7 @@ import forge.game.keyword.KeywordInterface;
|
|||||||
import forge.game.mulligan.MulliganService;
|
import forge.game.mulligan.MulliganService;
|
||||||
import forge.game.player.GameLossReason;
|
import forge.game.player.GameLossReason;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
|
import forge.game.player.PlayerActionConfirmMode;
|
||||||
import forge.game.replacement.ReplacementEffect;
|
import forge.game.replacement.ReplacementEffect;
|
||||||
import forge.game.replacement.ReplacementResult;
|
import forge.game.replacement.ReplacementResult;
|
||||||
import forge.game.replacement.ReplacementType;
|
import forge.game.replacement.ReplacementType;
|
||||||
@@ -539,6 +540,10 @@ public class GameAction {
|
|||||||
AttachEffect.attachAuraOnIndirectEnterBattlefield(c);
|
AttachEffect.attachAuraOnIndirectEnterBattlefield(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c.isCommander()) {
|
||||||
|
c.setMoveToCommandZone(true);
|
||||||
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1048,6 +1053,17 @@ public class GameAction {
|
|||||||
checkAgain = true;
|
checkAgain = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (game.getRules().hasAppliedVariant(GameType.Commander) && !checkAgain) {
|
||||||
|
Iterable<Card> cards = p.getCardsIn(ZoneType.Graveyard).threadSafeIterable();
|
||||||
|
for (final Card c : cards) {
|
||||||
|
checkAgain |= stateBasedAction903_9a(c);
|
||||||
|
}
|
||||||
|
cards = p.getCardsIn(ZoneType.Exile).threadSafeIterable();
|
||||||
|
for (final Card c : cards) {
|
||||||
|
checkAgain |= stateBasedAction903_9a(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (handlePlaneswalkerRule(p, table)) {
|
if (handlePlaneswalkerRule(p, table)) {
|
||||||
checkAgain = true;
|
checkAgain = true;
|
||||||
}
|
}
|
||||||
@@ -1142,6 +1158,17 @@ public class GameAction {
|
|||||||
return checkAgain;
|
return checkAgain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean stateBasedAction903_9a(Card c) {
|
||||||
|
if (c.isCommander() && c.canMoveToCommandZone()) {
|
||||||
|
c.setMoveToCommandZone(false);
|
||||||
|
if (c.getOwner().getController().confirmAction(c.getSpellPermanent(), PlayerActionConfirmMode.ChangeZoneToAltDestination, c.getName() + ": If a commander is in a graveyard or in exile and that card was put into that zone since the last time state-based actions were checked, its owner may put it into the command zone.")) {
|
||||||
|
moveTo(c.getOwner().getZone(ZoneType.Command), c, null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean stateBasedAction704_5r(Card c) {
|
private boolean stateBasedAction704_5r(Card c) {
|
||||||
boolean checkAgain = false;
|
boolean checkAgain = false;
|
||||||
final CounterType p1p1 = CounterType.get(CounterEnumType.P1P1);
|
final CounterType p1p1 = CounterType.get(CounterEnumType.P1P1);
|
||||||
|
|||||||
@@ -153,6 +153,8 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
|||||||
private final Map<Card, Integer> assignedDamageMap = Maps.newTreeMap();
|
private final Map<Card, Integer> assignedDamageMap = Maps.newTreeMap();
|
||||||
|
|
||||||
private boolean isCommander = false;
|
private boolean isCommander = false;
|
||||||
|
private boolean canMoveToCommandZone = false;
|
||||||
|
|
||||||
private boolean startsGameInPlay = false;
|
private boolean startsGameInPlay = false;
|
||||||
private boolean drawnThisTurn = false;
|
private boolean drawnThisTurn = false;
|
||||||
private boolean becameTargetThisTurn = false;
|
private boolean becameTargetThisTurn = false;
|
||||||
@@ -5999,6 +6001,13 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
|||||||
view.updateCommander(this);
|
view.updateCommander(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canMoveToCommandZone() {
|
||||||
|
return canMoveToCommandZone;
|
||||||
|
}
|
||||||
|
public void setMoveToCommandZone(boolean b) {
|
||||||
|
canMoveToCommandZone = b;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSplitStateToPlayAbility(final SpellAbility sa) {
|
public void setSplitStateToPlayAbility(final SpellAbility sa) {
|
||||||
CardStateName stateName = sa.getCardState();
|
CardStateName stateName = sa.getCardState();
|
||||||
if (hasState(stateName)) {
|
if (hasState(stateName)) {
|
||||||
|
|||||||
@@ -3124,7 +3124,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
if (game.getRules().hasAppliedVariant(GameType.TinyLeaders)) {
|
if (game.getRules().hasAppliedVariant(GameType.TinyLeaders)) {
|
||||||
moved += " | Destination$ Graveyard,Exile | Description$ If a commander would be put into its owner's graveyard or exile from anywhere, that player may put it into the command zone instead.";
|
moved += " | Destination$ Graveyard,Exile | Description$ If a commander would be put into its owner's graveyard or exile from anywhere, that player may put it into the command zone instead.";
|
||||||
} else {
|
} else {
|
||||||
moved += " | Destination$ Graveyard,Exile,Hand,Library | Description$ If a commander would be exiled or put into hand, graveyard, or library from anywhere, that player may put it into the command zone instead.";
|
// rule 903.9b
|
||||||
|
moved += " | Destination$ Hand,Library | Description$ If a commander would be put into its owner’s hand or library from anywhere, its owner may put it into the command zone instead.";
|
||||||
}
|
}
|
||||||
eff.addReplacementEffect(ReplacementHandler.parseReplacement(moved, eff, true));
|
eff.addReplacementEffect(ReplacementHandler.parseReplacement(moved, eff, true));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user