mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
- FRF: Added Sandsteppe Mastodon
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package forge.util;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
@@ -51,6 +52,24 @@ public class Aggregates {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static final <T> List<T> listWithMin(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
||||
if (source == null) { return null; }
|
||||
int min = Integer.MAX_VALUE;
|
||||
List<T> result = Lists.newArrayList();
|
||||
for (final T c : source) {
|
||||
int value = valueAccessor.apply(c);
|
||||
if (value == min) {
|
||||
result.add(c);
|
||||
}
|
||||
if (value < min) {
|
||||
min = value;
|
||||
result.clear();
|
||||
result.add(c);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static final <T> int sum(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
||||
int result = 0;
|
||||
if (source != null) {
|
||||
|
||||
@@ -3,13 +3,18 @@ package forge.game.ability.effects;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.card.CardPredicates.Presets;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -24,6 +29,10 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
|
||||
final CounterType cType = CounterType.valueOf(sa.getParam("CounterType"));
|
||||
final int amount = AbilityUtils.calculateAmount(card, sa.getParam("CounterNum"), sa);
|
||||
if (sa.hasParam("Bolster")) {
|
||||
sb.append("Bolster ").append(amount);
|
||||
return sb.toString();
|
||||
}
|
||||
if (dividedAsYouChoose) {
|
||||
sb.append("Distribute ");
|
||||
} else {
|
||||
@@ -84,7 +93,14 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
counterAmount = activator.getController().chooseNumber(sa, "How many counters?", 0, counterAmount);
|
||||
}
|
||||
|
||||
List<Card> tgtCards = getDefinedCardsOrTargeted(sa);
|
||||
CardCollection tgtCards = new CardCollection();
|
||||
if (sa.hasParam("Bolster")) {
|
||||
CardCollection creatsYouCtrl = CardLists.filter(activator.getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
||||
CardCollection leastToughness = new CardCollection(Aggregates.listWithMin(creatsYouCtrl, CardPredicates.Accessors.fnGetDefense));
|
||||
tgtCards.addAll(activator.getController().chooseCardsForEffect(leastToughness, sa, "Choose a creature with the least toughness", 1, 1, false));
|
||||
} else {
|
||||
tgtCards.addAll(getDefinedCardsOrTargeted(sa));
|
||||
}
|
||||
|
||||
for (final Card tgtCard : tgtCards) {
|
||||
counterAmount = sa.usesTargeting() && sa.hasParam("DividedAsYouChoose") ? sa.getTargetRestrictions().getDividedValue(tgtCard) : counterAmount;
|
||||
|
||||
Reference in New Issue
Block a user