Nethroi (IKO)

This commit is contained in:
Tim Mocny
2021-02-14 00:57:22 +00:00
committed by Anthony Calosa
parent 47fcd88366
commit d7f0665bae
8 changed files with 116 additions and 2 deletions

View File

@@ -331,6 +331,11 @@ public final class AbilityFactory {
abTgt.setMaxTotalCMC(mapParams.get("MaxTotalTargetCMC"));
}
if (mapParams.containsKey("MaxTotalTargetPower")) {
// only target cards up to a certain total max power
abTgt.setMaxTotalPower(mapParams.get("MaxTotalTargetPower"));
}
// TargetValidTargeting most for Counter: e.g. target spell that
// targets X.
if (mapParams.containsKey("TargetValidTargeting")) {

View File

@@ -547,6 +547,21 @@ public final class CardUtil {
}
}
// Remove cards exceeding total power
if (ability.hasParam("MaxTotalTargetPower")) {
int totalPowerTargeted = 0;
for (final Card c : targeted) {
totalPowerTargeted += c.getNetPower();
}
final List<Card> choicesCopy = Lists.newArrayList(choices);
for (final Card c : choicesCopy) {
if (c.getNetPower() > tgt.getMaxTotalPower(c, ability) - totalPowerTargeted) {
choices.remove(c);
}
}
}
// If all cards (including subability targets) must have the same controller
if (tgt.isSameController() && !targetedObjects.isEmpty()) {
final List<Card> list = Lists.newArrayList();

View File

@@ -1227,6 +1227,19 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
}
}
if (hasParam("MaxTotalTargetPower") && entity instanceof Card) {
int soFar = Aggregates.sum(getTargets().getTargetCards(), CardPredicates.Accessors.fnGetNetPower);
// only add if it isn't already targeting
if (!isTargeting(entity)) {
final Card c = (Card) entity;
soFar += c.getNetPower();
}
if (soFar > tr.getMaxTotalPower(getHostCard(),this)) {
return false;
}
}
if (tr.isDifferentControllers()) {
Player newController;
if (entity instanceof Card) {

View File

@@ -58,6 +58,14 @@ public class TargetChoices extends ForwardingList<GameObject> implements Cloneab
}
@Override
public final int getTotalTargetedPower() {
int totalPower = 0;
for (Card c : Iterables.filter(targets, Card.class)) {
totalPower += c.getNetPower();
}
return totalPower;
}
public final boolean add(final GameObject o) {
if (o instanceof Player || o instanceof Card || o instanceof SpellAbility) {
return super.add(o);

View File

@@ -73,7 +73,10 @@ public class TargetRestrictions {
// What's the max total CMC of targets?
private String maxTotalCMC;
// What's the max total power of targets?
private String maxTotalPower;
// Not sure what's up with Mandatory? Why wouldn't targeting be mandatory?
private boolean bMandatory = false;
@@ -92,6 +95,7 @@ public class TargetRestrictions {
this.minTargets = target.getMinTargets();
this.maxTargets = target.getMaxTargets();
this.maxTotalCMC = target.getMaxTotalCMC();
this.maxTotalPower = target.getMaxTotalPower();
this.tgtZone = target.getZone();
this.saValidTargeting = target.getSAValidTargeting();
this.uniqueTargets = target.isUniqueTargets();
@@ -163,6 +167,29 @@ public class TargetRestrictions {
this.maxTotalCMC = cmc;
}
/**
* <p>
* setMaxTotalPower.
* </p>
*
* @param power
* a String.
*/
public final void setMaxTotalPower(final String power) {
this.maxTotalPower = power;
}
/**
* <p>
* doesTarget.
* </p>
*
* @return a boolean.
*/
public final boolean doesTarget() {
return this.tgtValid;
}
/**
* <p>
* getValidTgts.
@@ -216,6 +243,19 @@ public class TargetRestrictions {
return AbilityUtils.calculateAmount(c, this.maxTotalCMC, sa);
}
/**
* Gets the max targets.
*
* @return the max targets
*/
private final String getMaxTotalPower() {
return this.maxTotalPower;
}
public final int getMaxTotalPower(final Card c, final SpellAbility sa) {
return AbilityUtils.calculateAmount(c, this.maxTotalPower, sa);
}
/**
* <p>
* Getter for the field <code>minTargets</code>.
@@ -541,7 +581,7 @@ public class TargetRestrictions {
for (final Card c : game.getCardsIn(this.tgtZone)) {
if (c.isValid(this.validTgts, srcCard.getController(), srcCard, sa)
&& (!isTargeted || sa.canTarget(c))
&& (!isTargeted || sa.canTarget(c))
&& !sa.getTargets().contains(c)) {
candidates.add(c);
}