mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Remove setStateAll effect,
Removed duplicate code in SetState Removed flipped variable from Card class - it will use current state to determine its flipped state
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -13645,7 +13645,6 @@ src/main/java/forge/card/ability/ai/SacrificeAi.java -text
|
|||||||
src/main/java/forge/card/ability/ai/SacrificeAllAi.java -text
|
src/main/java/forge/card/ability/ai/SacrificeAllAi.java -text
|
||||||
src/main/java/forge/card/ability/ai/ScryAi.java -text
|
src/main/java/forge/card/ability/ai/ScryAi.java -text
|
||||||
src/main/java/forge/card/ability/ai/SetStateAi.java -text
|
src/main/java/forge/card/ability/ai/SetStateAi.java -text
|
||||||
src/main/java/forge/card/ability/ai/SetStateAllAi.java -text
|
|
||||||
src/main/java/forge/card/ability/ai/ShuffleAi.java -text
|
src/main/java/forge/card/ability/ai/ShuffleAi.java -text
|
||||||
src/main/java/forge/card/ability/ai/StoreSVarAi.java -text
|
src/main/java/forge/card/ability/ai/StoreSVarAi.java -text
|
||||||
src/main/java/forge/card/ability/ai/TapAi.java -text
|
src/main/java/forge/card/ability/ai/TapAi.java -text
|
||||||
@@ -13752,7 +13751,6 @@ src/main/java/forge/card/ability/effects/SacrificeAllEffect.java -text
|
|||||||
src/main/java/forge/card/ability/effects/SacrificeEffect.java -text
|
src/main/java/forge/card/ability/effects/SacrificeEffect.java -text
|
||||||
src/main/java/forge/card/ability/effects/ScryEffect.java -text
|
src/main/java/forge/card/ability/effects/ScryEffect.java -text
|
||||||
src/main/java/forge/card/ability/effects/SetInMotionEffect.java -text
|
src/main/java/forge/card/ability/effects/SetInMotionEffect.java -text
|
||||||
src/main/java/forge/card/ability/effects/SetStateAllEffect.java -text
|
|
||||||
src/main/java/forge/card/ability/effects/SetStateEffect.java -text
|
src/main/java/forge/card/ability/effects/SetStateEffect.java -text
|
||||||
src/main/java/forge/card/ability/effects/ShuffleEffect.java -text
|
src/main/java/forge/card/ability/effects/ShuffleEffect.java -text
|
||||||
src/main/java/forge/card/ability/effects/StoreSVarEffect.java -text
|
src/main/java/forge/card/ability/effects/StoreSVarEffect.java -text
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
|
|
||||||
private boolean isDoubleFaced = false;
|
private boolean isDoubleFaced = false;
|
||||||
private boolean isFlipCard = false;
|
private boolean isFlipCard = false;
|
||||||
private boolean isFlipped = false;
|
|
||||||
private CardCharacteristicName otherTransformable = null;
|
private CardCharacteristicName otherTransformable = null;
|
||||||
|
|
||||||
private ZoneType castFrom = null;
|
private ZoneType castFrom = null;
|
||||||
@@ -527,17 +526,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
* @return the flipped
|
* @return the flipped
|
||||||
*/
|
*/
|
||||||
public final boolean isFlipped() {
|
public final boolean isFlipped() {
|
||||||
return this.isFlipped;
|
return curCharacteristics == CardCharacteristicName.Flipped;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a cards flipped status.
|
|
||||||
*
|
|
||||||
* @param newStatus
|
|
||||||
* boolean with new flipped status
|
|
||||||
*/
|
|
||||||
public final void setFlipStaus(final boolean newStatus) {
|
|
||||||
this.isFlipped = newStatus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ import forge.card.ability.ai.SacrificeAi;
|
|||||||
import forge.card.ability.ai.SacrificeAllAi;
|
import forge.card.ability.ai.SacrificeAllAi;
|
||||||
import forge.card.ability.ai.ScryAi;
|
import forge.card.ability.ai.ScryAi;
|
||||||
import forge.card.ability.ai.SetStateAi;
|
import forge.card.ability.ai.SetStateAi;
|
||||||
import forge.card.ability.ai.SetStateAllAi;
|
|
||||||
import forge.card.ability.ai.ShuffleAi;
|
import forge.card.ability.ai.ShuffleAi;
|
||||||
import forge.card.ability.ai.StoreSVarAi;
|
import forge.card.ability.ai.StoreSVarAi;
|
||||||
import forge.card.ability.ai.TapAi;
|
import forge.card.ability.ai.TapAi;
|
||||||
@@ -199,7 +198,6 @@ public enum ApiType {
|
|||||||
SetInMotion (SetInMotionEffect.class, AlwaysPlayAi.class),
|
SetInMotion (SetInMotionEffect.class, AlwaysPlayAi.class),
|
||||||
SetLife (LifeSetEffect.class, LifeSetAi.class),
|
SetLife (LifeSetEffect.class, LifeSetAi.class),
|
||||||
SetState (SetStateEffect.class, SetStateAi.class),
|
SetState (SetStateEffect.class, SetStateAi.class),
|
||||||
SetStateAll (SetStateAllEffect.class, SetStateAllAi.class),
|
|
||||||
Shuffle (ShuffleEffect.class, ShuffleAi.class),
|
Shuffle (ShuffleEffect.class, ShuffleAi.class),
|
||||||
StoreSVar (StoreSVarEffect.class, StoreSVarAi.class),
|
StoreSVar (StoreSVarEffect.class, StoreSVarAi.class),
|
||||||
Tap (TapEffect.class, TapAi.class),
|
Tap (TapEffect.class, TapAi.class),
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
package forge.card.ability.ai;
|
|
||||||
|
|
||||||
|
|
||||||
import forge.card.ability.SpellAbilityAi;
|
|
||||||
import forge.card.spellability.SpellAbility;
|
|
||||||
import forge.game.player.AIPlayer;
|
|
||||||
|
|
||||||
public class SetStateAllAi extends SpellAbilityAi {
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected boolean canPlayAI(AIPlayer aiPlayer, SpellAbility sa) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean chkAIDrawback(SpellAbility sa, AIPlayer aiPlayer) {
|
|
||||||
// Gross generalization, but this always considers alternate
|
|
||||||
// states more powerful
|
|
||||||
if (sa.getSourceCard().isInAlternateState()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected boolean doTriggerAINoCost(AIPlayer aiPlayer, SpellAbility sa, boolean mandatory) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
package forge.card.ability.effects;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import forge.Card;
|
|
||||||
import forge.CardCharacteristicName;
|
|
||||||
import forge.CardLists;
|
|
||||||
import forge.Singletons;
|
|
||||||
import forge.card.ability.AbilityUtils;
|
|
||||||
import forge.card.ability.SpellAbilityEffect;
|
|
||||||
import forge.card.spellability.SpellAbility;
|
|
||||||
import forge.card.spellability.Target;
|
|
||||||
import forge.game.player.Player;
|
|
||||||
import forge.game.zone.ZoneType;
|
|
||||||
|
|
||||||
public class SetStateAllEffect extends SpellAbilityEffect {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resolve(SpellAbility sa) {
|
|
||||||
|
|
||||||
final Card card = sa.getSourceCard();
|
|
||||||
|
|
||||||
final Target tgt = sa.getTarget();
|
|
||||||
Player targetPlayer = null;
|
|
||||||
if (tgt != null) {
|
|
||||||
targetPlayer = tgt.getTargetPlayers().get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
String valid = "";
|
|
||||||
|
|
||||||
if (sa.hasParam("ValidCards")) {
|
|
||||||
valid = sa.getParam("ValidCards");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ugh. If calculateAmount needs to be called with DestroyAll it _needs_
|
|
||||||
// to use the X variable
|
|
||||||
// We really need a better solution to this
|
|
||||||
if (valid.contains("X")) {
|
|
||||||
valid = valid.replace("X", Integer.toString(AbilityUtils.calculateAmount(card, "X", sa)));
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
|
||||||
|
|
||||||
if (targetPlayer != null) {
|
|
||||||
list = CardLists.filterControlledBy(list, targetPlayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
list = AbilityUtils.filterListByType(list, valid, sa);
|
|
||||||
|
|
||||||
final boolean remChanged = sa.hasParam("RememberChanged");
|
|
||||||
if (remChanged) {
|
|
||||||
card.clearRemembered();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Card c : list) {
|
|
||||||
final String mode = sa.getParam("Mode");
|
|
||||||
if (mode != null) {
|
|
||||||
if (mode.equals("Transform")) {
|
|
||||||
if (c.hasKeyword("CARDNAME can't transform")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c.isDoubleFaced()) {
|
|
||||||
if (c.getCurState() == CardCharacteristicName.Original) {
|
|
||||||
if (c.changeToState(CardCharacteristicName.Transformed) && remChanged) {
|
|
||||||
card.addRemembered(c);
|
|
||||||
}
|
|
||||||
} else if (c.getCurState() == CardCharacteristicName.Transformed) {
|
|
||||||
if (c.changeToState(CardCharacteristicName.Original)) {
|
|
||||||
if (remChanged) {
|
|
||||||
card.addRemembered(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (mode.equals("Flip")) {
|
|
||||||
if (c.isFlipCard()) {
|
|
||||||
if (c.getCurState() == CardCharacteristicName.Original) {
|
|
||||||
if (c.changeToState(CardCharacteristicName.Flipped)) {
|
|
||||||
c.setFlipStaus(true);
|
|
||||||
if (remChanged) {
|
|
||||||
card.addRemembered(tgt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (c.getCurState() == CardCharacteristicName.Flipped) {
|
|
||||||
if (c.changeToState(CardCharacteristicName.Original)) {
|
|
||||||
c.setFlipStaus(false);
|
|
||||||
if (remChanged) {
|
|
||||||
card.addRemembered(tgt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (mode.equals("TurnFace")) {
|
|
||||||
if (c.getCurState() == CardCharacteristicName.Original) {
|
|
||||||
if (c.turnFaceDown() && remChanged) {
|
|
||||||
card.addRemembered(tgt);
|
|
||||||
}
|
|
||||||
} else if (c.getCurState() == CardCharacteristicName.FaceDown) {
|
|
||||||
if (c.turnFaceUp() && remChanged) {
|
|
||||||
card.addRemembered(tgt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
c.changeToState(CardCharacteristicName.smartValueOf(sa.getParam("NewState")));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getStackDescription(SpellAbility sa) {
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
if (sa.hasParam("Mode")) {
|
|
||||||
sb.append(sa.getParam("Mode"));
|
|
||||||
} else {
|
|
||||||
sb.append(sa.getParam("NewState"));
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append(" permanents.");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -48,77 +48,50 @@ public class SetStateEffect extends SpellAbilityEffect {
|
|||||||
final boolean remChanged = sa.hasParam("RememberChanged");
|
final boolean remChanged = sa.hasParam("RememberChanged");
|
||||||
|
|
||||||
for (final Card tgt : tgtCards) {
|
for (final Card tgt : tgtCards) {
|
||||||
if (sa.getTarget() != null) {
|
if (sa.getTarget() != null && !tgt.canBeTargetedBy(sa)) {
|
||||||
if (!tgt.canBeTargetedBy(sa)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean hasTransformed = changeCardState(tgt, sa.getParam("Mode"), sa.getParam("NewState"));
|
||||||
|
if ( hasTransformed && remChanged) {
|
||||||
|
host.addRemembered(tgt);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String mode = sa.getParam("Mode");
|
private boolean changeCardState(final Card tgt, final String mode, final String customState) {
|
||||||
|
if (mode == null)
|
||||||
|
return tgt.changeToState(CardCharacteristicName.smartValueOf(customState));
|
||||||
|
|
||||||
if (mode != null) {
|
// flip and face-down don't overlap. That is there is no chance to turn face down a flipped permanent
|
||||||
if (mode.equals("Transform")) {
|
// and then any effect have it turn upface again and demand its former flip state to be restored
|
||||||
|
// Proof: Morph cards never have ability that makes them flip, Ixidron does not suppose cards to be turned face up again,
|
||||||
|
// Illusionary Mask affects cards in hand.
|
||||||
|
CardCharacteristicName oldState = tgt.getCurState();
|
||||||
|
if (mode.equals("Transform") && tgt.isDoubleFaced()) {
|
||||||
if (tgt.hasKeyword("CARDNAME can't transform")) {
|
if (tgt.hasKeyword("CARDNAME can't transform")) {
|
||||||
continue;
|
return false;
|
||||||
}
|
|
||||||
if (tgt.isDoubleFaced()) {
|
|
||||||
if (tgt.getCurState() == CardCharacteristicName.Original) {
|
|
||||||
if (tgt.changeToState(CardCharacteristicName.Transformed)) {
|
|
||||||
if (remChanged) {
|
|
||||||
host.addRemembered(tgt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (tgt.getCurState() == CardCharacteristicName.Transformed) {
|
|
||||||
if (tgt.changeToState(CardCharacteristicName.Original)) {
|
|
||||||
if (remChanged) {
|
|
||||||
host.addRemembered(tgt);
|
|
||||||
}
|
}
|
||||||
|
CardCharacteristicName destState = oldState == CardCharacteristicName.Transformed ? CardCharacteristicName.Original : CardCharacteristicName.Transformed;
|
||||||
|
return tgt.changeToState(destState);
|
||||||
|
|
||||||
}
|
} else if (mode.equals("Flip") && tgt.isFlipCard()) {
|
||||||
}
|
CardCharacteristicName destState = oldState == CardCharacteristicName.Flipped ? CardCharacteristicName.Original : CardCharacteristicName.Flipped;
|
||||||
}
|
return tgt.changeToState(destState);
|
||||||
} else if (mode.equals("Flip")) {
|
|
||||||
if (tgt.isFlipCard()) {
|
|
||||||
if (tgt.getCurState() == CardCharacteristicName.Original) {
|
|
||||||
if (tgt.changeToState(CardCharacteristicName.Flipped)) {
|
|
||||||
host.setFlipStaus(true);
|
|
||||||
if (remChanged) {
|
|
||||||
host.addRemembered(tgt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (tgt.getCurState() == CardCharacteristicName.Flipped) {
|
|
||||||
if (tgt.changeToState(CardCharacteristicName.Original)) {
|
|
||||||
host.setFlipStaus(false);
|
|
||||||
if (remChanged) {
|
|
||||||
host.addRemembered(tgt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (mode.equals("TurnFace")) {
|
} else if (mode.equals("TurnFace")) {
|
||||||
if (tgt.getCurState() == CardCharacteristicName.Original) {
|
if (oldState == CardCharacteristicName.Original) {
|
||||||
// Reset cloned state if Vesuvan Shapeshifter
|
// Reset cloned state if Vesuvan Shapeshifter
|
||||||
if (tgt.isCloned() && tgt.getState(CardCharacteristicName.Cloner).getName().equals("Vesuvan Shapeshifter")) {
|
if (tgt.isCloned() && tgt.getState(CardCharacteristicName.Cloner).getName().equals("Vesuvan Shapeshifter")) {
|
||||||
tgt.switchStates(CardCharacteristicName.Cloner, CardCharacteristicName.Original);
|
tgt.switchStates(CardCharacteristicName.Cloner, CardCharacteristicName.Original);
|
||||||
tgt.setState(CardCharacteristicName.Original);
|
tgt.setState(CardCharacteristicName.Original);
|
||||||
tgt.clearStates(CardCharacteristicName.Cloner);
|
tgt.clearStates(CardCharacteristicName.Cloner);
|
||||||
}
|
}
|
||||||
if (tgt.turnFaceDown() && remChanged) {
|
return tgt.turnFaceDown();
|
||||||
host.addRemembered(tgt);
|
} else if (oldState == CardCharacteristicName.FaceDown) {
|
||||||
}
|
return tgt.turnFaceUp();
|
||||||
} else if (tgt.getCurState() == CardCharacteristicName.FaceDown) {
|
|
||||||
if (tgt.turnFaceUp() && remChanged) {
|
|
||||||
host.addRemembered(tgt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
} else {
|
|
||||||
tgt.changeToState(CardCharacteristicName.smartValueOf(sa.getParam("NewState")));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,10 +151,6 @@ public class GameAction {
|
|||||||
c.clearStates(CardCharacteristicName.Flipped);
|
c.clearStates(CardCharacteristicName.Flipped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// reset flip status when card leaves battlefield
|
|
||||||
if (zoneFrom.is(ZoneType.Battlefield)) {
|
|
||||||
c.setFlipStaus(false);
|
|
||||||
}
|
|
||||||
copied = CardFactory.copyCard(c);
|
copied = CardFactory.copyCard(c);
|
||||||
copied.setUnearthed(c.isUnearthed());
|
copied.setUnearthed(c.isUnearthed());
|
||||||
copied.setTapped(false);
|
copied.setTapped(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user