mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
[M21] Implement more cards (#6730)
* EnthrallingHold * ArchfiendsVessel * ConspicuousSnoop * HoodedBlightfang * commit set updates * fix text * fix Archfiend's Vessel cast from graveyard trigger and Enthralling Hold text
This commit is contained in:
parent
8906f3be7b
commit
6fa1ad3aaa
11 changed files with 465 additions and 104 deletions
|
|
@ -76,9 +76,9 @@ public class AttacksCreatureYouControlTriggeredAbility extends TriggeredAbilityI
|
|||
public String getRule() {
|
||||
String an;
|
||||
String who = filter.getMessage();
|
||||
if (who.startsWith("another")) {
|
||||
if (who.startsWith("another") || who.startsWith("a ")) {
|
||||
an = "";
|
||||
} else if (who.startsWith("a")) {
|
||||
} else if (who.length() > 0 && "aeiou".contains(who.charAt(0) + "")) {
|
||||
an = "an ";
|
||||
} else {
|
||||
an = "a ";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
public class DestroyPlaneswalkerWhenDamagedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final FilterPermanent filter;
|
||||
|
||||
public DestroyPlaneswalkerWhenDamagedTriggeredAbility() {
|
||||
this((FilterPermanent) null);
|
||||
}
|
||||
|
||||
public DestroyPlaneswalkerWhenDamagedTriggeredAbility(FilterPermanent filter) {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
private DestroyPlaneswalkerWhenDamagedTriggeredAbility(final DestroyPlaneswalkerWhenDamagedTriggeredAbility effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DestroyPlaneswalkerWhenDamagedTriggeredAbility copy() {
|
||||
return new DestroyPlaneswalkerWhenDamagedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = getSourcePermanentIfItStillExists(game);
|
||||
if (permanent != null) {
|
||||
boolean applies = filter != null ?
|
||||
filter.match(permanent, game) : event.getSourceId().equals(getSourceId());
|
||||
if (applies) {
|
||||
Effect effect = new DestroyTargetEffect();
|
||||
effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
|
||||
this.getEffects().clear();
|
||||
this.addEffect(effect);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever " + (filter != null ? filter.getMessage() : "this creature") + " deals damage to a planeswalker, destroy that planeswalker.";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
public class GainActivatedAbilitiesOfTopCardEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final FilterCard filter;
|
||||
|
||||
public GainActivatedAbilitiesOfTopCardEffect(FilterCard filter) {
|
||||
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
staticText = "As long as the top card of your library is " + filter.getMessage() + ", {this} has all activated abilities of that card";
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public GainActivatedAbilitiesOfTopCardEffect(final GainActivatedAbilitiesOfTopCardEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainActivatedAbilitiesOfTopCardEffect copy() {
|
||||
return new GainActivatedAbilitiesOfTopCardEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
Card card = player.getLibrary().getFromTop(game);
|
||||
if (card != null && filter.match(card, game)) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
for (Ability ability : card.getAbilities(game)) {
|
||||
if (ability instanceof ActivatedAbility) {
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,16 +1,10 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
import mage.abilities.common.DestroyPlaneswalkerWhenDamagedTriggeredAbility;
|
||||
import mage.abilities.keyword.DeathtouchAbility;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
|
@ -25,7 +19,7 @@ public final class AssassinToken2 extends TokenImpl {
|
|||
power = new MageInt(1);
|
||||
toughness = new MageInt(1);
|
||||
addAbility(DeathtouchAbility.getInstance());
|
||||
addAbility(new AssassinToken2TriggeredAbility());
|
||||
addAbility(new DestroyPlaneswalkerWhenDamagedTriggeredAbility());
|
||||
|
||||
setOriginalExpansionSetCode("WAR");
|
||||
}
|
||||
|
|
@ -39,40 +33,3 @@ public final class AssassinToken2 extends TokenImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class AssassinToken2TriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
AssassinToken2TriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
}
|
||||
|
||||
private AssassinToken2TriggeredAbility(final AssassinToken2TriggeredAbility effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssassinToken2TriggeredAbility copy() {
|
||||
return new AssassinToken2TriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getSourceId().equals(getSourceId())) {
|
||||
Effect effect = new DestroyTargetEffect();
|
||||
effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
|
||||
this.getEffects().clear();
|
||||
this.addEffect(effect);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever this creature deals damage to a planeswalker, destroy that planeswalker.";
|
||||
}
|
||||
}
|
||||
|
|
@ -5,8 +5,6 @@
|
|||
*/
|
||||
package mage.watchers.common;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.constants.Zone;
|
||||
|
|
@ -17,6 +15,12 @@ import mage.game.events.GameEvent.EventType;
|
|||
import mage.game.stack.Spell;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
|
|
@ -24,6 +28,7 @@ import mage.watchers.Watcher;
|
|||
public class SpellsCastWatcher extends Watcher {
|
||||
|
||||
private final Map<UUID, List<Spell>> spellsCast = new HashMap<>();
|
||||
private final Map<UUID, List<Spell>> spellsCastFromGraveyard = new HashMap<>();
|
||||
private int nonCreatureSpells;
|
||||
|
||||
public SpellsCastWatcher() {
|
||||
|
|
@ -42,13 +47,21 @@ public class SpellsCastWatcher extends Watcher {
|
|||
}
|
||||
if (spell != null) {
|
||||
List<Spell> spells;
|
||||
List<Spell> graveyardSpells;
|
||||
if (!spellsCast.containsKey(spell.getControllerId())) {
|
||||
spells = new ArrayList<>();
|
||||
spellsCast.put(spell.getControllerId(), spells);
|
||||
graveyardSpells = new ArrayList<>();
|
||||
spellsCastFromGraveyard.put(spell.getControllerId(), graveyardSpells);
|
||||
|
||||
} else {
|
||||
spells = spellsCast.get(spell.getControllerId());
|
||||
graveyardSpells = spellsCastFromGraveyard.get(spell.getControllerId());
|
||||
}
|
||||
spells.add(spell.copy()); // copy needed because attributes like color could be changed later
|
||||
if (event.getZone() == Zone.GRAVEYARD) {
|
||||
graveyardSpells.add(spell.copy());
|
||||
}
|
||||
if (StaticFilters.FILTER_SPELL_NON_CREATURE.match(spell, game)) {
|
||||
nonCreatureSpells++;
|
||||
}
|
||||
|
|
@ -61,12 +74,17 @@ public class SpellsCastWatcher extends Watcher {
|
|||
super.reset();
|
||||
nonCreatureSpells = 0;
|
||||
spellsCast.clear();
|
||||
spellsCastFromGraveyard.clear();
|
||||
}
|
||||
|
||||
public List<Spell> getSpellsCastThisTurn(UUID playerId) {
|
||||
return spellsCast.get(playerId);
|
||||
}
|
||||
|
||||
public List<Spell> getSpellsCastFromGraveyardThisTurn(UUID playerId) {
|
||||
return spellsCastFromGraveyard.get(playerId);
|
||||
}
|
||||
|
||||
public int getNumberOfNonCreatureSpells() {
|
||||
return nonCreatureSpells;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue