mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Fix Discard cost with Library of Leng
This commit is contained in:
committed by
Michael Kamensky
parent
f091c0592e
commit
7b151bf78a
@@ -1,6 +1,7 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
@@ -8,11 +9,13 @@ import forge.game.card.CardLists;
|
||||
import forge.game.card.CardZoneTable;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.collect.FCollectionView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
@@ -50,12 +53,24 @@ public class BalanceEffect extends SpellAbilityEffect {
|
||||
continue;
|
||||
}
|
||||
if (zone.equals(ZoneType.Hand)) {
|
||||
boolean firstDiscard = p.getNumDiscardedThisTurn() == 0;
|
||||
final CardCollection discardedByPlayer = new CardCollection();
|
||||
for (Card card : p.getController().chooseCardsToDiscardFrom(p, sa, validCards.get(i), numToBalance, numToBalance)) {
|
||||
if ( null == card ) continue;
|
||||
p.discard(card, sa, table);
|
||||
if (p.discard(card, sa, table) != null) {
|
||||
discardedByPlayer.add(card);
|
||||
}
|
||||
}
|
||||
|
||||
if (!discardedByPlayer.isEmpty()) {
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Player, p);
|
||||
runParams.put(AbilityKey.Cards, discardedByPlayer);
|
||||
runParams.put(AbilityKey.Cause, sa);
|
||||
runParams.put(AbilityKey.FirstTime, firstDiscard);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.DiscardedAll, runParams, false);
|
||||
}
|
||||
} else { // Battlefield
|
||||
// TODO: "can'e be sacrificed"
|
||||
for(Card card : p.getController().choosePermanentsToSacrifice(sa, numToBalance, numToBalance, validCards.get(i), valid)) {
|
||||
if ( null == card ) continue;
|
||||
game.getAction().sacrifice(card, sa, table);
|
||||
|
||||
@@ -169,7 +169,7 @@ public class CostDiscard extends CostPartWithList {
|
||||
*/
|
||||
@Override
|
||||
protected Card doPayment(SpellAbility ability, Card targetCard) {
|
||||
return targetCard.getController().discard(targetCard, ability, null);
|
||||
return targetCard.getController().discard(targetCard, null, null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
Reference in New Issue
Block a user