[EOE] Implement The Seriema

This commit is contained in:
theelk801 2025-07-08 16:54:06 -04:00
parent 3f885afc21
commit 850efb06d5
5 changed files with 306 additions and 0 deletions

View file

@ -0,0 +1,74 @@
package mage.abilities.keyword;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapTargetCost;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.List;
import java.util.Optional;
/**
* @author TheElk801
*/
public class StationAbility extends SimpleActivatedAbility {
public StationAbility() {
super(Zone.BATTLEFIELD, new StationAbilityEffect(), new TapTargetCost(StaticFilters.FILTER_OTHER_CONTROLLED_CREATURE));
}
private StationAbility(final StationAbility ability) {
super(ability);
}
@Override
public StationAbility copy() {
return new StationAbility(this);
}
@Override
public String getRule() {
return "station <i>(Tap another creature you control: Put charge counters equal to its power on {this}. Station only as a sorcery.)</i>";
}
}
class StationAbilityEffect extends OneShotEffect {
StationAbilityEffect() {
super(Outcome.Benefit);
}
private StationAbilityEffect(final StationAbilityEffect effect) {
super(effect);
}
@Override
public StationAbilityEffect copy() {
return new StationAbilityEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent == null) {
return false;
}
int power = Optional
.ofNullable((List<Permanent>) getValue("tappedPermanents"))
.map(permanents -> permanents
.stream()
.map(MageObject::getPower)
.mapToInt(MageInt::getValue)
.sum())
.orElse(0);
return power > 0 && permanent.addCounters(CounterType.CHARGE.createInstance(power), source, game);
}
}

View file

@ -0,0 +1,155 @@
package mage.abilities.keyword;
import mage.abilities.Ability;
import mage.abilities.StaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.*;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.util.CardUtil;
import java.util.stream.Collectors;
/**
* @author TheElk801
*/
public class StationLevelAbility extends StaticAbility {
private final int level;
public StationLevelAbility(int level) {
super(Zone.BATTLEFIELD, null);
this.level = level;
}
private StationLevelAbility(final StationLevelAbility ability) {
super(ability);
this.level = ability.level;
}
@Override
public StationLevelAbility copy() {
return new StationLevelAbility(this);
}
public StationLevelAbility withLevelAbility(Ability ability) {
this.addEffect(new StationLevelAbilityEffect(ability, level));
return this;
}
public StationLevelAbility withPT(int power, int toughness) {
this.addEffect(new StationLevelCreatureEffect(power, toughness, level));
return this;
}
@Override
public String getRule() {
return "STATION " + level + "+" + this
.getEffects()
.stream()
.map(effect -> effect.getText(this.getModes().getMode()))
.map(CardUtil::getTextWithFirstCharUpperCase)
.collect(Collectors.joining("<br>"));
}
}
class StationLevelAbilityEffect extends ContinuousEffectImpl {
private final Ability ability;
private final int level;
StationLevelAbilityEffect(Ability ability, int level) {
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
this.ability = ability;
this.level = level;
this.ability.setRuleVisible(false);
this.staticText = ability.getRule();
}
private StationLevelAbilityEffect(final StationLevelAbilityEffect effect) {
super(effect);
this.ability = effect.ability;
this.level = effect.level;
}
@Override
public StationLevelAbilityEffect copy() {
return new StationLevelAbilityEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent == null || permanent.getCounters(game).getCount(CounterType.CHARGE) < level) {
return false;
}
permanent.addAbility(ability, source.getSourceId(), game);
return true;
}
}
class StationLevelCreatureEffect extends ContinuousEffectImpl {
private final int power;
private final int toughness;
private final int level;
StationLevelCreatureEffect(int power, int toughness, int level) {
super(Duration.WhileOnBattlefield, Outcome.BecomeCreature);
this.power = power;
this.toughness = toughness;
this.level = level;
staticText = power + "/" + toughness;
}
private StationLevelCreatureEffect(final StationLevelCreatureEffect effect) {
super(effect);
this.power = effect.power;
this.toughness = effect.toughness;
this.level = effect.level;
}
@Override
public StationLevelCreatureEffect copy() {
return new StationLevelCreatureEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent == null || permanent.getCounters(game).getCount(CounterType.CHARGE) < level) {
return false;
}
switch (layer) {
case TypeChangingEffects_4:
permanent.addCardType(game, CardType.ARTIFACT, CardType.CREATURE);
return true;
case PTChangingEffects_7:
if (sublayer != SubLayer.SetPT_7b) {
return false;
}
permanent.getPower().setModifiedBaseValue(power);
permanent.getToughness().setModifiedBaseValue(toughness);
return true;
default:
return false;
}
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
switch (layer) {
case TypeChangingEffects_4:
case PTChangingEffects_7:
return true;
default:
return false;
}
}
}