mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Merge pull request #5108 from NoahGleason/shape-of-the-wiitigo
Implement Shape of the Wiitigo
This commit is contained in:
commit
2cdd835ab5
4 changed files with 227 additions and 4 deletions
|
|
@ -0,0 +1,91 @@
|
|||
|
||||
package mage.abilities.effects.common.counter;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.Counter;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noahg
|
||||
*/
|
||||
public class RemoveCountersAttachedEffect extends OneShotEffect {
|
||||
|
||||
private Counter counter;
|
||||
private DynamicValue amount;
|
||||
private String textEnchanted;
|
||||
|
||||
public RemoveCountersAttachedEffect(Counter counter, String textEnchanted) {
|
||||
this(counter, new StaticValue(0), textEnchanted);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param counter
|
||||
* @param amount this amount will be added to the counter instances
|
||||
* @param textEnchanted text used for the enchanted permanent in rule text
|
||||
*/
|
||||
public RemoveCountersAttachedEffect(Counter counter, DynamicValue amount, String textEnchanted) {
|
||||
super(Outcome.UnboostCreature);
|
||||
this.counter = counter.copy();
|
||||
this.amount = amount;
|
||||
this.textEnchanted = textEnchanted;
|
||||
setText();
|
||||
}
|
||||
|
||||
public RemoveCountersAttachedEffect(final RemoveCountersAttachedEffect effect) {
|
||||
super(effect);
|
||||
if (effect.counter != null) {
|
||||
this.counter = effect.counter.copy();
|
||||
}
|
||||
this.amount = effect.amount;
|
||||
this.textEnchanted = effect.textEnchanted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.getAttachedTo() != null) {
|
||||
Permanent attachedTo = game.getPermanent(permanent.getAttachedTo());
|
||||
if (attachedTo != null && counter != null) {
|
||||
Counter newCounter = counter.copy();
|
||||
newCounter.add(amount.calculate(game, source, this));
|
||||
attachedTo.removeCounters(newCounter, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// put a +1/+1 counter on it
|
||||
sb.append("remove ");
|
||||
if (counter.getCount() > 1) {
|
||||
sb.append(CardUtil.numberToText(counter.getCount())).append(' ');
|
||||
sb.append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counters from ");
|
||||
} else {
|
||||
sb.append("a ");
|
||||
sb.append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counter from ");
|
||||
}
|
||||
sb.append(textEnchanted);
|
||||
if (!amount.getMessage().isEmpty()) {
|
||||
sb.append(" for each ").append(amount.getMessage());
|
||||
}
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoveCountersAttachedEffect copy() {
|
||||
return new RemoveCountersAttachedEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -30,13 +30,11 @@ public class AttackedLastTurnWatcher extends Watcher {
|
|||
public AttackedLastTurnWatcher(final AttackedLastTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Set<MageObjectReference>> entry : watcher.attackedLastTurnCreatures.entrySet()) {
|
||||
Set<MageObjectReference> allAttackersCopy = new HashSet<>();
|
||||
allAttackersCopy.addAll(entry.getValue());
|
||||
Set<MageObjectReference> allAttackersCopy = new HashSet<>(entry.getValue());
|
||||
attackedLastTurnCreatures.put(entry.getKey(), allAttackersCopy);
|
||||
}
|
||||
for (Entry<UUID, Set<MageObjectReference>> entry : watcher.attackedThisTurnCreatures.entrySet()) {
|
||||
Set<MageObjectReference> allAttackersCopy = new HashSet<>();
|
||||
allAttackersCopy.addAll(entry.getValue());
|
||||
Set<MageObjectReference> allAttackersCopy = new HashSet<>(entry.getValue());
|
||||
attackedThisTurnCreatures.put(entry.getKey(), allAttackersCopy);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue