mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Refactor StaticAbilityCantPhaseIn and StaticAbilityCantPhaseOut into StaticAbilityCantPhase (#4727)
This commit is contained in:
@@ -5467,11 +5467,11 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
}
|
||||
|
||||
private boolean switchPhaseState(final boolean fromUntapStep) {
|
||||
if (isPhasedOut() && StaticAbilityCantPhaseIn.cantPhaseIn(this)) {
|
||||
if (isPhasedOut() && StaticAbilityCantPhase.cantPhaseIn(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isPhasedOut() && StaticAbilityCantPhaseOut.cantPhaseOut(this)) {
|
||||
if (!isPhasedOut() && StaticAbilityCantPhase.cantPhaseOut(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ import forge.game.keyword.KeywordInterface;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerController.BinaryChoiceType;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.staticability.StaticAbilityCantPhaseOut;
|
||||
import forge.game.staticability.StaticAbilityCantPhase;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
@@ -290,7 +290,7 @@ public class Untap extends Phase {
|
||||
// and indirectly, it just phases out indirectly.
|
||||
if (c.isAttachment()) {
|
||||
final Card ent = c.getAttachedTo();
|
||||
if (ent != null && list.contains(ent) && !StaticAbilityCantPhaseOut.cantPhaseOut(ent)) {
|
||||
if (ent != null && list.contains(ent) && !StaticAbilityCantPhase.cantPhaseOut(ent)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package forge.game.staticability;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class StaticAbilityCantPhase {
|
||||
|
||||
static String MODE_CANT_PHASE_IN = "CantPhaseIn";
|
||||
static String MODE_CANT_PHASE_OUT = "CantPhaseOut";
|
||||
|
||||
static public boolean cantPhaseIn(Card card) {
|
||||
return cantPhase(card, MODE_CANT_PHASE_IN);
|
||||
}
|
||||
|
||||
static public boolean cantPhaseOut(Card card) {
|
||||
return cantPhase(card, MODE_CANT_PHASE_OUT);
|
||||
}
|
||||
|
||||
static private boolean cantPhase(Card card, String mode) {
|
||||
final Game game = card.getGame();
|
||||
for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) {
|
||||
for (final StaticAbility stAb : ca.getStaticAbilities()) {
|
||||
if (!stAb.checkConditions(mode)) {
|
||||
continue;
|
||||
}
|
||||
if (applyCantPhase(stAb, card)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static private boolean applyCantPhase(StaticAbility stAb, Card card) {
|
||||
return stAb.matchesValidParam("ValidCard", card);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package forge.game.staticability;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class StaticAbilityCantPhaseIn {
|
||||
|
||||
static String MODE = "CantPhaseIn";
|
||||
|
||||
static public boolean cantPhaseIn(Card card) {
|
||||
final Game game = card.getGame();
|
||||
for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) {
|
||||
for (final StaticAbility stAb : ca.getStaticAbilities()) {
|
||||
if (!stAb.checkConditions(MODE)) {
|
||||
continue;
|
||||
}
|
||||
if (applyCantPhaseIn(stAb, card)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static public boolean applyCantPhaseIn(StaticAbility stAb, Card card) {
|
||||
if (!stAb.matchesValidParam("ValidCard", card)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package forge.game.staticability;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class StaticAbilityCantPhaseOut {
|
||||
|
||||
static String MODE = "CantPhaseOut";
|
||||
|
||||
static public boolean cantPhaseOut(Card card) {
|
||||
final Game game = card.getGame();
|
||||
for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) {
|
||||
for (final StaticAbility stAb : ca.getStaticAbilities()) {
|
||||
if (!stAb.checkConditions(MODE)) {
|
||||
continue;
|
||||
}
|
||||
if (applyCantPhaseOut(stAb, card)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static public boolean applyCantPhaseOut(StaticAbility stAb, Card card) {
|
||||
if (!stAb.matchesValidParam("ValidCard", card)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user