mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
[EOC] fix Moxite Refinery cost
This commit is contained in:
parent
2b5650bdfe
commit
0a3a2d1199
2 changed files with 40 additions and 22 deletions
|
|
@ -33,9 +33,9 @@ public final class MoxiteRefinery extends CardImpl {
|
||||||
CounterType.CHARGE.createInstance(), GetXValue.instance
|
CounterType.CHARGE.createInstance(), GetXValue.instance
|
||||||
), new GenericManaCost(2)).setTiming(TimingRule.SORCERY);
|
), new GenericManaCost(2)).setTiming(TimingRule.SORCERY);
|
||||||
ability.addCost(new TapSourceCost());
|
ability.addCost(new TapSourceCost());
|
||||||
// TODO: this cost is not actually the right one to use here
|
|
||||||
ability.addCost(new RemoveVariableCountersTargetCost(
|
ability.addCost(new RemoveVariableCountersTargetCost(
|
||||||
StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE, CounterType.CHARGE
|
StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE,
|
||||||
|
null, "X", 0, true, null
|
||||||
));
|
));
|
||||||
ability.addTarget(new TargetArtifactPermanent());
|
ability.addTarget(new TargetArtifactPermanent());
|
||||||
ability.getModes().setChooseText("choose one. Activate only as a sorcery.");
|
ability.getModes().setChooseText("choose one. Activate only as a sorcery.");
|
||||||
|
|
|
||||||
|
|
@ -8,19 +8,21 @@ import mage.counters.Counter;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author LevelX
|
* @author LevelX
|
||||||
*/
|
*/
|
||||||
public class RemoveVariableCountersTargetCost extends VariableCostImpl {
|
public class RemoveVariableCountersTargetCost extends VariableCostImpl {
|
||||||
|
|
||||||
protected FilterPermanent filter;
|
protected final FilterPermanent filter;
|
||||||
protected CounterType counterTypeToRemove;
|
protected final CounterType counterTypeToRemove;
|
||||||
protected int minValue;
|
protected final int minValue;
|
||||||
|
protected final boolean onlyOne;
|
||||||
|
|
||||||
public RemoveVariableCountersTargetCost(FilterPermanent filter) {
|
public RemoveVariableCountersTargetCost(FilterPermanent filter) {
|
||||||
this(filter, null);
|
this(filter, null);
|
||||||
|
|
@ -35,15 +37,20 @@ public class RemoveVariableCountersTargetCost extends VariableCostImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoveVariableCountersTargetCost(FilterPermanent filter, CounterType counterTypeToRemove, String xText, int minValue, String text) {
|
public RemoveVariableCountersTargetCost(FilterPermanent filter, CounterType counterTypeToRemove, String xText, int minValue, String text) {
|
||||||
|
this(filter, counterTypeToRemove, xText, minValue, false, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RemoveVariableCountersTargetCost(FilterPermanent filter, CounterType counterTypeToRemove, String xText, int minValue, boolean onlyOne, String text) {
|
||||||
super(VariableCostType.NORMAL, xText, new StringBuilder(counterTypeToRemove != null ? counterTypeToRemove.getName() + ' ' : "").append("counters to remove").toString());
|
super(VariableCostType.NORMAL, xText, new StringBuilder(counterTypeToRemove != null ? counterTypeToRemove.getName() + ' ' : "").append("counters to remove").toString());
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.counterTypeToRemove = counterTypeToRemove;
|
this.counterTypeToRemove = counterTypeToRemove;
|
||||||
|
this.minValue = minValue;
|
||||||
|
this.onlyOne = onlyOne;
|
||||||
if (text != null && !text.isEmpty()) {
|
if (text != null && !text.isEmpty()) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
} else {
|
} else {
|
||||||
this.text = setText();
|
this.text = setText();
|
||||||
}
|
}
|
||||||
this.minValue = minValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RemoveVariableCountersTargetCost(final RemoveVariableCountersTargetCost cost) {
|
protected RemoveVariableCountersTargetCost(final RemoveVariableCountersTargetCost cost) {
|
||||||
|
|
@ -51,6 +58,7 @@ public class RemoveVariableCountersTargetCost extends VariableCostImpl {
|
||||||
this.filter = cost.filter;
|
this.filter = cost.filter;
|
||||||
this.counterTypeToRemove = cost.counterTypeToRemove;
|
this.counterTypeToRemove = cost.counterTypeToRemove;
|
||||||
this.minValue = cost.minValue;
|
this.minValue = cost.minValue;
|
||||||
|
this.onlyOne = cost.onlyOne;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -59,11 +67,19 @@ public class RemoveVariableCountersTargetCost extends VariableCostImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String setText() {
|
private String setText() {
|
||||||
StringBuilder sb = new StringBuilder("Remove ").append(xText);
|
StringBuilder sb = new StringBuilder("Remove ");
|
||||||
|
sb.append(xText);
|
||||||
if (counterTypeToRemove != null) {
|
if (counterTypeToRemove != null) {
|
||||||
sb.append(' ').append(counterTypeToRemove.getName());
|
sb.append(' ');
|
||||||
|
sb.append(counterTypeToRemove.getName());
|
||||||
|
}
|
||||||
|
sb.append(" counters from ");
|
||||||
|
if (onlyOne) {
|
||||||
|
sb.append(CardUtil.addArticle(filter.getMessage()));
|
||||||
|
} else {
|
||||||
|
sb.append("among ");
|
||||||
|
sb.append(filter.getMessage());
|
||||||
}
|
}
|
||||||
sb.append(" counters from among ").append(filter.getMessage());
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,22 +100,24 @@ public class RemoveVariableCountersTargetCost extends VariableCostImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxValue(Ability source, Game game) {
|
public int getMaxValue(Ability source, Game game) {
|
||||||
int maxValue = 0;
|
IntStream stream = game
|
||||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
.getBattlefield()
|
||||||
if (counterTypeToRemove != null) {
|
.getAllActivePermanents(filter, source.getControllerId(), game)
|
||||||
maxValue += permanent.getCounters(game).getCount(counterTypeToRemove);
|
.stream()
|
||||||
} else {
|
.map(permanent -> permanent.getCounters(game))
|
||||||
for (Counter counter : permanent.getCounters(game).values()) {
|
.mapToInt(counters -> counterTypeToRemove == null
|
||||||
maxValue += counter.getCount();
|
? counters.values().stream().mapToInt(Counter::getCount).sum()
|
||||||
|
: counters.getCount(counterTypeToRemove));
|
||||||
|
if (onlyOne) {
|
||||||
|
return stream.max().orElse(0);
|
||||||
}
|
}
|
||||||
}
|
return stream.sum();
|
||||||
}
|
|
||||||
return maxValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cost getFixedCostsFromAnnouncedValue(int xValue) {
|
public Cost getFixedCostsFromAnnouncedValue(int xValue) {
|
||||||
return new RemoveCounterCost(new TargetPermanent(minValue, Integer.MAX_VALUE, filter, true), counterTypeToRemove, xValue);
|
return new RemoveCounterCost(
|
||||||
|
new TargetPermanent(minValue, onlyOne ? 1 : Integer.MAX_VALUE, filter, true), counterTypeToRemove, xValue
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue