* Replaced some custom choose player effects.

This commit is contained in:
LevelX2 2015-10-15 22:15:23 +02:00
parent 268e83e170
commit 07565d81bd
4 changed files with 73 additions and 128 deletions

View file

@ -35,7 +35,7 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChoosePlayerEffect;
import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveTargetEffect;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.cards.CardImpl;
@ -47,9 +47,7 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget;
/**
@ -67,7 +65,7 @@ public class SewerNemesis extends CardImpl {
this.toughness = new MageInt(0);
// As Sewer Nemesis enters the battlefield, choose a player.
this.addAbility(new AsEntersBattlefieldAbility(new SewerNemesisChoosePlayerEffect()));
this.addAbility(new AsEntersBattlefieldAbility(new ChoosePlayerEffect(Outcome.Detriment)));
// Sewer Nemesis's power and toughness are each equal to the number of cards in the chosen player's graveyard.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new CardsInTargetOpponentsGraveyardCount(), Duration.WhileOnBattlefield)));
// Whenever the chosen player casts a spell, that player puts the top card of his or her library into his or her graveyard.
@ -85,42 +83,8 @@ public class SewerNemesis extends CardImpl {
}
}
class SewerNemesisChoosePlayerEffect extends OneShotEffect {
public SewerNemesisChoosePlayerEffect() {
super(Outcome.Detriment);
this.staticText = "choose a player";
}
public SewerNemesisChoosePlayerEffect(final SewerNemesisChoosePlayerEffect effect) {
super(effect);
}
@Override
public SewerNemesisChoosePlayerEffect copy() {
return new SewerNemesisChoosePlayerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
TargetPlayer target = new TargetPlayer(1,1,true);
if (player.choose(this.outcome, target, source.getSourceId(), game)) {
Player chosenPlayer = game.getPlayer(target.getFirstTarget());
if (chosenPlayer != null) {
game.informPlayers(permanent.getLogName() + ": " + player.getLogName() + " has chosen " + chosenPlayer.getLogName());
game.getState().setValue(permanent.getId() + "_player", target.getFirstTarget());
return true;
}
}
}
return false;
}
}
class CardsInTargetOpponentsGraveyardCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
if (sourceAbility != null) {

View file

@ -30,9 +30,8 @@ package mage.sets.commander2013;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChoosePlayerEffect;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -44,18 +43,19 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetPlayer;
/**
* Protection from a player is a new variant of the protection ability. It means the following:
* -- True-Name Nemesis cant be the target of spells or abilities controlled by the chosen player.
* -- True-Name Nemesis cant be enchanted by Auras or equipped by Equipment controlled
* by the chosen player. (The same is true for Fortifications controlled by the chosen player,
* if True-Name Nemesis becomes a land.)
* -- True-Name Nemesis cant be blocked by creatures controlled by the chosen player.
* -- All damage that would be dealt to True-Name Nemesis by sources controlled by the chosen player
* is prevented. (The same is true for sources owned by the chosen player that dont have controllers.)
* Protection from a player is a new variant of the protection ability. It means
* the following: -- True-Name Nemesis cant be the target of spells or
* abilities controlled by the chosen player. -- True-Name Nemesis cant be
* enchanted by Auras or equipped by Equipment controlled by the chosen player.
* (The same is true for Fortifications controlled by the chosen player, if
* True-Name Nemesis becomes a land.) -- True-Name Nemesis cant be blocked by
* creatures controlled by the chosen player. -- All damage that would be dealt
* to True-Name Nemesis by sources controlled by the chosen player is prevented.
* (The same is true for sources owned by the chosen player that dont have
* controllers.)
*
* @author LevelX2
*/
public class TrueNameNemesis extends CardImpl {
@ -70,7 +70,7 @@ public class TrueNameNemesis extends CardImpl {
this.toughness = new MageInt(1);
// As True-Name Nemesis enters the battlefield, choose a player.
this.addAbility(new AsEntersBattlefieldAbility(new TrueNameNemesisChoosePlayerEffect()));
this.addAbility(new AsEntersBattlefieldAbility(new ChoosePlayerEffect(Outcome.Protect)));
// True-Name Nemesis has protection from the chosen player.
this.addAbility(new ProtectionFromPlayerAbility());
}
@ -85,42 +85,6 @@ public class TrueNameNemesis extends CardImpl {
}
}
class TrueNameNemesisChoosePlayerEffect extends OneShotEffect {
public TrueNameNemesisChoosePlayerEffect() {
super(Outcome.Detriment);
this.staticText = "choose a player";
}
public TrueNameNemesisChoosePlayerEffect(final TrueNameNemesisChoosePlayerEffect effect) {
super(effect);
}
@Override
public TrueNameNemesisChoosePlayerEffect copy() {
return new TrueNameNemesisChoosePlayerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
TargetPlayer target = new TargetPlayer(1,1,true);
if (player.choose(this.outcome, target, source.getSourceId(), game)) {
Player chosenPlayer = game.getPlayer(target.getFirstTarget());
if (chosenPlayer != null) {
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + chosenPlayer.getLogName());
game.getState().setValue(permanent.getId() + "_player", target.getFirstTarget());
permanent.addInfo("chosen player", "<i>Chosen player: " + chosenPlayer.getLogName() + "</i>", game);
return true;
}
}
}
return false;
}
}
class ProtectionFromPlayerAbility extends ProtectionAbility {
public ProtectionFromPlayerAbility() {

View file

@ -35,6 +35,7 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChoosePlayerEffect;
import mage.abilities.effects.common.DamageSelfEffect;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
@ -45,10 +46,7 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer;
/**
*
@ -64,7 +62,7 @@ public class StuffyDoll extends CardImpl {
this.toughness = new MageInt(1);
// As Stuffy Doll enters the battlefield, choose a player.
this.addAbility(new AsEntersBattlefieldAbility(new StuffyDollChoosePlayerEffect()));
this.addAbility(new AsEntersBattlefieldAbility(new ChoosePlayerEffect(Outcome.Damage)));
// Stuffy Doll is indestructible.
this.addAbility(IndestructibleAbility.getInstance());
// Whenever Stuffy Doll is dealt damage, it deals that much damage to the chosen player.
@ -83,41 +81,6 @@ public class StuffyDoll extends CardImpl {
}
}
class StuffyDollChoosePlayerEffect extends OneShotEffect {
public StuffyDollChoosePlayerEffect() {
super(Outcome.Detriment);
this.staticText = "choose a player";
}
public StuffyDollChoosePlayerEffect(final StuffyDollChoosePlayerEffect effect) {
super(effect);
}
@Override
public StuffyDollChoosePlayerEffect copy() {
return new StuffyDollChoosePlayerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
TargetPlayer target = new TargetPlayer();
if (player.choose(this.outcome, target, source.getSourceId(), game)) {
Player chosenPlayer = game.getPlayer(target.getFirstTarget());
if (chosenPlayer != null) {
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + chosenPlayer.getLogName());
game.getState().setValue(permanent.getId() + "_player", target.getFirstTarget());
return true;
}
}
}
return false;
}
}
class StuffyDollTriggeredAbility extends TriggeredAbilityImpl {
public StuffyDollTriggeredAbility() {
@ -179,4 +142,3 @@ class StuffyDollGainLifeEffect extends OneShotEffect {
return true;
}
}

View file

@ -0,0 +1,55 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.util.CardUtil;
/**
*
* @author LevelX2
*/
public class ChoosePlayerEffect extends OneShotEffect {
public ChoosePlayerEffect(Outcome outcome) {
super(outcome);
this.staticText = "choose a player";
}
public ChoosePlayerEffect(final ChoosePlayerEffect effect) {
super(effect);
}
@Override
public ChoosePlayerEffect copy() {
return new ChoosePlayerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
TargetPlayer target = new TargetPlayer(1, 1, true);
if (player.choose(this.outcome, target, source.getSourceId(), game)) {
Player chosenPlayer = game.getPlayer(target.getFirstTarget());
if (chosenPlayer != null) {
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + chosenPlayer.getLogName());
game.getState().setValue(permanent.getId() + "_player", target.getFirstTarget());
permanent.addInfo("chosen player", CardUtil.addToolTipMarkTags("Chosen player: " + chosenPlayer.getLogName()), game);
return true;
}
}
}
return false;
}
}