mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Fix DiscardedThisTurn
This commit is contained in:
@@ -1063,6 +1063,10 @@ public class ComputerUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cardState.hasKeyword(Keyword.EXALTED) || cardState.hasKeyword(Keyword.EXTORT)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cardState.hasKeyword(Keyword.RIOT) && ChooseGenericEffectAi.preferHasteForRiot(sa, ai)) {
|
||||
// Planning to choose Haste for Riot, so do this in Main 1
|
||||
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 (ai.getManaPool().willManaBeLostAtEndOfPhase()) {
|
||||
// TODO should check if some will be kept and skip those
|
||||
boolean canUseToPayCost = false;
|
||||
for (byte color : ManaAtom.MANATYPES) {
|
||||
// tries to reuse any amount of colorless if cost only has generic
|
||||
@@ -1089,10 +1094,6 @@ public class ComputerUtil {
|
||||
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
|
||||
if (card.isEquipment()) {
|
||||
boolean playNow = false;
|
||||
|
||||
@@ -93,6 +93,7 @@ public class ComputerUtilMana {
|
||||
ability.setActivatingPlayer(card.getController(), true);
|
||||
if (ability.isManaAbility()) {
|
||||
score += ability.calculateScoreForManaAbility();
|
||||
// TODO check TriggersWhenSpent
|
||||
}
|
||||
else if (!ability.isTrigger() && ability.isPossible()) {
|
||||
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 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.Affected, hostCard);
|
||||
repParams.put(AbilityKey.Activator, ai);
|
||||
repParams.put(AbilityKey.AbilityMana, saPayment); // RootAbility
|
||||
|
||||
// TODO Damping Sphere might replace later?
|
||||
@@ -1614,9 +1615,9 @@ public class ComputerUtilMana {
|
||||
|
||||
// setup produce mana replacement effects
|
||||
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.Affected, sourceCard);
|
||||
repParams.put(AbilityKey.Activator, ai);
|
||||
repParams.put(AbilityKey.AbilityMana, m); // RootAbility
|
||||
|
||||
List<ReplacementEffect> reList = game.getReplacementHandler().getReplacementList(ReplacementType.ProduceMana, repParams, ReplacementLayer.Other);
|
||||
|
||||
@@ -266,6 +266,7 @@ public class ManaEffectAi extends SpellAbilityAi {
|
||||
ManaPool mp = ai.getManaPool();
|
||||
Mana test = null;
|
||||
if (mp.isEmpty()) {
|
||||
// TODO use color from ability
|
||||
test = new Mana((byte) ManaAtom.COLORLESS, source, null);
|
||||
mp.addMana(test, false);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ManifestAi extends SpellAbilityAi {
|
||||
repParams.put(AbilityKey.Origin, card.getZone().getZoneType());
|
||||
repParams.put(AbilityKey.Destination, ZoneType.Battlefield);
|
||||
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()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -94,8 +94,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
||||
if (!libCards.isEmpty()) {
|
||||
sa.getActivatingPlayer().getController().reveal(libCards, ZoneType.Library, libCards.get(0).getOwner());
|
||||
}
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Player, sa.getActivatingPlayer());
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(sa.getActivatingPlayer());
|
||||
runParams.put(AbilityKey.Target, tgtPlayers);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.SearchedLibrary, runParams, false);
|
||||
}
|
||||
|
||||
@@ -782,7 +782,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (sa.hasParam("TrackDiscarded")) {
|
||||
movedCard.setMadnessWithoutCast(true);
|
||||
movedCard.setDiscarded(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
private boolean tributed = false;
|
||||
private boolean embalmed = false;
|
||||
private boolean eternalized = false;
|
||||
private boolean madnessWithoutCast = false;
|
||||
private boolean discarded = false;
|
||||
|
||||
private boolean flipped = false;
|
||||
private boolean facedown = false;
|
||||
@@ -5801,8 +5801,8 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
}
|
||||
return getCastSA().isMadness();
|
||||
}
|
||||
public boolean getMadnessWithoutCast() { return madnessWithoutCast; }
|
||||
public void setMadnessWithoutCast(boolean state) { madnessWithoutCast = state; }
|
||||
public boolean wasDiscarded() { return discarded; }
|
||||
public void setDiscarded(boolean state) { discarded = state; }
|
||||
|
||||
public final boolean isMonstrous() {
|
||||
return monstrous;
|
||||
|
||||
@@ -984,8 +984,7 @@ public class CardProperty {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Card> cards = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Hand, "Card", source, spellAbility);
|
||||
if (!cards.contains(card) && !card.getMadnessWithoutCast()) {
|
||||
if (!card.wasDiscarded()) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("ControlledByPlayerInTheDirection")) {
|
||||
|
||||
@@ -1444,6 +1444,9 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
newCard = game.getAction().moveToGraveyard(c, sa, params);
|
||||
// Play the Discard sound
|
||||
}
|
||||
|
||||
newCard.setDiscarded(true);
|
||||
|
||||
if (table != null) {
|
||||
table.put(origin, newCard.getZone().getZoneType(), newCard);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
final Card source = am.getHostCard();
|
||||
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.Affected, source);
|
||||
repParams.put(AbilityKey.Activator, activator);
|
||||
repParams.put(AbilityKey.AbilityMana, am.getRootAbility());
|
||||
|
||||
if (!source.getGame().getReplacementHandler().getReplacementList(ReplacementType.ProduceMana, repParams, ReplacementLayer.Other).isEmpty()) {
|
||||
|
||||
@@ -173,7 +173,7 @@ public class HumanPlaySpellAbility {
|
||||
if (ability.getHostCard().isMadness()) {
|
||||
// if a player failed to play madness cost, move the card to graveyard
|
||||
Card newCard = game.getAction().moveToGraveyard(c, null);
|
||||
newCard.setMadnessWithoutCast(true);
|
||||
newCard.setDiscarded(true);
|
||||
}
|
||||
} else {
|
||||
payment.refundPayment();
|
||||
|
||||
Reference in New Issue
Block a user