AttractionsYouVisitedThisTurn and Squirrel Squatters

Untangled some oracle text methods in Card and CardState
Sly Spy, Everythingamajig, and two Garbage Elementals
Visit card text fix.
2 more Attractions
This commit is contained in:
Jetz
2024-06-07 21:36:10 -04:00
parent c6de232ac5
commit 8c8c8a779b
14 changed files with 136 additions and 60 deletions

View File

@@ -2649,6 +2649,10 @@ public class AbilityUtils {
return game.getPhaseHandler().getPlanarDiceSpecialActionThisTurn();
}
if (sq[0].startsWith("AttractionsYouVisitedThisTurn")) {
return doXMath(player.getAttractionsVisitedThisTurn(), expr, c, ctb);
}
if (sq[0].equals("AllTypes")) {
List<Card> cards = getDefinedCards(c, sq[1], ctb);

View File

@@ -221,6 +221,12 @@ public class RollDiceEffect extends SpellAbilityEffect {
List<Integer> rolls = new ArrayList<>();
int total = rollDiceForPlayer(sa, player, amount, sides, ignore, modifier, rolls);
if (sa.hasParam("UseHighestRoll")) {
total = Collections.max(rolls);
} else if (sa.hasParam("UseDifferenceBetweenRolls")) {
total = Collections.max(rolls) - Collections.min(rolls);
}
if (sa.hasParam("StoreResults")) {
host.addStoredRolls(rolls);
}
@@ -243,9 +249,6 @@ public class RollDiceEffect extends SpellAbilityEffect {
sa.setSVar(sa.getParam("OtherSVar"), Integer.toString(other));
}
}
if (sa.hasParam("UseHighestRoll")) {
total = Collections.max(rolls);
}
if (sa.hasParam("SubsForEach")) {
for (Integer roll : rolls) {

View File

@@ -277,8 +277,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
private Table<Long, Long, Pair<Integer,Integer>> newPT = TreeBasedTable.create(); // Layer 7b
private Table<Long, Long, Pair<Integer,Integer>> boostPT = TreeBasedTable.create(); // Layer 7c
private String oracleText = "";
private final Map<Card, Integer> assignedDamageMap = Maps.newTreeMap();
private Map<Integer, Integer> damage = Maps.newHashMap();
private boolean hasBeenDealtDeathtouchDamage;
@@ -2506,7 +2504,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|| keyword.startsWith("Class") || keyword.startsWith("Blitz")
|| keyword.startsWith("Specialize") || keyword.equals("Ravenous")
|| keyword.equals("For Mirrodin") || keyword.startsWith("Craft")
|| keyword.startsWith("Landwalk")) {
|| keyword.startsWith("Landwalk") || keyword.startsWith("Visit")) {
// keyword parsing takes care of adding a proper description
} else if (keyword.equals("Read ahead")) {
sb.append(Localizer.getInstance().getMessage("lblReadAhead")).append(" (").append(Localizer.getInstance().getMessage("lblReadAheadDesc"));
@@ -3498,7 +3496,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
public final void setCopiedPermanent(final Card c) {
if (copiedPermanent == c) { return; }
copiedPermanent = c;
currentState.getView().updateOracleText(this);
currentState.setOracleText(c.getOracleText());
}
public final boolean isCopiedSpell() {
@@ -7244,7 +7242,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
public void setRules(CardRules r) {
cardRules = r;
currentState.getView().updateRulesText(r, getType());
currentState.getView().updateOracleText(this);
}
public boolean isCommander() {
@@ -7573,15 +7570,10 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
}
public String getOracleText() {
CardRules rules = cardRules;
if (copiedPermanent != null) { //return oracle text of copied permanent if applicable
rules = copiedPermanent.getRules();
}
return rules != null ? rules.getOracleText() : oracleText;
return currentState.getOracleText();
}
public void setOracleText(final String oracleText0) {
oracleText = oracleText0;
currentState.getView().updateOracleText(this);
public void setOracleText(final String oracleText) {
currentState.setOracleText(oracleText);
}
@Override

View File

@@ -346,9 +346,9 @@ public class CardFactory {
card.setColor(combinedColor);
card.setType(new CardType(rules.getType()));
// Combined text based on Oracle text - might not be necessary, temporarily disabled.
//String combinedText = String.format("%s: %s\n%s: %s", rules.getMainPart().getName(), rules.getMainPart().getOracleText(), rules.getOtherPart().getName(), rules.getOtherPart().getOracleText());
//card.setText(combinedText);
// Combined text based on Oracle text - might not be necessary
String combinedText = String.format("(%s) %s\r\n\r\n(%s) %s", rules.getMainPart().getName(), rules.getMainPart().getOracleText(), rules.getOtherPart().getName(), rules.getOtherPart().getOracleText());
card.getState(CardStateName.Original).setOracleText(combinedText);
}
return card;
}
@@ -377,7 +377,7 @@ public class CardFactory {
c.getCurrentState().setBaseLoyalty(face.getInitialLoyalty());
c.getCurrentState().setBaseDefense(face.getDefense());
c.setOracleText(face.getOracleText());
c.getCurrentState().setOracleText(face.getOracleText());
// Super and 'middle' types should use enums.
c.setType(new CardType(face.getType()));
@@ -454,7 +454,7 @@ public class CardFactory {
c.getCurrentState().setBaseDefense(variant.getDefense());
if (variant.getOracleText() != null)
c.setOracleText(variant.getOracleText());
c.getCurrentState().setOracleText(variant.getOracleText());
if (variant.getType() != null) {
for(String type : variant.getType())

View File

@@ -58,6 +58,7 @@ public class CardState extends GameObject implements IHasSVars {
private CardType type = new CardType(false);
private ManaCost manaCost = ManaCost.NO_COST;
private byte color = MagicColor.COLORLESS;
private String oracleText = "";
private int basePower = 0;
private int baseToughness = 0;
private String basePowerString = null;
@@ -194,6 +195,15 @@ public class CardState extends GameObject implements IHasSVars {
view.updateColors(card);
}
public String getOracleText() {
return oracleText;
}
public void setOracleText(final String oracleText) {
this.oracleText = oracleText;
view.setOracleText(oracleText);
}
public final int getBasePower() {
return basePower;
}
@@ -595,6 +605,7 @@ public class CardState extends GameObject implements IHasSVars {
setType(source.type);
setManaCost(source.getManaCost());
setColor(source.getColor());
setOracleText(source.getOracleText());
setBasePower(source.getBasePower());
setBaseToughness(source.getBaseToughness());
setBaseLoyalty(source.getBaseLoyalty());

View File

@@ -1298,8 +1298,8 @@ public class CardView extends GameEntityView {
public String getOracleText() {
return get(TrackableProperty.OracleText);
}
void updateOracleText(Card c) {
set(TrackableProperty.OracleText, c.getOracleText().replace("\\n", "\r\n\r\n").trim());
void setOracleText(String oracleText) {
set(TrackableProperty.OracleText, oracleText.replace("\\n", "\r\n\r\n").trim());
}
public String getRulesText() {