mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
AbilityUtils: add RegisteredOpponents for PlayerCount
PlayerPredicates: add isOpponentOf Predicator Player: make getBloodthirstAmount use of new function
This commit is contained in:
@@ -18,6 +18,7 @@ import forge.game.card.*;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerPredicates;
|
||||
import forge.game.spellability.*;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Expressions;
|
||||
@@ -343,7 +344,8 @@ public class AbilityUtils {
|
||||
public static int calculateAmount(final Card card, String amount, final CardTraitBase ability) {
|
||||
// return empty strings and constants
|
||||
if (StringUtils.isBlank(amount)) { return 0; }
|
||||
final Game game = card.getController().getGame();
|
||||
final Player player = card.getController();
|
||||
final Game game = player.getGame();
|
||||
|
||||
// Strip and save sign for calculations
|
||||
final boolean startsWithPlus = amount.charAt(0) == '+';
|
||||
@@ -423,11 +425,15 @@ public class AbilityUtils {
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
}
|
||||
else if (hType.equals("Opponents")) {
|
||||
players.addAll(card.getController().getOpponents());
|
||||
players.addAll(player.getOpponents());
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
}
|
||||
else if (hType.equals("RegisteredOpponents")) {
|
||||
players.addAll(Iterables.filter(game.getRegisteredPlayers(),PlayerPredicates.isOpponentOf(player)));
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
}
|
||||
else if (hType.equals("Other")) {
|
||||
players.addAll(card.getController().getAllOtherPlayers());
|
||||
players.addAll(player.getAllOtherPlayers());
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
}
|
||||
else if (hType.equals("Remembered")) {
|
||||
|
||||
@@ -1953,13 +1953,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
}
|
||||
|
||||
public final int getBloodthirstAmount() {
|
||||
int blood = 0;
|
||||
for (Player p : game.getRegisteredPlayers()) {
|
||||
if (p.isOpponentOf(this)) {
|
||||
blood += p.getAssignedDamage();
|
||||
}
|
||||
}
|
||||
return blood;
|
||||
return Aggregates.sum(Iterables.filter(
|
||||
game.getRegisteredPlayers(), PlayerPredicates.isOpponentOf(this)), Accessors.FN_GET_ASSIGNED_DAMAGE);
|
||||
}
|
||||
|
||||
public final boolean hasSurge() {
|
||||
|
||||
@@ -21,6 +21,15 @@ public final class PlayerPredicates {
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Player> isOpponentOf(final Player player) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return p.isOpponentOf(player);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Player> isCardInPlay(final String cardName) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user