Refactored inner classes and fixed tab problem from previous commits

This commit is contained in:
Michael Ludwig 2013-07-15 12:46:33 -04:00
parent 2da26af567
commit d2ac0c48db
7 changed files with 120 additions and 122 deletions

View file

@ -60,7 +60,7 @@ public class EdricSpymasterOfTrest extends CardImpl<EdricSpymasterOfTrest> {
this.toughness = new MageInt(2);
// Whenever a creature deals combat damage to one of your opponents, its controller may draw a card.
this.addAbility(new EdricSpymasterOfTrestTriggeredAbility());
this.addAbility(new EdricSpymasterOfTrestTriggeredAbility());
}
public EdricSpymasterOfTrest(final EdricSpymasterOfTrest card) {
@ -71,39 +71,37 @@ public class EdricSpymasterOfTrest extends CardImpl<EdricSpymasterOfTrest> {
public EdricSpymasterOfTrest copy() {
return new EdricSpymasterOfTrest(this);
}
public static class EdricSpymasterOfTrestTriggeredAbility extends TriggeredAbilityImpl<EdricSpymasterOfTrestTriggeredAbility> {
}
public EdricSpymasterOfTrestTriggeredAbility() {
super(Zone.BATTLEFIELD, new DrawCardTargetEffect(1), true);
}
public EdricSpymasterOfTrestTriggeredAbility(final EdricSpymasterOfTrestTriggeredAbility ability) {
super(ability);
}
@Override
public EdricSpymasterOfTrestTriggeredAbility copy() {
return new EdricSpymasterOfTrestTriggeredAbility(this);
}
class EdricSpymasterOfTrestTriggeredAbility extends TriggeredAbilityImpl<EdricSpymasterOfTrestTriggeredAbility> {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType().equals(EventType.DAMAGED_PLAYER) &&
((DamagedPlayerEvent) event).isCombatDamage() &&
game.getOpponents(this.controllerId).contains(((DamagedPlayerEvent) event).getPlayerId())) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(game.getPermanent(event.getSourceId()).getControllerId()));
}
return true;
}
return false;
}
@Override
public String getRule() {
return "Whenever a creature deals combat damage to one of your opponents, its controller may draw a card";
}
public EdricSpymasterOfTrestTriggeredAbility() {
super(Zone.BATTLEFIELD, new DrawCardTargetEffect(1), true);
}
public EdricSpymasterOfTrestTriggeredAbility(final EdricSpymasterOfTrestTriggeredAbility ability) {
super(ability);
}
@Override
public EdricSpymasterOfTrestTriggeredAbility copy() {
return new EdricSpymasterOfTrestTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType().equals(EventType.DAMAGED_PLAYER) && ((DamagedPlayerEvent) event).isCombatDamage() && game.getOpponents(this.controllerId).contains(((DamagedPlayerEvent) event).getPlayerId())) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(game.getPermanent(event.getSourceId()).getControllerId()));
}
return true;
}
return false;
}
@Override
public String getRule() {
return "Whenever a creature deals combat damage to one of your opponents, its controller may draw a card";
}
}

View file

@ -74,45 +74,45 @@ public class ParasiticStrix extends CardImpl<ParasiticStrix> {
public ParasiticStrix copy() {
return new ParasiticStrix(this);
}
static class ParasiticStrixTriggeredAbility extends TriggeredAbilityImpl<ParasiticStrixTriggeredAbility> {
public ParasiticStrixTriggeredAbility() {
super(Zone.BATTLEFIELD, new LoseLifeTargetEffect(2));
this.addEffect(new GainLifeEffect(2));
this.addTarget(new TargetPlayer(true));
}
class ParasiticStrixTriggeredAbility extends TriggeredAbilityImpl<ParasiticStrixTriggeredAbility> {
public ParasiticStrixTriggeredAbility() {
super(Zone.BATTLEFIELD, new LoseLifeTargetEffect(2));
this.addEffect(new GainLifeEffect(2));
this.addTarget(new TargetPlayer(true));
}
public ParasiticStrixTriggeredAbility(final ParasiticStrixTriggeredAbility ability) {
super(ability);
}
@Override
public ParasiticStrixTriggeredAbility copy() {
return new ParasiticStrixTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType().equals(EventType.ENTERS_THE_BATTLEFIELD) && event.getTargetId().equals(this.getSourceId())) {
return true;
}
public ParasiticStrixTriggeredAbility(final ParasiticStrixTriggeredAbility ability) {
super(ability);
}
@Override
public ParasiticStrixTriggeredAbility copy() {
return new ParasiticStrixTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType().equals(EventType.ENTERS_THE_BATTLEFIELD) && event.getTargetId().equals(this.getSourceId())) {
return true;
}
return false;
}
@Override
public boolean checkInterveningIfClause(Game game) {
FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate(ObjectColor.BLACK));
if (game.getBattlefield().countAll(filter, this.controllerId, game) >= 1) {
return true;
}
return false;
}
@Override
public String getRule() {
return "When Parasitic Strix enters the battlefield, if you control a black permanent, target player loses 2 life and you gain 2 life.";
return false;
}
@Override
public boolean checkInterveningIfClause(Game game) {
FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate(ObjectColor.BLACK));
if (game.getBattlefield().countAll(filter, this.controllerId, game) >= 1) {
return true;
}
return false;
}
@Override
public String getRule() {
return "When Parasitic Strix enters the battlefield, if you control a black permanent, target player loses 2 life and you gain 2 life.";
}
}

