Fix DiscardedThisTurn

This commit is contained in:
TRT
2023-01-05 16:10:50 +01:00
parent 40dbdec31c
commit b1df2d1008
11 changed files with 24 additions and 20 deletions

View File

@@ -1063,6 +1063,10 @@ public class ComputerUtil {
return true; return true;
} }
if (cardState.hasKeyword(Keyword.EXALTED) || cardState.hasKeyword(Keyword.EXTORT)) {
return true;
}
if (cardState.hasKeyword(Keyword.RIOT) && ChooseGenericEffectAi.preferHasteForRiot(sa, ai)) { if (cardState.hasKeyword(Keyword.RIOT) && ChooseGenericEffectAi.preferHasteForRiot(sa, ai)) {
// Planning to choose Haste for Riot, so do this in Main 1 // Planning to choose Haste for Riot, so do this in Main 1
return true; return true;
@@ -1070,6 +1074,7 @@ public class ComputerUtil {
// if we have non-persistent mana in our pool, would be good to try to use it and not waste it // if we have non-persistent mana in our pool, would be good to try to use it and not waste it
if (ai.getManaPool().willManaBeLostAtEndOfPhase()) { if (ai.getManaPool().willManaBeLostAtEndOfPhase()) {
// TODO should check if some will be kept and skip those
boolean canUseToPayCost = false; boolean canUseToPayCost = false;
for (byte color : ManaAtom.MANATYPES) { for (byte color : ManaAtom.MANATYPES) {
// tries to reuse any amount of colorless if cost only has generic // tries to reuse any amount of colorless if cost only has generic
@@ -1089,10 +1094,6 @@ public class ComputerUtil {
return true; return true;
} }
if (cardState.hasKeyword(Keyword.EXALTED) || cardState.hasKeyword(Keyword.EXTORT)) {
return true;
}
//cast equipments in Main1 when there are creatures to equip and no other unequipped equipment //cast equipments in Main1 when there are creatures to equip and no other unequipped equipment
if (card.isEquipment()) { if (card.isEquipment()) {
boolean playNow = false; boolean playNow = false;

View File

@@ -93,6 +93,7 @@ public class ComputerUtilMana {
ability.setActivatingPlayer(card.getController(), true); ability.setActivatingPlayer(card.getController(), true);
if (ability.isManaAbility()) { if (ability.isManaAbility()) {
score += ability.calculateScoreForManaAbility(); score += ability.calculateScoreForManaAbility();
// TODO check TriggersWhenSpent
} }
else if (!ability.isTrigger() && ability.isPossible()) { else if (!ability.isTrigger() && ability.isPossible()) {
score += 13; //add 13 for any non-mana activated abilities score += 13; //add 13 for any non-mana activated abilities
@@ -393,9 +394,9 @@ public class ComputerUtilMana {
String manaProduced = toPay.isSnow() && hostCard.isSnow() ? "S" : GameActionUtil.generatedTotalMana(saPayment); String manaProduced = toPay.isSnow() && hostCard.isSnow() ? "S" : GameActionUtil.generatedTotalMana(saPayment);
//String originalProduced = manaProduced; //String originalProduced = manaProduced;
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromPlayer(ai); final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(hostCard);
repParams.put(AbilityKey.Mana, manaProduced); repParams.put(AbilityKey.Mana, manaProduced);
repParams.put(AbilityKey.Affected, hostCard); repParams.put(AbilityKey.Activator, ai);
repParams.put(AbilityKey.AbilityMana, saPayment); // RootAbility repParams.put(AbilityKey.AbilityMana, saPayment); // RootAbility
// TODO Damping Sphere might replace later? // TODO Damping Sphere might replace later?
@@ -1614,9 +1615,9 @@ public class ComputerUtilMana {
// setup produce mana replacement effects // setup produce mana replacement effects
String origin = mp.getOrigProduced(); String origin = mp.getOrigProduced();
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromPlayer(ai); final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(sourceCard);
repParams.put(AbilityKey.Mana, origin); repParams.put(AbilityKey.Mana, origin);
repParams.put(AbilityKey.Affected, sourceCard); repParams.put(AbilityKey.Activator, ai);
repParams.put(AbilityKey.AbilityMana, m); // RootAbility repParams.put(AbilityKey.AbilityMana, m); // RootAbility
List<ReplacementEffect> reList = game.getReplacementHandler().getReplacementList(ReplacementType.ProduceMana, repParams, ReplacementLayer.Other); List<ReplacementEffect> reList = game.getReplacementHandler().getReplacementList(ReplacementType.ProduceMana, repParams, ReplacementLayer.Other);

View File

@@ -266,6 +266,7 @@ public class ManaEffectAi extends SpellAbilityAi {
ManaPool mp = ai.getManaPool(); ManaPool mp = ai.getManaPool();
Mana test = null; Mana test = null;
if (mp.isEmpty()) { if (mp.isEmpty()) {
// TODO use color from ability
test = new Mana((byte) ManaAtom.COLORLESS, source, null); test = new Mana((byte) ManaAtom.COLORLESS, source, null);
mp.addMana(test, false); mp.addMana(test, false);
} }

View File

@@ -101,7 +101,7 @@ public class ManifestAi extends SpellAbilityAi {
repParams.put(AbilityKey.Origin, card.getZone().getZoneType()); repParams.put(AbilityKey.Origin, card.getZone().getZoneType());
repParams.put(AbilityKey.Destination, ZoneType.Battlefield); repParams.put(AbilityKey.Destination, ZoneType.Battlefield);
repParams.put(AbilityKey.Source, sa.getHostCard()); repParams.put(AbilityKey.Source, sa.getHostCard());
List<ReplacementEffect> list = game.getReplacementHandler().getReplacementList(ReplacementType.Moved, repParams, ReplacementLayer.Other); List<ReplacementEffect> list = game.getReplacementHandler().getReplacementList(ReplacementType.Moved, repParams, ReplacementLayer.CantHappen);
if (!list.isEmpty()) { if (!list.isEmpty()) {
return false; return false;
} }

View File

@@ -94,8 +94,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
if (!libCards.isEmpty()) { if (!libCards.isEmpty()) {
sa.getActivatingPlayer().getController().reveal(libCards, ZoneType.Library, libCards.get(0).getOwner()); sa.getActivatingPlayer().getController().reveal(libCards, ZoneType.Library, libCards.get(0).getOwner());
} }
final Map<AbilityKey, Object> runParams = AbilityKey.newMap(); final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(sa.getActivatingPlayer());
runParams.put(AbilityKey.Player, sa.getActivatingPlayer());
runParams.put(AbilityKey.Target, tgtPlayers); runParams.put(AbilityKey.Target, tgtPlayers);
game.getTriggerHandler().runTrigger(TriggerType.SearchedLibrary, runParams, false); game.getTriggerHandler().runTrigger(TriggerType.SearchedLibrary, runParams, false);
} }

View File

@@ -782,7 +782,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
} }
if (sa.hasParam("TrackDiscarded")) { if (sa.hasParam("TrackDiscarded")) {
movedCard.setMadnessWithoutCast(true); movedCard.setDiscarded(true);
} }
} }
} }

View File

@@ -226,7 +226,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
private boolean tributed = false; private boolean tributed = false;
private boolean embalmed = false; private boolean embalmed = false;
private boolean eternalized = false; private boolean eternalized = false;
private boolean madnessWithoutCast = false; private boolean discarded = false;
private boolean flipped = false; private boolean flipped = false;
private boolean facedown = false; private boolean facedown = false;
@@ -5801,8 +5801,8 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
} }
return getCastSA().isMadness(); return getCastSA().isMadness();
} }
public boolean getMadnessWithoutCast() { return madnessWithoutCast; } public boolean wasDiscarded() { return discarded; }
public void setMadnessWithoutCast(boolean state) { madnessWithoutCast = state; } public void setDiscarded(boolean state) { discarded = state; }
public final boolean isMonstrous() { public final boolean isMonstrous() {
return monstrous; return monstrous;

View File

@@ -984,8 +984,7 @@ public class CardProperty {
return false; return false;
} }
List<Card> cards = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Hand, "Card", source, spellAbility); if (!card.wasDiscarded()) {
if (!cards.contains(card) && !card.getMadnessWithoutCast()) {
return false; return false;
} }
} else if (property.startsWith("ControlledByPlayerInTheDirection")) { } else if (property.startsWith("ControlledByPlayerInTheDirection")) {

View File

@@ -1444,6 +1444,9 @@ public class Player extends GameEntity implements Comparable<Player> {
newCard = game.getAction().moveToGraveyard(c, sa, params); newCard = game.getAction().moveToGraveyard(c, sa, params);
// Play the Discard sound // Play the Discard sound
} }
newCard.setDiscarded(true);
if (table != null) { if (table != null) {
table.put(origin, newCard.getZone().getZoneType(), newCard); table.put(origin, newCard.getZone().getZoneType(), newCard);
} }

View File

@@ -664,9 +664,9 @@ public class AbilityManaPart implements java.io.Serializable {
// check for produce mana replacement effects - they mess this up, so just use the mana ability // check for produce mana replacement effects - they mess this up, so just use the mana ability
final Card source = am.getHostCard(); final Card source = am.getHostCard();
final Player activator = am.getActivatingPlayer(); final Player activator = am.getActivatingPlayer();
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromPlayer(activator); final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(source);
repParams.put(AbilityKey.Mana, getOrigProduced()); repParams.put(AbilityKey.Mana, getOrigProduced());
repParams.put(AbilityKey.Affected, source); repParams.put(AbilityKey.Activator, activator);
repParams.put(AbilityKey.AbilityMana, am.getRootAbility()); repParams.put(AbilityKey.AbilityMana, am.getRootAbility());
if (!source.getGame().getReplacementHandler().getReplacementList(ReplacementType.ProduceMana, repParams, ReplacementLayer.Other).isEmpty()) { if (!source.getGame().getReplacementHandler().getReplacementList(ReplacementType.ProduceMana, repParams, ReplacementLayer.Other).isEmpty()) {

View File

@@ -173,7 +173,7 @@ public class HumanPlaySpellAbility {
if (ability.getHostCard().isMadness()) { if (ability.getHostCard().isMadness()) {
// if a player failed to play madness cost, move the card to graveyard // if a player failed to play madness cost, move the card to graveyard
Card newCard = game.getAction().moveToGraveyard(c, null); Card newCard = game.getAction().moveToGraveyard(c, null);
newCard.setMadnessWithoutCast(true); newCard.setDiscarded(true);
} }
} else { } else {
payment.refundPayment(); payment.refundPayment();