mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Attempt at reducing code when cards get created/change zone (should be watched).
- Removed a lot of suppressions of TriggerType.Transformed by adding a new setState function that does not run triggers at all.
This commit is contained in:
@@ -254,6 +254,31 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
this.characteristicsMap.put(CardCharactersticName.FaceDown, CardUtil.getFaceDownCharacteristic());
|
this.characteristicsMap.put(CardCharactersticName.FaceDown, CardUtil.getFaceDownCharacteristic());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the state.
|
||||||
|
*
|
||||||
|
* @param state
|
||||||
|
* the state
|
||||||
|
* @return true, if successful
|
||||||
|
*/
|
||||||
|
public boolean changeToState(final CardCharactersticName state) {
|
||||||
|
|
||||||
|
CardCharactersticName cur = this.curCharacteristics;
|
||||||
|
|
||||||
|
if (!setState(state)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((cur == CardCharactersticName.Original && state == CardCharactersticName.Transformed)
|
||||||
|
|| (cur == CardCharactersticName.Transformed && state == CardCharactersticName.Original)) {
|
||||||
|
HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
|
runParams.put("Transformer", this);
|
||||||
|
AllZone.getTriggerHandler().runTrigger(TriggerType.Transformed, runParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the state.
|
* Sets the state.
|
||||||
*
|
*
|
||||||
@@ -275,17 +300,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardCharactersticName cur = this.curCharacteristics;
|
|
||||||
|
|
||||||
this.curCharacteristics = state;
|
this.curCharacteristics = state;
|
||||||
|
|
||||||
if ((cur == CardCharactersticName.Original && state == CardCharactersticName.Transformed)
|
|
||||||
|| (cur == CardCharactersticName.Transformed && state == CardCharactersticName.Original)) {
|
|
||||||
HashMap<String, Object> runParams = new HashMap<String, Object>();
|
|
||||||
runParams.put("Transformer", this);
|
|
||||||
AllZone.getTriggerHandler().runTrigger(TriggerType.Transformed, runParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,7 +355,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public boolean turnFaceDown() {
|
public boolean turnFaceDown() {
|
||||||
if (!this.isDoubleFaced) {
|
if (!this.isDoubleFaced) {
|
||||||
this.preTFDCharacteristic = this.curCharacteristics;
|
this.preTFDCharacteristic = this.curCharacteristics;
|
||||||
return this.setState(CardCharactersticName.FaceDown);
|
return this.changeToState(CardCharactersticName.FaceDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -352,7 +368,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
*/
|
*/
|
||||||
public boolean turnFaceUp() {
|
public boolean turnFaceUp() {
|
||||||
if (this.curCharacteristics == CardCharactersticName.FaceDown) {
|
if (this.curCharacteristics == CardCharactersticName.FaceDown) {
|
||||||
return this.setState(this.preTFDCharacteristic);
|
return this.changeToState(this.preTFDCharacteristic);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -392,6 +392,11 @@ public class CardReader implements Runnable {
|
|||||||
|
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
|
if (ignoreTheRest) {
|
||||||
|
continue;
|
||||||
|
} // have to deplete the iterator
|
||||||
|
// otherwise the underlying class would close its stream on finalize
|
||||||
|
// only
|
||||||
|
|
||||||
if ("End".equals(line)) {
|
if ("End".equals(line)) {
|
||||||
// have to deplete the iterator
|
// have to deplete the iterator
|
||||||
@@ -399,11 +404,6 @@ public class CardReader implements Runnable {
|
|||||||
continue;
|
continue;
|
||||||
// otherwise the underlying class would close its stream on finalize only
|
// otherwise the underlying class would close its stream on finalize only
|
||||||
}
|
}
|
||||||
if (ignoreTheRest) {
|
|
||||||
continue;
|
|
||||||
} // have to deplete the iterator
|
|
||||||
// otherwise the underlying class would close its stream on finalize
|
|
||||||
// only
|
|
||||||
|
|
||||||
if (line.isEmpty() || (line.charAt(0) == '#')) {
|
if (line.isEmpty() || (line.charAt(0) == '#')) {
|
||||||
continue;
|
continue;
|
||||||
@@ -413,7 +413,7 @@ public class CardReader implements Runnable {
|
|||||||
rulesReader.parseLine(line);
|
rulesReader.parseLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.startsWith("Name:")) {
|
if (line.startsWith("Name")) {
|
||||||
final String value = line.substring(5);
|
final String value = line.substring(5);
|
||||||
// System.out.println(s);
|
// System.out.println(s);
|
||||||
if ((mapToFill != null) && mapToFill.containsKey(value)) {
|
if ((mapToFill != null) && mapToFill.containsKey(value)) {
|
||||||
@@ -421,23 +421,23 @@ public class CardReader implements Runnable {
|
|||||||
} else {
|
} else {
|
||||||
card.setName(value);
|
card.setName(value);
|
||||||
}
|
}
|
||||||
} else if (line.startsWith("ManaCost:")) {
|
} else if (line.startsWith("ManaCost")) {
|
||||||
final String value = line.substring(9);
|
final String value = line.substring(9);
|
||||||
// System.out.println(s);
|
// System.out.println(s);
|
||||||
if (!"no cost".equals(value)) {
|
if (!"no cost".equals(value)) {
|
||||||
card.setManaCost(new CardManaCost(new ManaCostParser(value)));
|
card.setManaCost(new CardManaCost(new ManaCostParser(value)));
|
||||||
}
|
}
|
||||||
} else if (line.startsWith("Types:")) {
|
} else if (line.startsWith("Types")) {
|
||||||
CardReader.addTypes(card, line.substring("Types:".length()));
|
CardReader.addTypes(card, line.substring(6));
|
||||||
} else if (line.startsWith("Text:")) {
|
} else if (line.startsWith("Text")) {
|
||||||
String value = line.substring("Text:".length());
|
String value = line.substring(5);
|
||||||
// if (!t.equals("no text"));
|
// if (!t.equals("no text"));
|
||||||
if ("no text".equals(value)) {
|
if ("no text".equals(value)) {
|
||||||
value = "";
|
value = "";
|
||||||
}
|
}
|
||||||
card.setText(value);
|
card.setText(value);
|
||||||
} else if (line.startsWith("PT:")) {
|
} else if (line.startsWith("PT")) {
|
||||||
final String value = line.substring("PT:".length());
|
final String value = line.substring(3);
|
||||||
final String[] powTough = value.split("/");
|
final String[] powTough = value.split("/");
|
||||||
int att;
|
int att;
|
||||||
if (powTough[0].contains("*")) {
|
if (powTough[0].contains("*")) {
|
||||||
@@ -457,14 +457,14 @@ public class CardReader implements Runnable {
|
|||||||
card.setBaseDefenseString(powTough[1]);
|
card.setBaseDefenseString(powTough[1]);
|
||||||
card.setBaseAttack(att);
|
card.setBaseAttack(att);
|
||||||
card.setBaseDefense(def);
|
card.setBaseDefense(def);
|
||||||
} else if (line.startsWith("Loyalty:")) {
|
} else if (line.startsWith("Loyalty")) {
|
||||||
final String[] splitStr = line.split(":");
|
final String[] splitStr = line.split(":");
|
||||||
final int loyal = Integer.parseInt(splitStr[1]);
|
final int loyal = Integer.parseInt(splitStr[1]);
|
||||||
card.setBaseLoyalty(loyal);
|
card.setBaseLoyalty(loyal);
|
||||||
} else if (line.startsWith("K:")) {
|
} else if (line.startsWith("K:")) {
|
||||||
final String value = line.substring(2);
|
final String value = line.substring(2);
|
||||||
card.addIntrinsicKeyword(value);
|
card.addIntrinsicKeyword(value);
|
||||||
} else if (line.startsWith("SVar:")) {
|
} else if (line.startsWith("SVar")) {
|
||||||
final String[] value = line.split(":", 3);
|
final String[] value = line.split(":", 3);
|
||||||
card.setSVar(value[1], value[2]);
|
card.setSVar(value[1], value[2]);
|
||||||
} else if (line.startsWith("A:")) {
|
} else if (line.startsWith("A:")) {
|
||||||
@@ -475,8 +475,8 @@ public class CardReader implements Runnable {
|
|||||||
card.addStaticAbilityString(line.substring(2));
|
card.addStaticAbilityString(line.substring(2));
|
||||||
} else if (line.startsWith("R:")) {
|
} else if (line.startsWith("R:")) {
|
||||||
card.addReplacementEffect(ReplacementHandler.parseReplacement(line.substring(2), card));
|
card.addReplacementEffect(ReplacementHandler.parseReplacement(line.substring(2), card));
|
||||||
} else if (line.startsWith("SetInfo:")) {
|
} else if (line.startsWith("SetInfo")) {
|
||||||
final String value = line.substring("SetInfo:".length());
|
final String value = line.substring(8);
|
||||||
card.addSet(new EditionInfo(value));
|
card.addSet(new EditionInfo(value));
|
||||||
// 8/18/11 11:08 PM
|
// 8/18/11 11:08 PM
|
||||||
} else if (line.equals("ALTERNATE")) {
|
} else if (line.equals("ALTERNATE")) {
|
||||||
@@ -489,8 +489,8 @@ public class CardReader implements Runnable {
|
|||||||
mode = card.isTransformable();
|
mode = card.isTransformable();
|
||||||
}
|
}
|
||||||
card.addAlternateState(mode);
|
card.addAlternateState(mode);
|
||||||
card.setState(mode);
|
card.changeToState(mode);
|
||||||
} else if (line.startsWith("AlternateMode:")) {
|
} else if (line.startsWith("AlternateMode")) {
|
||||||
//System.out.println(card.getName());
|
//System.out.println(card.getName());
|
||||||
final CardCharactersticName value = CardCharactersticName.smartValueOf(line.substring("AlternateMode:".length()));
|
final CardCharactersticName value = CardCharactersticName.smartValueOf(line.substring("AlternateMode:".length()));
|
||||||
if (value == CardCharactersticName.Flipped) {
|
if (value == CardCharactersticName.Flipped) {
|
||||||
@@ -500,8 +500,8 @@ public class CardReader implements Runnable {
|
|||||||
} else {
|
} else {
|
||||||
card.setTransformable(value);
|
card.setTransformable(value);
|
||||||
}
|
}
|
||||||
} else if (line.startsWith("Colors:")) {
|
} else if (line.startsWith("Colors")) {
|
||||||
final String value = line.substring("Colors:".length());
|
final String value = line.substring(7);
|
||||||
final ArrayList<CardColor> newCols = new ArrayList<CardColor>();
|
final ArrayList<CardColor> newCols = new ArrayList<CardColor>();
|
||||||
final CardColor newCol = new CardColor(card);
|
final CardColor newCol = new CardColor(card);
|
||||||
for (final String col : value.split(",")) {
|
for (final String col : value.split(",")) {
|
||||||
|
|||||||
@@ -33,11 +33,9 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import forge.card.CardCharacteristics;
|
import forge.card.CardCharacteristics;
|
||||||
import forge.card.CardManaCost;
|
import forge.card.CardManaCost;
|
||||||
import forge.card.EditionInfo;
|
import forge.card.EditionInfo;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.card.spellability.SpellAbilityList;
|
import forge.card.spellability.SpellAbilityList;
|
||||||
import forge.card.trigger.TriggerType;
|
|
||||||
import forge.control.input.InputPayManaCostUtil;
|
import forge.control.input.InputPayManaCostUtil;
|
||||||
import forge.game.zone.DefaultPlayerZone;
|
import forge.game.zone.DefaultPlayerZone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
@@ -912,14 +910,12 @@ public final class CardUtil {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
final CardCharactersticName state = c.getCurState();
|
final CardCharactersticName state = c.getCurState();
|
||||||
AllZone.getTriggerHandler().suppressMode(TriggerType.Transformed);
|
|
||||||
if (c.isInAlternateState()) {
|
if (c.isInAlternateState()) {
|
||||||
c.setState(CardCharactersticName.Original);
|
c.setState(CardCharactersticName.Original);
|
||||||
}
|
}
|
||||||
final Card res = AllZone.getCardFactory().copyCard(c);
|
final Card res = AllZone.getCardFactory().copyCard(c);
|
||||||
c.setState(state);
|
c.setState(state);
|
||||||
res.setState(state);
|
res.setState(state);
|
||||||
AllZone.getTriggerHandler().clearSuppression(TriggerType.Transformed);
|
|
||||||
res.setControllerObjects(c.getControllerObjects());
|
res.setControllerObjects(c.getControllerObjects());
|
||||||
res.addTempAttackBoost(c.getTempAttackBoost());
|
res.addTempAttackBoost(c.getTempAttackBoost());
|
||||||
res.addSemiPermanentAttackBoost(c.getSemiPermanentAttackBoost());
|
res.addSemiPermanentAttackBoost(c.getSemiPermanentAttackBoost());
|
||||||
@@ -964,10 +960,11 @@ public final class CardUtil {
|
|||||||
newCopy.setDoubleFaced(in.isDoubleFaced());
|
newCopy.setDoubleFaced(in.isDoubleFaced());
|
||||||
|
|
||||||
// Copy all states
|
// Copy all states
|
||||||
AllZone.getTriggerHandler().suppressMode(TriggerType.Transformed);
|
// Commented out by Sloth 2012/07/25
|
||||||
|
/*AllZone.getTriggerHandler().suppressMode(TriggerType.Transformed);
|
||||||
for (final CardCharactersticName state : in.getStates()) {
|
for (final CardCharactersticName state : in.getStates()) {
|
||||||
newCopy.addAlternateState(state);
|
newCopy.addAlternateState(state);
|
||||||
newCopy.setState(state);
|
newCopy.changeToState(state);
|
||||||
CardFactoryUtil.copyState(in, state, newCopy);
|
CardFactoryUtil.copyState(in, state, newCopy);
|
||||||
//Copies of full abilities not need in LKI copy
|
//Copies of full abilities not need in LKI copy
|
||||||
/*
|
/*
|
||||||
@@ -993,13 +990,13 @@ public final class CardUtil {
|
|||||||
newCopy.addSpellAbility(newSA);
|
newCopy.addSpellAbility(newSA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
for (int i = 0; i < newCopy.getStaticAbilityStrings().size(); i++) {
|
for (int i = 0; i < newCopy.getStaticAbilityStrings().size(); i++) {
|
||||||
newCopy.addStaticAbility(newCopy.getStaticAbilityStrings().get(i));
|
newCopy.addStaticAbility(newCopy.getStaticAbilityStrings().get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newCopy.setState(in.getCurState());
|
newCopy.changeToState(in.getCurState());
|
||||||
AllZone.getTriggerHandler().clearSuppression(TriggerType.Transformed);
|
AllZone.getTriggerHandler().clearSuppression(TriggerType.Transformed);*/
|
||||||
|
|
||||||
// I'm not sure if we really should be copying enchant/equip stuff over.
|
// I'm not sure if we really should be copying enchant/equip stuff over.
|
||||||
|
|
||||||
|
|||||||
@@ -140,16 +140,13 @@ public class GameAction {
|
|||||||
Card copied = null;
|
Card copied = null;
|
||||||
Card lastKnownInfo = null;
|
Card lastKnownInfo = null;
|
||||||
|
|
||||||
// Don't copy Tokens, Cards staying in same zone, or cards entering
|
// Don't copy Tokens, copy only cards leaving the battlefield
|
||||||
// Battlefield
|
if (c.isToken() || suppress || zoneTo.is(ZoneType.Battlefield) || !zoneFrom.is(ZoneType.Battlefield)) {
|
||||||
if (c.isToken() || suppress || zoneTo.is(ZoneType.Battlefield) || zoneTo.is(ZoneType.Stack)
|
|
||||||
|| (zoneFrom.is(ZoneType.Stack) && zoneTo.is(ZoneType.Battlefield))) {
|
|
||||||
lastKnownInfo = c;
|
lastKnownInfo = c;
|
||||||
copied = c;
|
copied = c;
|
||||||
} else {
|
} else {
|
||||||
lastKnownInfo = CardUtil.getLKICopy(c);
|
lastKnownInfo = CardUtil.getLKICopy(c);
|
||||||
|
|
||||||
AllZone.getTriggerHandler().suppressMode(TriggerType.Transformed);
|
|
||||||
if (c.isCloned()) {
|
if (c.isCloned()) {
|
||||||
c.switchStates(CardCharactersticName.Cloner, CardCharactersticName.Original);
|
c.switchStates(CardCharactersticName.Cloner, CardCharactersticName.Original);
|
||||||
c.setState(CardCharactersticName.Original);
|
c.setState(CardCharactersticName.Original);
|
||||||
@@ -162,20 +159,18 @@ public class GameAction {
|
|||||||
if (zoneFrom.is(ZoneType.Battlefield)) {
|
if (zoneFrom.is(ZoneType.Battlefield)) {
|
||||||
c.setFlipStaus(false);
|
c.setFlipStaus(false);
|
||||||
}
|
}
|
||||||
AllZone.getTriggerHandler().clearSuppression(TriggerType.Transformed);
|
|
||||||
copied = AllZone.getCardFactory().copyCard(c);
|
copied = AllZone.getCardFactory().copyCard(c);
|
||||||
copied.setUnearthed(c.isUnearthed());
|
copied.setUnearthed(c.isUnearthed());
|
||||||
copied.setTapped(false);
|
copied.setTapped(false);
|
||||||
|
for (final Trigger trigger : c.getTriggers()) {
|
||||||
|
trigger.setHostCard(copied);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c.wasSuspendCast()) {
|
if (c.wasSuspendCast()) {
|
||||||
copied = GameAction.addSuspendTriggers(c);
|
copied = GameAction.addSuspendTriggers(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Trigger trigger : c.getTriggers()) {
|
|
||||||
trigger.setHostCard(copied);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (suppress) {
|
if (suppress) {
|
||||||
AllZone.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
AllZone.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
||||||
}
|
}
|
||||||
@@ -224,17 +219,14 @@ public class GameAction {
|
|||||||
// remove all counters from the card if destination is not the
|
// remove all counters from the card if destination is not the
|
||||||
// battlefield
|
// battlefield
|
||||||
// UNLESS we're dealing with Skullbriar, the Walking Grave
|
// UNLESS we're dealing with Skullbriar, the Walking Grave
|
||||||
if (!zoneTo.is(ZoneType.Battlefield)) {
|
if (zoneFrom.is(ZoneType.Battlefield)) {
|
||||||
copied.setSuspendCast(false);
|
copied.setSuspendCast(false);
|
||||||
// remove all counters from the card if destination is not the battlefield
|
// remove all counters from the card if destination is not the battlefield
|
||||||
// UNLESS we're dealing with Skullbriar, the Walking Grave
|
// UNLESS we're dealing with Skullbriar, the Walking Grave
|
||||||
if (!(c.getName().equals("Skullbriar, the Walking Grave") && !zoneTo.is(ZoneType.Hand) && !zoneTo
|
if (zoneTo.is(ZoneType.Hand) || zoneTo.is(ZoneType.Library) || !c.getName().equals("Skullbriar, the Walking Grave")) {
|
||||||
.is(ZoneType.Library))) {
|
|
||||||
copied.clearCounters();
|
copied.clearCounters();
|
||||||
}
|
}
|
||||||
AllZone.getTriggerHandler().suppressMode(TriggerType.Transformed);
|
|
||||||
copied.setState(CardCharactersticName.Original);
|
copied.setState(CardCharactersticName.Original);
|
||||||
AllZone.getTriggerHandler().clearSuppression(TriggerType.Transformed);
|
|
||||||
// Soulbond unpairing
|
// Soulbond unpairing
|
||||||
if (c.isPaired()) {
|
if (c.isPaired()) {
|
||||||
c.getPairedWith().setPairedWith(null);
|
c.getPairedWith().setPairedWith(null);
|
||||||
@@ -276,8 +268,7 @@ public class GameAction {
|
|||||||
if (copied.isEnchanting()) {
|
if (copied.isEnchanting()) {
|
||||||
copied.unEnchantEntity(copied.getEnchanting());
|
copied.unEnchantEntity(copied.getEnchanting());
|
||||||
}
|
}
|
||||||
}
|
} else if (zoneTo.is(ZoneType.Battlefield)) {
|
||||||
|
|
||||||
copied.setTimestamp(AllZone.getNextTimestamp());
|
copied.setTimestamp(AllZone.getNextTimestamp());
|
||||||
for (String s : copied.getKeyword()) {
|
for (String s : copied.getKeyword()) {
|
||||||
if (s.startsWith("May be played") || s.startsWith("You may look at this card.")
|
if (s.startsWith("May be played") || s.startsWith("You may look at this card.")
|
||||||
@@ -287,6 +278,7 @@ public class GameAction {
|
|||||||
copied.removeHiddenExtrinsicKeyword(s);
|
copied.removeHiddenExtrinsicKeyword(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return copied;
|
return copied;
|
||||||
}
|
}
|
||||||
@@ -639,9 +631,7 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (c.isInAlternateState()) {
|
if (c.isInAlternateState()) {
|
||||||
AllZone.getTriggerHandler().suppressMode(TriggerType.Transformed);
|
|
||||||
c.setState(CardCharactersticName.Original);
|
c.setState(CardCharactersticName.Original);
|
||||||
AllZone.getTriggerHandler().clearSuppression(TriggerType.Transformed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((libPosition == -1) || (libPosition > library.size())) {
|
if ((libPosition == -1) || (libPosition > library.size())) {
|
||||||
|
|||||||
@@ -477,20 +477,20 @@ public final class AbilityFactoryClone {
|
|||||||
if (!copyingSelf) {
|
if (!copyingSelf) {
|
||||||
if (tgtCard.isCloned()) { // cloning again
|
if (tgtCard.isCloned()) { // cloning again
|
||||||
tgtCard.switchStates(CardCharactersticName.Cloner, CardCharactersticName.Original);
|
tgtCard.switchStates(CardCharactersticName.Cloner, CardCharactersticName.Original);
|
||||||
tgtCard.setState(CardCharactersticName.Original);
|
tgtCard.changeToState(CardCharactersticName.Original);
|
||||||
tgtCard.clearStates(CardCharactersticName.Cloner);
|
tgtCard.clearStates(CardCharactersticName.Cloner);
|
||||||
}
|
}
|
||||||
// add "Cloner" state to clone
|
// add "Cloner" state to clone
|
||||||
tgtCard.addAlternateState(CardCharactersticName.Cloner);
|
tgtCard.addAlternateState(CardCharactersticName.Cloner);
|
||||||
tgtCard.switchStates(CardCharactersticName.Original, CardCharactersticName.Cloner);
|
tgtCard.switchStates(CardCharactersticName.Original, CardCharactersticName.Cloner);
|
||||||
tgtCard.setState(CardCharactersticName.Original);
|
tgtCard.changeToState(CardCharactersticName.Original);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//copy Original state to Cloned
|
//copy Original state to Cloned
|
||||||
tgtCard.addAlternateState(CardCharactersticName.Cloned);
|
tgtCard.addAlternateState(CardCharactersticName.Cloned);
|
||||||
tgtCard.switchStates(CardCharactersticName.Original, CardCharactersticName.Cloned);
|
tgtCard.switchStates(CardCharactersticName.Original, CardCharactersticName.Cloned);
|
||||||
if (tgtCard.isFlipCard()) {
|
if (tgtCard.isFlipCard()) {
|
||||||
tgtCard.setState(CardCharactersticName.Original);
|
tgtCard.changeToState(CardCharactersticName.Original);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,7 +521,7 @@ public final class AbilityFactoryClone {
|
|||||||
if (cardToCopy.isFlipCard()) {
|
if (cardToCopy.isFlipCard()) {
|
||||||
if (!copyingSelf) {
|
if (!copyingSelf) {
|
||||||
tgtCard.addAlternateState(CardCharactersticName.Flipped);
|
tgtCard.addAlternateState(CardCharactersticName.Flipped);
|
||||||
tgtCard.setState(CardCharactersticName.Flipped);
|
tgtCard.changeToState(CardCharactersticName.Flipped);
|
||||||
}
|
}
|
||||||
CardFactoryUtil.copyState(cardToCopy, CardCharactersticName.Flipped, tgtCard);
|
CardFactoryUtil.copyState(cardToCopy, CardCharactersticName.Flipped, tgtCard);
|
||||||
addExtraCharacteristics(tgtCard, params, origSVars);
|
addExtraCharacteristics(tgtCard, params, origSVars);
|
||||||
@@ -537,7 +537,7 @@ public final class AbilityFactoryClone {
|
|||||||
tgtCard.setImageFilename(imageFileName);
|
tgtCard.setImageFilename(imageFileName);
|
||||||
|
|
||||||
if (!tgtCard.isFlipped()) {
|
if (!tgtCard.isFlipped()) {
|
||||||
tgtCard.setState(CardCharactersticName.Original);
|
tgtCard.changeToState(CardCharactersticName.Original);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tgtCard.setFlipCard(false);
|
tgtCard.setFlipCard(false);
|
||||||
|
|||||||
@@ -397,7 +397,7 @@ public final class AbilityFactoryCopy {
|
|||||||
if (c.isInAlternateState()) {
|
if (c.isInAlternateState()) {
|
||||||
stateName = c.getCurState();
|
stateName = c.getCurState();
|
||||||
wasInAlt = true;
|
wasInAlt = true;
|
||||||
c.setState(CardCharactersticName.Original);
|
c.changeToState(CardCharactersticName.Original);
|
||||||
}
|
}
|
||||||
|
|
||||||
// start copied Kiki code
|
// start copied Kiki code
|
||||||
@@ -445,22 +445,22 @@ public final class AbilityFactoryCopy {
|
|||||||
|
|
||||||
if (c.isDoubleFaced()) { // Cloned DFC's can't transform
|
if (c.isDoubleFaced()) { // Cloned DFC's can't transform
|
||||||
if (wasInAlt) {
|
if (wasInAlt) {
|
||||||
copy.setState(CardCharactersticName.Transformed);
|
copy.changeToState(CardCharactersticName.Transformed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c.isFlipCard()) { // Cloned Flips CAN flip.
|
if (c.isFlipCard()) { // Cloned Flips CAN flip.
|
||||||
copy.setState(CardCharactersticName.Original);
|
copy.changeToState(CardCharactersticName.Original);
|
||||||
c.setState(CardCharactersticName.Original);
|
c.changeToState(CardCharactersticName.Original);
|
||||||
copy.setImageFilename(c.getImageFilename());
|
copy.setImageFilename(c.getImageFilename());
|
||||||
if (!c.isInAlternateState()) {
|
if (!c.isInAlternateState()) {
|
||||||
copy.setState(CardCharactersticName.Flipped);
|
copy.changeToState(CardCharactersticName.Flipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
c.setState(CardCharactersticName.Flipped);
|
c.changeToState(CardCharactersticName.Flipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c.isFaceDown()) {
|
if (c.isFaceDown()) {
|
||||||
c.setState(CardCharactersticName.FaceDown);
|
c.changeToState(CardCharactersticName.FaceDown);
|
||||||
}
|
}
|
||||||
copy = Singletons.getModel().getGameAction().moveToPlay(copy);
|
copy = Singletons.getModel().getGameAction().moveToPlay(copy);
|
||||||
|
|
||||||
@@ -470,7 +470,7 @@ public final class AbilityFactoryCopy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wasInAlt) {
|
if (wasInAlt) {
|
||||||
c.setState(stateName);
|
c.changeToState(stateName);
|
||||||
}
|
}
|
||||||
AllZone.getTriggerHandler().clearSuppression(TriggerType.Transformed);
|
AllZone.getTriggerHandler().clearSuppression(TriggerType.Transformed);
|
||||||
|
|
||||||
|
|||||||
@@ -269,13 +269,13 @@ public class AbilityFactorySetState {
|
|||||||
}
|
}
|
||||||
if (tgt.isDoubleFaced()) {
|
if (tgt.isDoubleFaced()) {
|
||||||
if (tgt.getCurState() == CardCharactersticName.Original) {
|
if (tgt.getCurState() == CardCharactersticName.Original) {
|
||||||
if (tgt.setState(CardCharactersticName.Transformed)) {
|
if (tgt.changeToState(CardCharactersticName.Transformed)) {
|
||||||
if (remChanged) {
|
if (remChanged) {
|
||||||
abilityFactory.getHostCard().addRemembered(tgt);
|
abilityFactory.getHostCard().addRemembered(tgt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (tgt.getCurState() == CardCharactersticName.Transformed) {
|
} else if (tgt.getCurState() == CardCharactersticName.Transformed) {
|
||||||
if (tgt.setState(CardCharactersticName.Original)) {
|
if (tgt.changeToState(CardCharactersticName.Original)) {
|
||||||
if (remChanged) {
|
if (remChanged) {
|
||||||
abilityFactory.getHostCard().addRemembered(tgt);
|
abilityFactory.getHostCard().addRemembered(tgt);
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ public class AbilityFactorySetState {
|
|||||||
} else if (mode.equals("Flip")) {
|
} else if (mode.equals("Flip")) {
|
||||||
if (tgt.isFlipCard()) {
|
if (tgt.isFlipCard()) {
|
||||||
if (tgt.getCurState() == CardCharactersticName.Original) {
|
if (tgt.getCurState() == CardCharactersticName.Original) {
|
||||||
if (tgt.setState(CardCharactersticName.Flipped)) {
|
if (tgt.changeToState(CardCharactersticName.Flipped)) {
|
||||||
abilityFactory.getHostCard().setFlipStaus(true);
|
abilityFactory.getHostCard().setFlipStaus(true);
|
||||||
if (remChanged) {
|
if (remChanged) {
|
||||||
abilityFactory.getHostCard().addRemembered(tgt);
|
abilityFactory.getHostCard().addRemembered(tgt);
|
||||||
@@ -294,7 +294,7 @@ public class AbilityFactorySetState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (tgt.getCurState() == CardCharactersticName.Flipped) {
|
} else if (tgt.getCurState() == CardCharactersticName.Flipped) {
|
||||||
if (tgt.setState(CardCharactersticName.Original)) {
|
if (tgt.changeToState(CardCharactersticName.Original)) {
|
||||||
abilityFactory.getHostCard().setFlipStaus(false);
|
abilityFactory.getHostCard().setFlipStaus(false);
|
||||||
if (remChanged) {
|
if (remChanged) {
|
||||||
abilityFactory.getHostCard().addRemembered(tgt);
|
abilityFactory.getHostCard().addRemembered(tgt);
|
||||||
@@ -314,7 +314,7 @@ public class AbilityFactorySetState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tgt.setState(CardCharactersticName.smartValueOf(abilityFactory.getMapParams().get("NewState")));
|
tgt.changeToState(CardCharactersticName.smartValueOf(abilityFactory.getMapParams().get("NewState")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -491,14 +491,14 @@ public class AbilityFactorySetState {
|
|||||||
}
|
}
|
||||||
if (list.get(i).isDoubleFaced()) {
|
if (list.get(i).isDoubleFaced()) {
|
||||||
if (list.get(i).getCurState() == CardCharactersticName.Original) {
|
if (list.get(i).getCurState() == CardCharactersticName.Original) {
|
||||||
if (list.get(i).setState(CardCharactersticName.Transformed) && remChanged) {
|
if (list.get(i).changeToState(CardCharactersticName.Transformed) && remChanged) {
|
||||||
if (remChanged) {
|
if (remChanged) {
|
||||||
abilityFactory.getHostCard().addRemembered(list.get(i));
|
abilityFactory.getHostCard().addRemembered(list.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (list.get(i).getCurState() == CardCharactersticName.Transformed) {
|
} else if (list.get(i).getCurState() == CardCharactersticName.Transformed) {
|
||||||
if (list.get(i).setState(CardCharactersticName.Original)) {
|
if (list.get(i).changeToState(CardCharactersticName.Original)) {
|
||||||
if (remChanged) {
|
if (remChanged) {
|
||||||
abilityFactory.getHostCard().addRemembered(list.get(i));
|
abilityFactory.getHostCard().addRemembered(list.get(i));
|
||||||
}
|
}
|
||||||
@@ -509,14 +509,14 @@ public class AbilityFactorySetState {
|
|||||||
} else if (mode.equals("Flip")) {
|
} else if (mode.equals("Flip")) {
|
||||||
if (list.get(i).isFlipCard()) {
|
if (list.get(i).isFlipCard()) {
|
||||||
if (list.get(i).getCurState() == CardCharactersticName.Original) {
|
if (list.get(i).getCurState() == CardCharactersticName.Original) {
|
||||||
if (list.get(i).setState(CardCharactersticName.Flipped)) {
|
if (list.get(i).changeToState(CardCharactersticName.Flipped)) {
|
||||||
list.get(i).setFlipStaus(true);
|
list.get(i).setFlipStaus(true);
|
||||||
if (remChanged) {
|
if (remChanged) {
|
||||||
abilityFactory.getHostCard().addRemembered(tgt);
|
abilityFactory.getHostCard().addRemembered(tgt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (list.get(i).getCurState() == CardCharactersticName.Flipped) {
|
} else if (list.get(i).getCurState() == CardCharactersticName.Flipped) {
|
||||||
if (list.get(i).setState(CardCharactersticName.Original)) {
|
if (list.get(i).changeToState(CardCharactersticName.Original)) {
|
||||||
list.get(i).setFlipStaus(false);
|
list.get(i).setFlipStaus(false);
|
||||||
if (remChanged) {
|
if (remChanged) {
|
||||||
abilityFactory.getHostCard().addRemembered(tgt);
|
abilityFactory.getHostCard().addRemembered(tgt);
|
||||||
@@ -536,7 +536,7 @@ public class AbilityFactorySetState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list.get(i).setState(CardCharactersticName.smartValueOf(abilityFactory.getMapParams().get("NewState")));
|
list.get(i).changeToState(CardCharactersticName.smartValueOf(abilityFactory.getMapParams().get("NewState")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import forge.Singletons;
|
|||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.card.spellability.SpellPermanent;
|
import forge.card.spellability.SpellPermanent;
|
||||||
import forge.card.spellability.Target;
|
import forge.card.spellability.Target;
|
||||||
import forge.card.trigger.TriggerType;
|
|
||||||
import forge.game.player.ComputerUtil;
|
import forge.game.player.ComputerUtil;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
@@ -153,7 +152,6 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
|||||||
@Override
|
@Override
|
||||||
public final Card copyCard(final Card in) {
|
public final Card copyCard(final Card in) {
|
||||||
final CardCharactersticName curState = in.getCurState();
|
final CardCharactersticName curState = in.getCurState();
|
||||||
AllZone.getTriggerHandler().suppressMode(TriggerType.Transformed);
|
|
||||||
if (in.isInAlternateState()) {
|
if (in.isInAlternateState()) {
|
||||||
in.setState(CardCharactersticName.Original);
|
in.setState(CardCharactersticName.Original);
|
||||||
}
|
}
|
||||||
@@ -174,7 +172,6 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
|||||||
in.setState(curState);
|
in.setState(curState);
|
||||||
out.setState(curState);
|
out.setState(curState);
|
||||||
}
|
}
|
||||||
AllZone.getTriggerHandler().clearSuppression(TriggerType.Transformed);
|
|
||||||
|
|
||||||
// I'm not sure if we really should be copying enchant/equip stuff over.
|
// I'm not sure if we really should be copying enchant/equip stuff over.
|
||||||
out.setEquipping(in.getEquipping());
|
out.setEquipping(in.getEquipping());
|
||||||
|
|||||||
@@ -3914,7 +3914,6 @@ public class CardFactoryUtil {
|
|||||||
c.setDoubleFaced(sim.isDoubleFaced());
|
c.setDoubleFaced(sim.isDoubleFaced());
|
||||||
c.setCurSetCode(sim.getCurSetCode());
|
c.setCurSetCode(sim.getCurSetCode());
|
||||||
|
|
||||||
AllZone.getTriggerHandler().suppressMode(TriggerType.Transformed);
|
|
||||||
final CardCharactersticName origState = sim.getCurState();
|
final CardCharactersticName origState = sim.getCurState();
|
||||||
for (final CardCharactersticName state : sim.getStates()) {
|
for (final CardCharactersticName state : sim.getStates()) {
|
||||||
c.addAlternateState(state);
|
c.addAlternateState(state);
|
||||||
@@ -3926,7 +3925,6 @@ public class CardFactoryUtil {
|
|||||||
sim.setState(origState);
|
sim.setState(origState);
|
||||||
c.setState(origState);
|
c.setState(origState);
|
||||||
|
|
||||||
AllZone.getTriggerHandler().clearSuppression(TriggerType.Transformed);
|
|
||||||
return c;
|
return c;
|
||||||
} // copyStats()
|
} // copyStats()
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import forge.CardUtil;
|
|||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
import forge.GameAction;
|
import forge.GameAction;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.trigger.TriggerType;
|
|
||||||
import forge.control.FControl;
|
import forge.control.FControl;
|
||||||
import forge.control.input.InputMulligan;
|
import forge.control.input.InputMulligan;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
@@ -128,7 +127,6 @@ public class GameNew {
|
|||||||
final ArrayList<String> hAnteRemoved = new ArrayList<String>();
|
final ArrayList<String> hAnteRemoved = new ArrayList<String>();
|
||||||
final ArrayList<String> cAnteRemoved = new ArrayList<String>();
|
final ArrayList<String> cAnteRemoved = new ArrayList<String>();
|
||||||
|
|
||||||
AllZone.getTriggerHandler().suppressMode(TriggerType.Transformed);
|
|
||||||
for (final Entry<CardPrinted, Integer> stackOfCards : humanDeck.getMain()) {
|
for (final Entry<CardPrinted, Integer> stackOfCards : humanDeck.getMain()) {
|
||||||
final CardPrinted cardPrinted = stackOfCards.getKey();
|
final CardPrinted cardPrinted = stackOfCards.getKey();
|
||||||
for (int i = 0; i < stackOfCards.getValue(); i++) {
|
for (int i = 0; i < stackOfCards.getValue(); i++) {
|
||||||
@@ -141,8 +139,8 @@ public class GameNew {
|
|||||||
card.setFoil(iFoil);
|
card.setFoil(iFoil);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card.hasKeyword("Remove CARDNAME from your deck before playing if you're not playing for ante.")
|
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)
|
||||||
&& !Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
|
&& card.hasKeyword("Remove CARDNAME from your deck before playing if you're not playing for ante.")) {
|
||||||
hAnteRemoved.add(card.getName());
|
hAnteRemoved.add(card.getName());
|
||||||
} else {
|
} else {
|
||||||
AllZone.getHumanPlayer().getZone(ZoneType.Library).add(card);
|
AllZone.getHumanPlayer().getZone(ZoneType.Library).add(card);
|
||||||
@@ -167,8 +165,8 @@ public class GameNew {
|
|||||||
card.setFoil(iFoil);
|
card.setFoil(iFoil);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card.hasKeyword("Remove CARDNAME from your deck before playing if you're not playing for ante.")
|
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)
|
||||||
&& !Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
|
&& card.hasKeyword("Remove CARDNAME from your deck before playing if you're not playing for ante.")) {
|
||||||
cAnteRemoved.add(card.getName());
|
cAnteRemoved.add(card.getName());
|
||||||
} else {
|
} else {
|
||||||
AllZone.getComputerPlayer().getZone(ZoneType.Library).add(card);
|
AllZone.getComputerPlayer().getZone(ZoneType.Library).add(card);
|
||||||
@@ -182,7 +180,7 @@ public class GameNew {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AllZone.getTriggerHandler().clearSuppression(TriggerType.Transformed);
|
|
||||||
if (rAICards.size() > 0) {
|
if (rAICards.size() > 0) {
|
||||||
final StringBuilder sb = new StringBuilder(
|
final StringBuilder sb = new StringBuilder(
|
||||||
"AI deck contains the following cards that it can't play or may be buggy:\n");
|
"AI deck contains the following cards that it can't play or may be buggy:\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user