mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 20:32:06 -08:00
[WOE] Implement Gruff Triplets (#10791)
* [WOE] Implement (Leaked) Gruff Triplets * fix name predicate * remove unecessary file with wrong predicate --------- Co-authored-by: Evan Kranzler <theelk801@gmail.com>
This commit is contained in:
parent
d499efe971
commit
493cb811d5
3 changed files with 107 additions and 3 deletions
|
|
@ -2,6 +2,9 @@ package mage.abilities.effects.common.counter;
|
|||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.Counter;
|
||||
|
|
@ -9,6 +12,7 @@ import mage.filter.FilterPermanent;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* @author North
|
||||
|
|
@ -16,19 +20,25 @@ import mage.players.Player;
|
|||
public class AddCountersAllEffect extends OneShotEffect {
|
||||
|
||||
private final Counter counter;
|
||||
private DynamicValue amount;
|
||||
private final FilterPermanent filter;
|
||||
|
||||
public AddCountersAllEffect(Counter counter, FilterPermanent filter) {
|
||||
this(counter, StaticValue.get(0), filter);
|
||||
}
|
||||
|
||||
public AddCountersAllEffect(Counter counter, DynamicValue amount, FilterPermanent filter) {
|
||||
super(Outcome.Benefit);
|
||||
this.counter = counter;
|
||||
this.amount = amount;
|
||||
this.filter = filter;
|
||||
staticText = "put " + counter.getDescription() + " on each " + filter.getMessage();
|
||||
}
|
||||
|
||||
protected AddCountersAllEffect(final AddCountersAllEffect effect) {
|
||||
super(effect);
|
||||
this.counter = effect.counter.copy();
|
||||
this.filter = effect.filter.copy();
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -38,9 +48,21 @@ public class AddCountersAllEffect extends OneShotEffect {
|
|||
if (controller != null && sourceObject != null) {
|
||||
if (counter != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
||||
permanent.addCounters(counter.copy(), source.getControllerId(), source, game);
|
||||
Counter newCounter = counter.copy();
|
||||
int calculated = amount.calculate(game, source, this); // 0 -- you must use default couner
|
||||
if (calculated < 0) {
|
||||
continue;
|
||||
} else if (calculated == 0) {
|
||||
// use original counter
|
||||
} else {
|
||||
// increase to calculated value
|
||||
newCounter.remove(newCounter.getCount());
|
||||
newCounter.add(calculated);
|
||||
}
|
||||
|
||||
permanent.addCounters(newCounter, source.getControllerId(), source, game);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts " + counter.getCount() + ' ' + counter.getName()
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts " + newCounter.getCount() + ' ' + newCounter.getName()
|
||||
+ " counter on " + permanent.getLogName());
|
||||
}
|
||||
}
|
||||
|
|
@ -50,6 +72,14 @@ public class AddCountersAllEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (!staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return CardUtil.getAddRemoveCountersText(amount, counter, getTargetPointer().describeTargets(mode.getTargets(), "that creature"), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddCountersAllEffect copy() {
|
||||
return new AddCountersAllEffect(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue