[AFR] Implemented Keen-Eared Sentry

This commit is contained in:
Evan Kranzler 2021-07-07 18:52:55 -04:00
parent 9d1b84102f
commit d846f6113a
4 changed files with 124 additions and 0 deletions

View file

@ -0,0 +1,118 @@
package mage.cards.k;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.common.continuous.GainAbilityControllerEffect;
import mage.abilities.keyword.HexproofAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.watchers.Watcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class KeenEaredSentry extends CardImpl {
public KeenEaredSentry(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.SOLDIER);
this.power = new MageInt(2);
this.toughness = new MageInt(1);
// You have hexproof.
this.addAbility(new SimpleStaticAbility(new GainAbilityControllerEffect(HexproofAbility.getInstance())));
// Your opponents can't venture into the dungeon more than once each turn.
this.addAbility(new SimpleStaticAbility(new KeenEaredSentryEffect()), new KeenEaredSentryWatcher());
}
private KeenEaredSentry(final KeenEaredSentry card) {
super(card);
}
@Override
public KeenEaredSentry copy() {
return new KeenEaredSentry(this);
}
}
class KeenEaredSentryEffect extends ContinuousRuleModifyingEffectImpl {
KeenEaredSentryEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "your opponents can't venture into the dungeon more than once each turn";
}
private KeenEaredSentryEffect(final KeenEaredSentryEffect effect) {
super(effect);
}
@Override
public KeenEaredSentryEffect copy() {
return new KeenEaredSentryEffect(this);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.VENTURE;
}
@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject == null) {
return null;
}
return "You can't venture into the dungeon more than once each turn. (" + sourceObject.getName() + ')';
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return game.getOpponents(source.getControllerId()).contains(event.getTargetId())
&& KeenEaredSentryWatcher.checkPlayer(event.getTargetId(), game);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
}
class KeenEaredSentryWatcher extends Watcher {
private final Set<UUID> playerSet = new HashSet<>();
KeenEaredSentryWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.VENTURED) {
playerSet.add(event.getTargetId());
}
}
@Override
public void reset() {
super.reset();
playerSet.clear();
}
static boolean checkPlayer(UUID playerId, Game game) {
KeenEaredSentryWatcher watcher = game.getState().getWatcher(KeenEaredSentryWatcher.class);
return watcher != null && watcher.playerSet.contains(playerId);
}
}

View file

@ -133,6 +133,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet {
cards.add(new SetCardInfo("Island", 266, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Island", 266, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Iymrith, Desert Doom", 62, Rarity.MYTHIC, mage.cards.i.IymrithDesertDoom.class)); cards.add(new SetCardInfo("Iymrith, Desert Doom", 62, Rarity.MYTHIC, mage.cards.i.IymrithDesertDoom.class));
cards.add(new SetCardInfo("Jaded Sell-Sword", 152, Rarity.COMMON, mage.cards.j.JadedSellSword.class)); cards.add(new SetCardInfo("Jaded Sell-Sword", 152, Rarity.COMMON, mage.cards.j.JadedSellSword.class));
cards.add(new SetCardInfo("Keen-Eared Sentry", 22, Rarity.UNCOMMON, mage.cards.k.KeenEaredSentry.class));
cards.add(new SetCardInfo("Kick in the Door", 153, Rarity.COMMON, mage.cards.k.KickInTheDoor.class)); cards.add(new SetCardInfo("Kick in the Door", 153, Rarity.COMMON, mage.cards.k.KickInTheDoor.class));
cards.add(new SetCardInfo("Krydle of Baldur's Gate", 226, Rarity.UNCOMMON, mage.cards.k.KrydleOfBaldursGate.class)); cards.add(new SetCardInfo("Krydle of Baldur's Gate", 226, Rarity.UNCOMMON, mage.cards.k.KrydleOfBaldursGate.class));
cards.add(new SetCardInfo("Leather Armor", 248, Rarity.COMMON, mage.cards.l.LeatherArmor.class)); cards.add(new SetCardInfo("Leather Armor", 248, Rarity.COMMON, mage.cards.l.LeatherArmor.class));

View file

@ -478,7 +478,11 @@ public abstract class GameImpl implements Game, Serializable {
@Override @Override
public void ventureIntoDungeon(UUID playerId) { public void ventureIntoDungeon(UUID playerId) {
if (replaceEvent(GameEvent.getEvent(GameEvent.EventType.VENTURE, playerId, null, playerId))) {
return;
}
this.getOrCreateDungeon(playerId).moveToNextRoom(playerId, this); this.getOrCreateDungeon(playerId).moveToNextRoom(playerId, this);
fireEvent(GameEvent.getEvent(GameEvent.EventType.VENTURED, playerId, null, playerId));
} }
@Override @Override

View file

@ -454,6 +454,7 @@ public class GameEvent implements Serializable {
playerId player in the dungeon playerId player in the dungeon
*/ */
ROOM_ENTERED, ROOM_ENTERED,
VENTURE, VENTURED,
DUNGEON_COMPLETED, DUNGEON_COMPLETED,
//custom events //custom events
CUSTOM_EVENT CUSTOM_EVENT