[ECL] Implement Selfless Safewright (#14227)

* Update gen-card.pl to take all command line args as a space-seperated card name to remove need for quoting or escaping

* [ECL] Implement Selfless Safewright
This commit is contained in:
Muz 2026-01-10 16:14:14 -06:00 committed by GitHub
parent 44a9c2722b
commit ed3305cf59
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 120 additions and 1 deletions

View file

@ -0,0 +1,115 @@
package mage.cards.s;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import mage.MageInt;
import mage.MageObject;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTargets;
import mage.abilities.keyword.FlashAbility;
import mage.abilities.keyword.HexproofAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.ConvokeAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.Choice;
import mage.choices.ChoiceCreatureType;
import mage.constants.CardType;
import mage.constants.Outcome;
/**
*
* @author muz
*/
public final class SelflessSafewright extends CardImpl {
public SelflessSafewright(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}");
this.subtype.add(SubType.ELF);
this.subtype.add(SubType.WARRIOR);
this.power = new MageInt(4);
this.toughness = new MageInt(2);
// Flash
this.addAbility(FlashAbility.getInstance());
// Convoke
this.addAbility(new ConvokeAbility());
// When this creature enters, choose a creature type. Other permanents you control of that type gain hexproof and indestructible until end of turn.
this.addAbility(new AsEntersBattlefieldAbility(new SelflessSafewrightEffect()));
}
private SelflessSafewright(final SelflessSafewright card) {
super(card);
}
@Override
public SelflessSafewright copy() {
return new SelflessSafewright(this);
}
}
class SelflessSafewrightEffect extends OneShotEffect {
SelflessSafewrightEffect() {
super(Outcome.Benefit);
staticText = "choose a creature type. Other permanents you control of that type gain hexproof and indestructible until end of turn";
}
private SelflessSafewrightEffect(final SelflessSafewrightEffect effect) {
super(effect);
}
@Override
public SelflessSafewrightEffect copy() {
return new SelflessSafewrightEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Choice choice = new ChoiceCreatureType(game, source);
controller.choose(outcome, choice, game);
SubType subType = SubType.byDescription(choice.getChoiceKey());
if (subType == null) {
return false;
}
game.informPlayers(controller.getLogName() + " chooses " + subType);
List<Permanent> permanents = game
.getBattlefield()
.getActivePermanents(
StaticFilters.FILTER_OTHER_CONTROLLED_PERMANENTS,
source.getControllerId(), source, game
).stream()
.filter(permanent -> permanent.hasSubtype(subType, game))
.collect(Collectors.toList());
if (permanents.isEmpty()) {
return false;
}
game.addEffect(new GainAbilityTargetEffect(
HexproofAbility.getInstance()
).setTargetPointer(new FixedTargets(permanents, game)), source);
game.addEffect(new GainAbilityTargetEffect(
IndestructibleAbility.getInstance()
).setTargetPointer(new FixedTargets(permanents, game)), source);
return true;
}
}

View file

@ -270,6 +270,10 @@ public final class LorwynEclipsed extends ExpansionSet {
cards.add(new SetCardInfo("Scuzzback Scrounger", 320, Rarity.RARE, mage.cards.s.ScuzzbackScrounger.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Sear", 154, Rarity.UNCOMMON, mage.cards.s.Sear.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Sear", 405, Rarity.UNCOMMON, mage.cards.s.Sear.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Selfless Safewright", 193, Rarity.RARE, mage.cards.s.SelflessSafewright.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Selfless Safewright", 367, Rarity.RARE, mage.cards.s.SelflessSafewright.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Selfless Safewright", 391, Rarity.MYTHIC, mage.cards.s.SelflessSafewright.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Selfless Safewright", 401, Rarity.MYTHIC, mage.cards.s.SelflessSafewright.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Shimmercreep", 120, Rarity.UNCOMMON, mage.cards.s.Shimmercreep.class));
cards.add(new SetCardInfo("Shinestriker", 68, Rarity.UNCOMMON, mage.cards.s.Shinestriker.class));
cards.add(new SetCardInfo("Shore Lurker", 34, Rarity.COMMON, mage.cards.s.ShoreLurker.class));

View file

@ -90,7 +90,7 @@ $raritiesConversion{'Special'} = 'SPECIAL';
$raritiesConversion{'Bonus'} = 'BONUS';
# Get card name
my $cardName = $ARGV[0];
my $cardName = join ' ', @ARGV;
if (!$cardName) {
print 'Enter a card name: ';
$cardName = <STDIN>;