forked from External/mage
[WOE] Implement Embereth Veteran
This commit is contained in:
parent
eeb0f9b7d8
commit
bd1b657e24
6 changed files with 211 additions and 0 deletions
49
Mage.Sets/src/mage/cards/e/EmberethVeteran.java
Normal file
49
Mage.Sets/src/mage/cards/e/EmberethVeteran.java
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package mage.cards.e;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.common.CreateRoleAttachedTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.RoleType;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class EmberethVeteran extends CardImpl {
|
||||
|
||||
public EmberethVeteran(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}");
|
||||
|
||||
this.subtype.add(SubType.HUMAN);
|
||||
this.subtype.add(SubType.KNIGHT);
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// {1}, Sacrifice Embereth Veteran: Create a Young Hero Role token attached to another target creature.
|
||||
Ability ability = new SimpleActivatedAbility(
|
||||
new CreateRoleAttachedTargetEffect(RoleType.YOUNG_HERO), new GenericManaCost(1)
|
||||
);
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
ability.addTarget(new TargetPermanent(StaticFilters.FILTER_ANOTHER_TARGET_CREATURE));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
private EmberethVeteran(final EmberethVeteran card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmberethVeteran copy() {
|
||||
return new EmberethVeteran(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ public final class WildsOfEldraine extends ExpansionSet {
|
|||
this.hasBoosters = false; // temporary
|
||||
|
||||
cards.add(new SetCardInfo("Cruel Somnophage", 222, Rarity.RARE, mage.cards.c.CruelSomnophage.class));
|
||||
cards.add(new SetCardInfo("Embereth Veteran", 127, Rarity.UNCOMMON, mage.cards.e.EmberethVeteran.class));
|
||||
cards.add(new SetCardInfo("Forest", 266, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Glass Casket", 16, Rarity.UNCOMMON, mage.cards.g.GlassCasket.class));
|
||||
cards.add(new SetCardInfo("Island", 263, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.RoleType;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class CreateRoleAttachedTargetEffect extends OneShotEffect {
|
||||
|
||||
private final RoleType roleType;
|
||||
|
||||
public CreateRoleAttachedTargetEffect(RoleType roleType) {
|
||||
super(Outcome.Benefit);
|
||||
this.roleType = roleType;
|
||||
}
|
||||
|
||||
private CreateRoleAttachedTargetEffect(final CreateRoleAttachedTargetEffect effect) {
|
||||
super(effect);
|
||||
this.roleType = effect.roleType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateRoleAttachedTargetEffect copy() {
|
||||
return new CreateRoleAttachedTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
Token token = roleType.createToken();
|
||||
token.putOntoBattlefield(1, game, source);
|
||||
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||
Permanent aura = game.getPermanent(tokenId);
|
||||
if (aura == null || !aura.hasSubtype(SubType.AURA, game)) {
|
||||
continue;
|
||||
}
|
||||
aura.getAbilities().get(0).getTargets().get(0).add(source.getFirstTarget(), game);
|
||||
aura.getAbilities().get(0).getEffects().get(0).apply(game, aura.getAbilities().get(0));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return "create a " + roleType.getName() + " Role token attached to " +
|
||||
getTargetPointer().describeTargets(mode.getTargets(), "it");
|
||||
}
|
||||
}
|
||||
34
Mage/src/main/java/mage/constants/RoleType.java
Normal file
34
Mage/src/main/java/mage/constants/RoleType.java
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package mage.constants;
|
||||
|
||||
import mage.game.permanent.token.Token;
|
||||
import mage.game.permanent.token.YoungHeroRoleToken;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public enum RoleType {
|
||||
YOUNG_HERO("Young Hero", YoungHeroRoleToken::new);
|
||||
|
||||
private final String name;
|
||||
private final Supplier<Token> supplier;
|
||||
|
||||
RoleType(String name, Supplier<Token> supplier) {
|
||||
this.name = name;
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Token createToken() {
|
||||
return supplier.get();
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +40,7 @@ public enum SubType {
|
|||
CARTOUCHE("Cartouche", SubTypeSet.EnchantmentType),
|
||||
CLASS("Class", SubTypeSet.EnchantmentType),
|
||||
CURSE("Curse", SubTypeSet.EnchantmentType),
|
||||
ROLE("Role", SubTypeSet.EnchantmentType),
|
||||
RUNE("Rune", SubTypeSet.EnchantmentType),
|
||||
SAGA("Saga", SubTypeSet.EnchantmentType),
|
||||
SHARD("Shard", SubTypeSet.EnchantmentType),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.SourceMatchesFilterCondition;
|
||||
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.constants.*;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.ToughnessPredicate;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class YoungHeroRoleToken extends TokenImpl {
|
||||
|
||||
private static final FilterPermanent filter = new FilterCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter.add(new ToughnessPredicate(ComparisonType.FEWER_THAN, 4));
|
||||
}
|
||||
|
||||
private static final Condition condition = new SourceMatchesFilterCondition(filter);
|
||||
|
||||
public YoungHeroRoleToken() {
|
||||
super("Young Hero", "Young Hero Role token");
|
||||
cardType.add(CardType.ENCHANTMENT);
|
||||
subtype.add(SubType.AURA);
|
||||
subtype.add(SubType.ROLE);
|
||||
|
||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||
Ability ability = new EnchantAbility(auraTarget);
|
||||
ability.addTarget(auraTarget);
|
||||
ability.addEffect(new AttachEffect(Outcome.BoostCreature));
|
||||
this.addAbility(ability);
|
||||
|
||||
// Enchanted creature has "Whenever this creature attacks, if its toughness is 3 or less, put a +1/+1 counter on it."
|
||||
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
|
||||
new ConditionalInterveningIfTriggeredAbility(
|
||||
new AttacksTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance())),
|
||||
condition, "Whenever this creature attacks, if its toughness is 3 or less, put a +1/+1 counter on it."
|
||||
), AttachmentType.AURA
|
||||
)));
|
||||
}
|
||||
|
||||
private YoungHeroRoleToken(final YoungHeroRoleToken token) {
|
||||
super(token);
|
||||
}
|
||||
|
||||
public YoungHeroRoleToken copy() {
|
||||
return new YoungHeroRoleToken(this);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue