Fix Conspiracy removing types without choice for new one (#6017)

* Skip incomplete overwrite

* Fix NPE for Unhaunting
This commit is contained in:
tool4ever
2024-08-30 19:13:49 +02:00
committed by GitHub
parent cadf278871
commit 080d347199
7 changed files with 38 additions and 32 deletions

View File

@@ -353,7 +353,7 @@ public class ComputerUtilAbility {
} }
// 1. increase chance of using Surge effects // 1. increase chance of using Surge effects
// 2. non-surged versions are usually inefficient // 2. non-surged versions are usually inefficient
if (source.getOracleText().contains("surge cost") && !sa.isSurged()) { if (source.hasKeyword(Keyword.SURGE) && !sa.isSurged()) {
p -= 9; p -= 9;
} }
// move snap-casted spells to front // move snap-casted spells to front
@@ -386,8 +386,10 @@ public class ComputerUtilAbility {
} }
if (ApiType.DestroyAll == sa.getApi()) { if (ApiType.DestroyAll == sa.getApi()) {
// check boardwipe earlier
p += 4; p += 4;
} else if (ApiType.Mana == sa.getApi()) { } else if (ApiType.Mana == sa.getApi()) {
// keep mana abilities for paying
p -= 9; p -= 9;
} }
@@ -398,7 +400,7 @@ public class ComputerUtilAbility {
return p; return p;
} }
}; }
public static List<SpellAbility> sortCreatureSpells(final List<SpellAbility> all) { public static List<SpellAbility> sortCreatureSpells(final List<SpellAbility> all) {
// try to smoothen power creep by making CMC less of a factor // try to smoothen power creep by making CMC less of a factor

View File

@@ -47,6 +47,7 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
public static final CardTypeView EMPTY = new CardType(false); public static final CardTypeView EMPTY = new CardType(false);
public enum CoreType { public enum CoreType {
Kindred(false, "kindreds"), // always printed first
Artifact(true, "artifacts"), Artifact(true, "artifacts"),
Battle(true, "battles"), Battle(true, "battles"),
Conspiracy(false, "conspiracies"), Conspiracy(false, "conspiracies"),
@@ -60,7 +61,6 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
Planeswalker(true, "planeswalkers"), Planeswalker(true, "planeswalkers"),
Scheme(false, "schemes"), Scheme(false, "schemes"),
Sorcery(false, "sorceries"), Sorcery(false, "sorceries"),
Kindred(false, "kindreds"),
Vanguard(false, "vanguards"); Vanguard(false, "vanguards");
public final boolean isPermanent; public final boolean isPermanent;

View File

@@ -194,8 +194,7 @@ public interface IPaperCard extends InventoryItem, Serializable {
* easier access from code. * easier access from code.
*/ */
public abstract static class Presets { public abstract static class Presets {
// Think twice before using these, since rarity is a prop of printed // Think twice before using these, since rarity is a prop of printed card.
// card.
/** The Constant isCommon. */ /** The Constant isCommon. */
public static final Predicate<PaperCard> IS_COMMON = Predicates.rarity(true, CardRarity.Common); public static final Predicate<PaperCard> IS_COMMON = Predicates.rarity(true, CardRarity.Common);

View File

@@ -35,7 +35,6 @@ public class ForgeScript {
public static boolean cardStateHasProperty(CardState cardState, String property, Player sourceController, public static boolean cardStateHasProperty(CardState cardState, String property, Player sourceController,
Card source, CardTraitBase spellAbility) { Card source, CardTraitBase spellAbility) {
boolean withSource = property.endsWith("Source"); boolean withSource = property.endsWith("Source");
final ColorSet colors; final ColorSet colors;
if (withSource && StaticAbilityColorlessDamageSource.colorlessDamageSource(cardState)) { if (withSource && StaticAbilityColorlessDamageSource.colorlessDamageSource(cardState)) {
@@ -53,7 +52,7 @@ public class ForgeScript {
int desiredColor = MagicColor.fromName(colorName); int desiredColor = MagicColor.fromName(colorName);
boolean hasColor = colors.hasAnyColor(desiredColor); boolean hasColor = colors.hasAnyColor(desiredColor);
return mustHave == hasColor; return mustHave == hasColor;
} else if (property.contains("Colorless")) { // ... Card is colorless } else if (property.contains("Colorless")) {
boolean non = property.startsWith("non"); boolean non = property.startsWith("non");
return non != colors.isColorless(); return non != colors.isColorless();
} else if (property.startsWith("MultiColor")) { } else if (property.startsWith("MultiColor")) {
@@ -72,7 +71,7 @@ public class ForgeScript {
return false; return false;
} else if (property.startsWith("AllColors")) { } else if (property.startsWith("AllColors")) {
return colors.isAllColors(); return colors.isAllColors();
} else if (property.startsWith("MonoColor")) { // ... Card is monocolored } else if (property.startsWith("MonoColor")) {
return colors.isMonoColor(); return colors.isMonoColor();
} else if (property.startsWith("ChosenColor")) { } else if (property.startsWith("ChosenColor")) {
return source.hasChosenColor() && colors.hasAnyColor(MagicColor.fromName(source.getChosenColor())); return source.hasChosenColor() && colors.hasAnyColor(MagicColor.fromName(source.getChosenColor()));

View File

@@ -14,7 +14,7 @@ public class HauntEffect extends SpellAbilityEffect {
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
Card host = sa.getHostCard(); Card host = sa.getHostCard();
if (host.isPermanent()) { if (host.isPermanent() && sa.hasTriggeringObject(AbilityKey.NewCard)) {
// get new version instead of battlefield lki // get new version instead of battlefield lki
host = (Card) sa.getTriggeringObject(AbilityKey.NewCard); host = (Card) sa.getTriggeringObject(AbilityKey.NewCard);
} }

View File

@@ -1843,6 +1843,7 @@ public class Player extends GameEntity implements Comparable<Player> {
lastDrawnCard = c; lastDrawnCard = c;
return lastDrawnCard; return lastDrawnCard;
} }
public final Card getRingBearer() { public final Card getRingBearer() {
return ringBearer; return ringBearer;
} }
@@ -1865,6 +1866,7 @@ public class Player extends GameEntity implements Comparable<Player> {
ringBearer.setRingBearer(false); ringBearer.setRingBearer(false);
ringBearer = null; ringBearer = null;
} }
public final String getNamedCard() { public final String getNamedCard() {
return namedCard; return namedCard;
} }

View File

@@ -422,6 +422,9 @@ public final class StaticAbilityContinuous {
if (params.containsKey("AddAllCreatureTypes")) { if (params.containsKey("AddAllCreatureTypes")) {
addAllCreatureTypes = true; addAllCreatureTypes = true;
} }
// overwrite doesn't work without new value (e.g. Conspiracy missing choice)
if (addTypes == null || !addTypes.isEmpty()) {
if (params.containsKey("RemoveSuperTypes")) { if (params.containsKey("RemoveSuperTypes")) {
remove.add(RemoveType.SuperTypes); remove.add(RemoveType.SuperTypes);
} }
@@ -444,6 +447,7 @@ public final class StaticAbilityContinuous {
remove.add(RemoveType.EnchantmentTypes); remove.add(RemoveType.EnchantmentTypes);
} }
} }
}
if (layer == StaticAbilityLayer.COLOR) { if (layer == StaticAbilityLayer.COLOR) {
if (params.containsKey("AddColor")) { if (params.containsKey("AddColor")) {
@@ -510,7 +514,7 @@ public final class StaticAbilityContinuous {
// modify players // modify players
for (final Player p : affectedPlayers) { for (final Player p : affectedPlayers) {
// add keywords // add keywords
if (addKeywords != null) { if (addKeywords != null && !addKeywords.isEmpty()) {
p.addChangedKeywords(addKeywords, removeKeywords, se.getTimestamp(), stAb.getId()); p.addChangedKeywords(addKeywords, removeKeywords, se.getTimestamp(), stAb.getId());
} }
@@ -718,7 +722,7 @@ public final class StaticAbilityContinuous {
} }
// add keywords // add keywords
if (addKeywords != null || removeKeywords != null || removeAllAbilities) { if ((addKeywords != null && !addKeywords.isEmpty()) || removeKeywords != null || removeAllAbilities) {
List<String> newKeywords = null; List<String> newKeywords = null;
if (addKeywords != null) { if (addKeywords != null) {
newKeywords = Lists.newArrayList(addKeywords); newKeywords = Lists.newArrayList(addKeywords);
@@ -876,7 +880,7 @@ public final class StaticAbilityContinuous {
} }
// add Types // add Types
if (addTypes != null || removeTypes != null || addAllCreatureTypes || !remove.isEmpty()) { if ((addTypes != null && !addTypes.isEmpty()) || (removeTypes != null && !removeTypes.isEmpty()) || addAllCreatureTypes || !remove.isEmpty()) {
affectedCard.addChangedCardTypes(addTypes, removeTypes, addAllCreatureTypes, remove, affectedCard.addChangedCardTypes(addTypes, removeTypes, addAllCreatureTypes, remove,
se.getTimestamp(), stAb.getId(), true, stAb.hasParam("CharacteristicDefining")); se.getTimestamp(), stAb.getId(), true, stAb.hasParam("CharacteristicDefining"));
} }