mirror of
https://github.com/correl/mage.git
synced 2025-04-08 01:01:04 -09:00
[MAT] Implement Tyvar, the Bellicose
This commit is contained in:
parent
406d61a55f
commit
39d78aff2f
4 changed files with 133 additions and 6 deletions
Mage.Sets/src/mage
Mage/src/main/java/mage
110
Mage.Sets/src/mage/cards/t/TyvarTheBellicose.java
Normal file
110
Mage.Sets/src/mage/cards/t/TyvarTheBellicose.java
Normal file
|
@ -0,0 +1,110 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.AttacksWithCreaturesTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.dynamicvalue.common.SavedDamageValue;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.keyword.DeathtouchAbility;
|
||||
import mage.abilities.mana.ManaAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class TyvarTheBellicose extends CardImpl {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(SubType.ELF, "");
|
||||
|
||||
static {
|
||||
filter.add(TargetController.YOU.getControllerPredicate());
|
||||
}
|
||||
|
||||
public TyvarTheBellicose(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{G}");
|
||||
|
||||
this.addSuperType(SuperType.LEGENDARY);
|
||||
this.subtype.add(SubType.ELF);
|
||||
this.subtype.add(SubType.WARRIOR);
|
||||
this.power = new MageInt(5);
|
||||
this.toughness = new MageInt(4);
|
||||
|
||||
// Whenever one or more Elves you control attack, they gain deathtouch until end of turn.
|
||||
this.addAbility(new AttacksWithCreaturesTriggeredAbility(
|
||||
Zone.BATTLEFIELD, new GainAbilityTargetEffect(DeathtouchAbility.getInstance())
|
||||
.setText("they gain deathtouch until end of turn"), 1, filter, true
|
||||
).setTriggerPhrase("Whenever one or more Elves you control attack, "));
|
||||
|
||||
// Each creature you control has "Whenever a mana ability of this creature resolves, put a number of +1/+1 counters on it equal to the amount of mana this creature produced. This ability triggers only once each turn."
|
||||
this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect(
|
||||
new TyvarTheBellicoseTriggeredAbility(),
|
||||
Duration.WhileOnBattlefield,
|
||||
StaticFilters.FILTER_PERMANENT_CREATURE
|
||||
)));
|
||||
}
|
||||
|
||||
private TyvarTheBellicose(final TyvarTheBellicose card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TyvarTheBellicose copy() {
|
||||
return new TyvarTheBellicose(this);
|
||||
}
|
||||
}
|
||||
|
||||
class TyvarTheBellicoseTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
TyvarTheBellicoseTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(
|
||||
CounterType.P1P1.createInstance(0), SavedDamageValue.MANY, false
|
||||
));
|
||||
this.setTriggersOnce(true);
|
||||
}
|
||||
|
||||
private TyvarTheBellicoseTriggeredAbility(final TyvarTheBellicoseTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TyvarTheBellicoseTriggeredAbility copy() {
|
||||
return new TyvarTheBellicoseTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.MANA_ADDED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (isControlledBy(event.getPlayerId())
|
||||
&& event.getSourceId().equals(getSourceId())
|
||||
&& game
|
||||
.getAbility(event.getTargetId(), event.getSourceId())
|
||||
.map(ManaAbility.class::isInstance)
|
||||
.orElse(false)) {
|
||||
this.getEffects().setValue("damage", event.getAmount());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever a mana ability of this creature resolves, put a number of +1/+1 counters on it " +
|
||||
"equal to the amount of mana this creature produced. This ability triggers only once each turn.";
|
||||
}
|
||||
}
|
|
@ -46,6 +46,7 @@ public final class MarchOfTheMachineTheAftermath extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Spark Rupture", 5, Rarity.RARE, mage.cards.s.SparkRupture.class));
|
||||
cards.add(new SetCardInfo("The Kenriths' Royal Funeral", 34, Rarity.RARE, mage.cards.t.TheKenrithsRoyalFuneral.class));
|
||||
cards.add(new SetCardInfo("Training Grounds", 9, Rarity.RARE, mage.cards.t.TrainingGrounds.class));
|
||||
cards.add(new SetCardInfo("Tyvar the Bellicose", 48, Rarity.MYTHIC, mage.cards.t.TyvarTheBellicose.class));
|
||||
cards.add(new SetCardInfo("Undercity Upheaval", 25, Rarity.UNCOMMON, mage.cards.u.UndercityUpheaval.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,14 @@ import mage.filter.StaticFilters;
|
|||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTargets;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Styxo
|
||||
*/
|
||||
|
@ -16,6 +22,7 @@ public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
private final FilterCreaturePermanent filter;
|
||||
private final int minAttackers;
|
||||
private final boolean setTargetPointer;
|
||||
|
||||
public AttacksWithCreaturesTriggeredAbility(Effect effect, int minAttackers) {
|
||||
this(effect, minAttackers, StaticFilters.FILTER_PERMANENT_CREATURES);
|
||||
|
@ -26,9 +33,14 @@ public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
|
||||
public AttacksWithCreaturesTriggeredAbility(Zone zone, Effect effect, int minAttackers, FilterCreaturePermanent filter) {
|
||||
this(zone, effect, minAttackers, filter, false);
|
||||
}
|
||||
|
||||
public AttacksWithCreaturesTriggeredAbility(Zone zone, Effect effect, int minAttackers, FilterCreaturePermanent filter, boolean setTargetPointer) {
|
||||
super(zone, effect);
|
||||
this.filter = filter;
|
||||
this.minAttackers = minAttackers;
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
if (minAttackers == 1) {
|
||||
setTriggerPhrase("Whenever you attack, ");
|
||||
} else {
|
||||
|
@ -45,6 +57,7 @@ public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
|
|||
super(ability);
|
||||
this.filter = ability.filter;
|
||||
this.minAttackers = ability.minAttackers;
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,18 +75,21 @@ public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (!isControlledBy(game.getCombat().getAttackingPlayerId())) {
|
||||
return false;
|
||||
}
|
||||
int attackers = game
|
||||
List<Permanent> attackers = game
|
||||
.getCombat()
|
||||
.getAttackers()
|
||||
.stream()
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(permanent -> filter.match(permanent, controllerId, this, game))
|
||||
.mapToInt(x -> 1)
|
||||
.sum();
|
||||
if (attackers < minAttackers) {
|
||||
.collect(Collectors.toList());
|
||||
if (attackers.size() < minAttackers) {
|
||||
return false;
|
||||
}
|
||||
getEffects().setValue("attackers", attackers);
|
||||
getEffects().setValue("attackers", attackers.size());
|
||||
if (setTargetPointer) {
|
||||
getEffects().setTargetPointer(new FixedTargets(attackers, game));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public class ManaEvent extends GameEvent {
|
|||
protected Mana mana;
|
||||
|
||||
public ManaEvent(EventType type, UUID targetId, Ability source, UUID playerId, Mana mana) {
|
||||
super(type, targetId, source, playerId);
|
||||
super(type, targetId, source, playerId, mana.count(), false);
|
||||
this.mana = mana;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue