mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 20:29:19 -08:00
Fixed some possible exceptions.
This commit is contained in:
parent
e936f7dc0f
commit
d2eb6151f1
20 changed files with 133 additions and 132 deletions
|
|
@ -43,6 +43,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Rarity;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.filter.common.FilterInstantOrSorceryCard;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
|
|
@ -152,13 +153,16 @@ class JelevaNephaliasCastEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (controller.chooseUse(outcome, "Cast an instant or sorcery from exile?", source, game)) {
|
||||
TargetCardInExile target = new TargetCardInExile(new FilterInstantOrSorceryCard(), CardUtil.getCardExileZoneId(game, source));
|
||||
if (controller.choose(Outcome.PlayForFree, game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)), target, game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
game.getExile().removeCard(card, game);
|
||||
return controller.cast(card.getSpellAbility(), game, true);
|
||||
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
|
||||
if (exileZone != null && exileZone.count(new FilterInstantOrSorceryCard(), game) > 0) {
|
||||
if (controller.chooseUse(outcome, "Cast an instant or sorcery card from exile?", source, game)) {
|
||||
TargetCardInExile target = new TargetCardInExile(new FilterInstantOrSorceryCard(), CardUtil.getCardExileZoneId(game, source));
|
||||
if (controller.choose(Outcome.PlayForFree, exileZone, target, game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
game.getExile().removeCard(card, game);
|
||||
return controller.cast(card.getSpellAbility(), game, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
|
|||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.CardType;
|
||||
|
|
@ -24,6 +23,7 @@ import mage.constants.Rarity;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
|
|
@ -125,10 +125,9 @@ class CloudKeyCostModificationEffect extends CostModificationEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
|
||||
if (abilityToModify instanceof SpellAbility && abilityToModify.getControllerId().equals(source.getControllerId())) {
|
||||
Card card = game.getCard(abilityToModify.getSourceId());
|
||||
if (card.getCardType().toString().contains((String) game.getState().getValue(source.getSourceId().toString() + "_CloudKey"))) {
|
||||
Spell spell = game.getStack().getSpell(abilityToModify.getSourceId());
|
||||
if (spell != null && spell.getCardType().toString().contains((String) game.getState().getValue(source.getSourceId().toString() + "_CloudKey"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.DiesAttachedTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.PutPermanentOnBattlefieldEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
|
||||
import mage.abilities.keyword.EquipAbility;
|
||||
import mage.cards.Card;
|
||||
|
|
@ -45,9 +43,6 @@ import mage.constants.Rarity;
|
|||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.filter.predicate.other.AuraCardCanAttachToPermanentId;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -86,7 +81,7 @@ class DeathrenderEffect extends OneShotEffect {
|
|||
|
||||
DeathrenderEffect() {
|
||||
super(Outcome.PutCardInPlay);
|
||||
this.staticText = "you may put a creature card from your hand onto the battlefield and attach {this} to it.";
|
||||
this.staticText = "you may put a creature card from your hand onto the battlefield and attach {this} to it";
|
||||
}
|
||||
|
||||
DeathrenderEffect(final DeathrenderEffect effect) {
|
||||
|
|
@ -102,14 +97,13 @@ class DeathrenderEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (controller != null) {
|
||||
if (controller != null && sourcePermanent != null) {
|
||||
FilterCard filter = new FilterCreatureCard();
|
||||
TargetCardInHand target = new TargetCardInHand(0, 1, filter);
|
||||
if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
|
||||
Card creatureInHand = game.getCard(target.getFirstTarget());
|
||||
if (creatureInHand != null) {
|
||||
game.getState().setValue("attachTo:" + sourcePermanent.getId(), game.getPermanent(creatureInHand.getId()));
|
||||
if (controller.moveCards(creatureInHand, Zone.BATTLEFIELD, source, game) && sourcePermanent != null) {
|
||||
if (controller.moveCards(creatureInHand, Zone.BATTLEFIELD, source, game)) {
|
||||
game.getPermanent(creatureInHand.getId()).addAttachment(sourcePermanent.getId(), game);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,16 +28,11 @@
|
|||
package mage.sets.magic2010;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.DrawCardOpponentTriggeredAbility;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -49,7 +44,6 @@ public class UnderworldDreams extends CardImpl {
|
|||
super(ownerId, 115, "Underworld Dreams", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{B}{B}{B}");
|
||||
this.expansionSetCode = "M10";
|
||||
|
||||
|
||||
// Whenever an opponent draws a card, Underworld Dreams deals 1 damage to him or her.
|
||||
this.addAbility(new DrawCardOpponentTriggeredAbility(new DamageTargetEffect(1, true, "him or her"), false, true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ public class HamletbackGoliath extends CardImpl {
|
|||
}
|
||||
|
||||
class HamletbackGoliathTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
HamletbackGoliathTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new HamletbackGoliathEffect(), true);
|
||||
}
|
||||
|
|
@ -109,11 +110,12 @@ class HamletbackGoliathTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever another creature enters the battlefield, you may put X +1/+1 counters on Hamletback Goliath, where X is that creature's power.";
|
||||
return "Whenever another creature enters the battlefield, you may put X +1/+1 counters on {this}, where X is that creature's power.";
|
||||
}
|
||||
}
|
||||
|
||||
class HamletbackGoliathEffect extends OneShotEffect {
|
||||
|
||||
HamletbackGoliathEffect() {
|
||||
super(Outcome.BoostCreature);
|
||||
}
|
||||
|
|
@ -125,15 +127,14 @@ class HamletbackGoliathEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
Permanent HamletbackGoliath = game.getPermanent(source.getSourceId());
|
||||
Permanent sourceObject = game.getPermanent(source.getSourceId());
|
||||
if (creature == null) {
|
||||
creature = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
|
||||
}
|
||||
if (creature != null) {
|
||||
HamletbackGoliath.addCounters(CounterType.P1P1.createInstance(creature.getPower().getValue()), game);
|
||||
return true;
|
||||
if (creature != null && sourceObject != null) {
|
||||
sourceObject.addCounters(CounterType.P1P1.createInstance(creature.getPower().getValue()), game);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -61,14 +61,13 @@ public class ErayoSoratamiAscendant extends CardImpl {
|
|||
this.toughness = new MageInt(1);
|
||||
|
||||
this.flipCard = true;
|
||||
this.flipCardName = "Erayo's Essence";
|
||||
|
||||
|
||||
this.flipCardName = "Erayo's Essence";
|
||||
|
||||
// Flying
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
// Whenever the fourth spell of a turn is cast, flip Erayo, Soratami Ascendant.
|
||||
this.addAbility(new ErayoSoratamiAscendantTriggeredAbility());
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ErayoSoratamiAscendant(final ErayoSoratamiAscendant card) {
|
||||
|
|
@ -92,7 +91,7 @@ class ErayoSoratamiAscendantTriggeredAbility extends TriggeredAbilityImpl {
|
|||
effect.setText("flip {this}");
|
||||
return effect;
|
||||
}
|
||||
|
||||
|
||||
public ErayoSoratamiAscendantTriggeredAbility(final ErayoSoratamiAscendantTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
|
@ -121,7 +120,7 @@ class ErayoSoratamiAscendantTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
class ErayosEssence extends Token {
|
||||
|
||||
ErayosEssence () {
|
||||
ErayosEssence() {
|
||||
super("Erayo's Essence", "");
|
||||
supertype.add("Legendary");
|
||||
cardType.add(CardType.ENCHANTMENT);
|
||||
|
|
@ -129,15 +128,18 @@ class ErayosEssence extends Token {
|
|||
color.setBlue(true);
|
||||
|
||||
// Whenever an opponent casts a spell for the first time in a turn, counter that spell.
|
||||
this.addAbility(new ErayosEssenceTriggeredAbility());
|
||||
Effect effect = new CounterTargetEffect();
|
||||
effect.setText("counter that spell");
|
||||
this.addAbility(new ErayosEssenceTriggeredAbility(effect));
|
||||
}
|
||||
}
|
||||
|
||||
class ErayosEssenceTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public ErayosEssenceTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new CounterTargetEffect(), false);
|
||||
public ErayosEssenceTriggeredAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, effect, false);
|
||||
}
|
||||
|
||||
|
||||
public ErayosEssenceTriggeredAbility(final ErayosEssenceTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
|
@ -156,14 +158,14 @@ class ErayosEssenceTriggeredAbility extends TriggeredAbilityImpl {
|
|||
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever an opponent casts a spell for the first time each turn, counter that spell.";
|
||||
return "Whenever an opponent casts a spell for the first time each turn, " + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -78,10 +78,10 @@ public class EternalDominion extends CardImpl {
|
|||
|
||||
class EternalDominionEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterCard filter = new FilterCard("an artifact, creature, enchantment, or land card");
|
||||
private static final FilterCard FILTER = new FilterCard("an artifact, creature, enchantment, or land card");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT),
|
||||
FILTER.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT),
|
||||
new CardTypePredicate(CardType.CREATURE),
|
||||
new CardTypePredicate(CardType.ENCHANTMENT),
|
||||
new CardTypePredicate(CardType.LAND)));
|
||||
|
|
@ -102,7 +102,7 @@ class EternalDominionEffect extends OneShotEffect {
|
|||
Player opponent = game.getPlayer(source.getFirstTarget());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (opponent != null && controller != null) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(FILTER);
|
||||
controller.searchLibrary(target, game, opponent.getId());
|
||||
Card targetCard = game.getCard(target.getFirstTarget());
|
||||
if (targetCard != null) {
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@ import java.util.UUID;
|
|||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
|
|
@ -50,7 +50,6 @@ import mage.target.common.TargetControlledCreaturePermanent;
|
|||
*/
|
||||
public class SigilBlessing extends CardImpl {
|
||||
|
||||
|
||||
public SigilBlessing(UUID ownerId) {
|
||||
super(ownerId, 195, "Sigil Blessing", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{G}{W}");
|
||||
this.expansionSetCode = "ALA";
|
||||
|
|
@ -71,6 +70,7 @@ public class SigilBlessing extends CardImpl {
|
|||
}
|
||||
|
||||
class SigilBlessingBoostControlledEffect extends ContinuousEffectImpl {
|
||||
|
||||
public SigilBlessingBoostControlledEffect() {
|
||||
super(Duration.EndOfTurn, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
||||
staticText = "Until end of turn, target creature you control gets +3/+3 and other creatures you control get +1/+1";
|
||||
|
|
@ -95,11 +95,11 @@ class SigilBlessingBoostControlledEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent permanent = it.next().getPermanent(game);
|
||||
if (permanent != null) {
|
||||
int boost = 1;
|
||||
if (getTargetPointer().getFirst(game, source).equals(permanent.getId())) {
|
||||
if (permanent.getId().equals(getTargetPointer().getFirst(game, source))) {
|
||||
boost = 3;
|
||||
}
|
||||
permanent.addPower(boost);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue