* Replaced some custom name a card effects.

This commit is contained in:
LevelX2 2015-10-15 22:25:52 +02:00 committed by AlumiuN
parent 3c8a9a75fb
commit ff0aace404
4 changed files with 31 additions and 118 deletions

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
@ -33,11 +33,8 @@ import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.NameACardEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -46,9 +43,6 @@ import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/** /**
* *
@ -60,11 +54,10 @@ public class Nevermore extends CardImpl {
super(ownerId, 25, "Nevermore", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}{W}"); super(ownerId, 25, "Nevermore", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}{W}");
this.expansionSetCode = "ISD"; this.expansionSetCode = "ISD";
// As Nevermore enters the battlefield, name a nonland card.
this.addAbility(new AsEntersBattlefieldAbility(new NameACardEffect(NameACardEffect.TypeOfName.NON_LAND_NAME)));
//As Nevermore enters the battlefield, name a nonland card. // The named card can't be cast.
this.addAbility(new AsEntersBattlefieldAbility(new NevermoreEffect1()));
//The named card can't be cast.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new NevermoreEffect2())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new NevermoreEffect2()));
} }
@ -80,46 +73,6 @@ public class Nevermore extends CardImpl {
} }
class NevermoreEffect1 extends OneShotEffect {
public NevermoreEffect1() {
super(Outcome.Detriment);
staticText = "name a nonland card";
}
public NevermoreEffect1(final NevermoreEffect1 effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers(permanent.getLogName() + ", named card: [" + cardName + "]");
game.getState().setValue(source.getSourceId().toString(), cardName);
permanent.addInfo("named card", CardUtil.addToolTipMarkTags("Named card: [" + cardName +"]"), game);
return true;
}
return false;
}
@Override
public NevermoreEffect1 copy() {
return new NevermoreEffect1(this);
}
}
class NevermoreEffect2 extends ContinuousRuleModifyingEffectImpl { class NevermoreEffect2 extends ContinuousRuleModifyingEffectImpl {
public NevermoreEffect2() { public NevermoreEffect2() {
@ -145,7 +98,7 @@ class NevermoreEffect2 extends ContinuousRuleModifyingEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.CAST_SPELL) { if (event.getType() == EventType.CAST_SPELL) {
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) { if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY))) {
return true; return true;
} }
} }

View file

@ -25,32 +25,25 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.sets.mirrodinbesieged; package mage.sets.mirrodinbesieged;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.NameACardEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardRepository; import mage.constants.CardType;
import mage.choices.Choice; import mage.constants.Duration;
import mage.choices.ChoiceImpl; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/** /**
* *
@ -66,7 +59,7 @@ public class PhyrexianRevoker extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// As Phyrexian Revoker enters the battlefield, name a nonland card. // As Phyrexian Revoker enters the battlefield, name a nonland card.
this.addAbility(new AsEntersBattlefieldAbility(new PhyrexianRevokerEffect1())); this.addAbility(new AsEntersBattlefieldAbility(new NameACardEffect(NameACardEffect.TypeOfName.NON_LAND_NAME)));
// Activated abilities of sources with the chosen name can't be activated. // Activated abilities of sources with the chosen name can't be activated.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhyrexianRevokerEffect2())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhyrexianRevokerEffect2()));
@ -83,46 +76,6 @@ public class PhyrexianRevoker extends CardImpl {
} }
class PhyrexianRevokerEffect1 extends OneShotEffect {
public PhyrexianRevokerEffect1() {
super(Outcome.Detriment);
staticText = "name a nonland card";
}
public PhyrexianRevokerEffect1(final PhyrexianRevokerEffect1 effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers(permanent.getLogName() + ", named card: [" + cardName + "]");
game.getState().setValue(source.getSourceId().toString(), cardName);
permanent.addInfo("named card", CardUtil.addToolTipMarkTags("Named card: [" + cardName +"]"), game);
return true;
}
return false;
}
@Override
public PhyrexianRevokerEffect1 copy() {
return new PhyrexianRevokerEffect1(this);
}
}
class PhyrexianRevokerEffect2 extends ContinuousRuleModifyingEffectImpl { class PhyrexianRevokerEffect2 extends ContinuousRuleModifyingEffectImpl {
public PhyrexianRevokerEffect2() { public PhyrexianRevokerEffect2() {
@ -143,7 +96,7 @@ class PhyrexianRevokerEffect2 extends ContinuousRuleModifyingEffectImpl {
public PhyrexianRevokerEffect2 copy() { public PhyrexianRevokerEffect2 copy() {
return new PhyrexianRevokerEffect2(this); return new PhyrexianRevokerEffect2(this);
} }
@Override @Override
public String getInfoMessage(Ability source, GameEvent event, Game game) { public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = game.getObject(source.getSourceId()); MageObject mageObject = game.getObject(source.getSourceId());
@ -157,7 +110,7 @@ class PhyrexianRevokerEffect2 extends ContinuousRuleModifyingEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.ACTIVATE_ABILITY) { if (event.getType() == EventType.ACTIVATE_ABILITY) {
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) { if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY))) {
return true; return true;
} }
} }

View file

@ -34,7 +34,9 @@ import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.NameACardEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardRepository; import mage.cards.repository.CardRepository;
@ -69,7 +71,7 @@ public class VoidstoneGargoyle extends CardImpl {
// Flying // Flying
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// As Voidstone Gargoyle enters the battlefield, name a nonland card. // As Voidstone Gargoyle enters the battlefield, name a nonland card.
this.addAbility(new AsEntersBattlefieldAbility(new VoidstoneGargoyleChooseCardEffect())); this.addAbility(new AsEntersBattlefieldAbility(new NameACardEffect(NameACardEffect.TypeOfName.NON_LAND_NAME)));
// The named card can't be cast. // The named card can't be cast.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VoidstoneGargoyleReplacementEffect1())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VoidstoneGargoyleReplacementEffect1()));
// Activated abilities of sources with the chosen name can't be activated. // Activated abilities of sources with the chosen name can't be activated.
@ -100,7 +102,7 @@ class VoidstoneGargoyleChooseCardEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (controller != null && permanent != null) { if (controller != null && permanent != null) {
Choice cardChoice = new ChoiceImpl(); Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandNames()); cardChoice.setChoices(CardRepository.instance.getNonLandNames());
@ -160,7 +162,8 @@ class VoidstoneGargoyleReplacementEffect1 extends ContinuousRuleModifyingEffectI
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL) { if (event.getType() == GameEvent.EventType.CAST_SPELL) {
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) { if (object != null
&& object.getName().equals(game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY))) {
return true; return true;
} }
} }
@ -203,7 +206,7 @@ class VoidstoneGargoyleRuleModifyingEffect2 extends ContinuousRuleModifyingEffec
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.ACTIVATE_ABILITY) { if (event.getType() == EventType.ACTIVATE_ABILITY) {
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) { if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY))) {
return true; return true;
} }
} }

View file

@ -29,6 +29,7 @@ package mage.abilities.effects.common;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.repository.CardRepository; import mage.cards.repository.CardRepository;
import mage.choices.Choice; import mage.choices.Choice;
@ -71,7 +72,10 @@ public class NameACardEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (sourceObject == null) {
game.getObject(source.getSourceId());
}
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
Choice cardChoice = new ChoiceImpl(); Choice cardChoice = new ChoiceImpl();
switch (typeOfName) { switch (typeOfName) {