View file

@ -74,41 +74,41 @@ public class SkywardEyeProphets extends CardImpl<SkywardEyeProphets> {
public SkywardEyeProphets copy() {
return new SkywardEyeProphets(this);
}
public static class SkywardEyeProphetsEffect extends OneShotEffect<SkywardEyeProphetsEffect> {
}
public SkywardEyeProphetsEffect() {
super(Outcome.DrawCard);
this.staticText = "Reveal the top card of your library. If it's a land card, put it onto the battlefield. Otherwise, put it into your hand";
}
class SkywardEyeProphetsEffect extends OneShotEffect<SkywardEyeProphetsEffect> {
public SkywardEyeProphetsEffect(final SkywardEyeProphetsEffect effect) {
super(effect);
}
public SkywardEyeProphetsEffect() {
super(Outcome.DrawCard);
this.staticText = "Reveal the top card of your library. If it's a land card, put it onto the battlefield. Otherwise, put it into your hand";
}
@Override
public SkywardEyeProphetsEffect copy() {
return new SkywardEyeProphetsEffect(this);
}
public SkywardEyeProphetsEffect(final SkywardEyeProphetsEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.getLibrary().size() > 0) {
CardsImpl cards = new CardsImpl();
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
player.revealCards("Skyward Eye Prophets", cards, game);
if (card.getCardType().contains(CardType.LAND)) {
card.putOntoBattlefield(game, Zone.HAND, source.getId(), source.getControllerId());
} else {
card.moveToZone(Zone.HAND, source.getId(), game, true);
}
return true;
}
}
return false;
}
@Override
public SkywardEyeProphetsEffect copy() {
return new SkywardEyeProphetsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.getLibrary().size() > 0) {
CardsImpl cards = new CardsImpl();
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
player.revealCards("Skyward Eye Prophets", cards, game);
if (card.getCardType().contains(CardType.LAND)) {
card.putOntoBattlefield(game, Zone.HAND, source.getId(), source.getControllerId());
} else {
card.moveToZone(Zone.HAND, source.getId(), game, true);
}
return true;
}
}
return false;
}
}

View file

@ -53,7 +53,7 @@ public class CoilingOracle extends CardImpl<CoilingOracle> {
this.toughness = new MageInt(1);
// When Coiling Oracle enters the battlefield, reveal the top card of your library. If it's a land card, put it onto the battlefield. Otherwise, put that card into your hand.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SkywardEyeProphetsEffect()));
this.addAbility(new EntersBattlefieldTriggeredAbility(new SkywardEyeProphetsEffect()));
}
public CoilingOracle(final CoilingOracle card) {

View file

@ -70,8 +70,8 @@ public class PilloryOfTheSleepless extends CardImpl<PilloryOfTheSleepless> {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackBlockAttachedEffect(AttachmentType.AURA)));
// Enchanted creature has "At the beginning of your upkeep, you lose 1 life."
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(
new BeginningOfUpkeepTriggeredAbility(new LoseLifeSourceEffect(1), TargetController.YOU, false), AttachmentType.AURA)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(
new BeginningOfUpkeepTriggeredAbility(new LoseLifeSourceEffect(1), TargetController.YOU, false), AttachmentType.AURA)));
}
public PilloryOfTheSleepless(final PilloryOfTheSleepless card) {

View file

@ -46,8 +46,8 @@ public class WheelOfFortune extends CardImpl<WheelOfFortune> {
this.color.setRed(true);
// Each player discards his or her hand and draws seven cards.
this.getSpellAbility().addEffect(new DiscardHandAllEffect());
this.getSpellAbility().addEffect(new DrawCardAllEffect(7));
this.getSpellAbility().addEffect(new DiscardHandAllEffect());
this.getSpellAbility().addEffect(new DrawCardAllEffect(7));
}
public WheelOfFortune(final WheelOfFortune card) {

View file

@ -42,31 +42,31 @@ import mage.players.Player;
public class DiscardHandAllEffect extends OneShotEffect<DiscardHandAllEffect> {
public DiscardHandAllEffect() {
super(Outcome.Discard);
this.staticText = "Each player discards his or her hand";
super(Outcome.Discard);
this.staticText = "Each player discards his or her hand";
}
public DiscardHandAllEffect(final DiscardHandAllEffect effect) {
super(effect);
super(effect);
}
@Override
public DiscardHandAllEffect copy() {
return new DiscardHandAllEffect(this);
return new DiscardHandAllEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player sourcePlayer = game.getPlayer(source.getControllerId());
for (UUID playerId : sourcePlayer.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
Set<Card> cards = player.getHand().getCards(game);
for (Card card : cards) {
player.discard(card, source, game);
}
}
Player sourcePlayer = game.getPlayer(source.getControllerId());
for (UUID playerId : sourcePlayer.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
Set<Card> cards = player.getHand().getCards(game);
for (Card card : cards) {
player.discard(card, source, game);
}
}
}
return true;
return true;
}
}