mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
implement [BLB] Salvation Swan
This commit is contained in:
parent
d29c57d2af
commit
62a99a0497
8 changed files with 245 additions and 4 deletions
|
|
@ -1,7 +1,8 @@
|
|||
package mage.abilities.effects;
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.MeldCard;
|
||||
import mage.constants.Outcome;
|
||||
|
|
@ -11,6 +12,7 @@ import mage.counters.Counters;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
// TODO: refactor into ReturnToBattlefieldUnderOwnerControlWithCounterTargetEffect
|
||||
public class ReturnMORToBattlefieldUnderOwnerControlWithCounterEffect extends OneShotEffect {
|
||||
|
||||
private final MageObjectReference objectToReturn;
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.Counters;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public class ReturnToBattlefieldUnderOwnerControlWithCounterTargetEffect extends ReturnToBattlefieldUnderOwnerControlTargetEffect {
|
||||
|
||||
private final Counters counters;
|
||||
private final String counterText;
|
||||
|
||||
public ReturnToBattlefieldUnderOwnerControlWithCounterTargetEffect(Counter counter, boolean returnFromExileZoneOnly) {
|
||||
this(counter, false, returnFromExileZoneOnly);
|
||||
}
|
||||
|
||||
public ReturnToBattlefieldUnderOwnerControlWithCounterTargetEffect(Counter counter, boolean additional, boolean returnFromExileZoneOnly) {
|
||||
super(false, returnFromExileZoneOnly);
|
||||
this.counters = new Counters();
|
||||
this.counters.addCounter(counter);
|
||||
this.counterText = makeText(counter, additional);
|
||||
}
|
||||
|
||||
protected ReturnToBattlefieldUnderOwnerControlWithCounterTargetEffect(final ReturnToBattlefieldUnderOwnerControlWithCounterTargetEffect effect) {
|
||||
super(effect);
|
||||
this.counters = effect.counters.copy();
|
||||
this.counterText = effect.counterText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReturnToBattlefieldUnderOwnerControlWithCounterTargetEffect copy() {
|
||||
return new ReturnToBattlefieldUnderOwnerControlWithCounterTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
|
||||
game.setEnterWithCounters(targetId, counters.copy());
|
||||
}
|
||||
return super.apply(game, source);
|
||||
}
|
||||
|
||||
private static String makeText(Counter counter, boolean additional) {
|
||||
StringBuilder sb = new StringBuilder(" with ");
|
||||
if (additional) {
|
||||
sb.append(CardUtil.numberToText(counter.getCount(), "an"));
|
||||
sb.append(" additional");
|
||||
} else {
|
||||
sb.append(CardUtil.numberToText(counter.getCount(), "a"));
|
||||
}
|
||||
sb.append(' ');
|
||||
sb.append(counter.getName());
|
||||
sb.append(" counter");
|
||||
if (counter.getCount() != 1) {
|
||||
sb.append('s');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return super.getText(mode) + counterText + (getTargetPointer().isPlural(mode.getTargets()) ? " on them" : " on it");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue