Refactor related to #6187

This commit is contained in:
Oleg Agafonov 2020-01-15 11:47:22 +04:00
parent 4eacadb9f1
commit d20a20fb6a
9 changed files with 44 additions and 40 deletions

View file

@ -128,9 +128,9 @@ class AkoumHellkiteDamageEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (land != null && permanent != null) {
if (land.hasSubtype(SubType.MOUNTAIN, game)) {
permanent.damage(2, source.getSourceId(), game, false, true);
permanent.damage(2, source.getSourceId(), game);
} else {
permanent.damage(1, source.getSourceId(), game, false, true);
permanent.damage(1, source.getSourceId(), game);
}
return true;
}

View file

@ -1,7 +1,5 @@
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -21,8 +19,9 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetAttackingCreature;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class AvengerEnDal extends CardImpl {
@ -34,7 +33,7 @@ public final class AvengerEnDal extends CardImpl {
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// {2}{W}, {tap}, Discard a card: Exile target attacking creature. Its controller gains life equal to its toughness.
// {2}{W}, {T}, Discard a card: Exile target attacking creature. Its controller gains life equal to its toughness.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileTargetEffect(), new ManaCostsImpl("{2}{W}"));
ability.addCost(new TapSourceCost());
ability.addCost(new DiscardCardCost());
@ -71,7 +70,7 @@ class AvengerEnDalEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {

View file

@ -1,7 +1,5 @@
package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.PreventionEffectData;
import mage.abilities.effects.PreventionEffectImpl;
@ -15,6 +13,8 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
* @author brikr
*/
@ -65,7 +65,7 @@ class AweStrikeEffect extends PreventionEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!this.used && super.applies(event, source, game)) {
Permanent targetCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
return targetCreature != null && targetCreature.getId().equals(event.getSourceId());
}
return false;

View file

@ -1,7 +1,5 @@
package mage.cards.b;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
@ -14,8 +12,9 @@ import mage.game.permanent.Permanent;
import mage.game.permanent.token.BeastToken;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
*
* @author North, Loki
*/
public final class BeastWithin extends CardImpl {
@ -57,7 +56,10 @@ class BeastWithinEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
// If the permanent is an illegal target when Beast Within tries to resolve, the spell wont resolve and none
// of its effects will happen. The permanents controller wont get a Beast token.
// (2011-06-01)
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
new BeastToken().putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId());
}

View file

@ -1,7 +1,5 @@
package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
@ -14,8 +12,9 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetArtifactPermanent;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class Crumble extends CardImpl {
@ -59,7 +58,8 @@ class CrumbleEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
// If the target artifact becomes illegal before resolution, the player does not gain any life. (2004-10-04)
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
int cost = permanent.getConvertedManaCost();
Player player = game.getPlayer(permanent.getControllerId());

View file

@ -1,8 +1,5 @@
package mage.cards.d;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -11,8 +8,8 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.CreateTokenCopyTargetEffect;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
import mage.abilities.effects.common.SacrificeTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
@ -30,8 +27,10 @@ import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import java.util.List;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class DanceOfMany extends CardImpl {
@ -84,7 +83,11 @@ class DanceOfManyCreateTokenCopyEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
// The ability is targeted and checks the validity of the target when put on the stack and when resolving.
// If the creature is not still there when the copy ability resolves, the ability doesnt resolve and no token
// is put onto the battlefield. This card remains on the battlefield as an enchantment with no token.
// (2004-10-04)
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
Permanent sourceObject = game.getPermanent(source.getSourceId());
if (permanent != null && sourceObject != null) {

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
@ -12,7 +11,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
* @author LoneFox
*/
public class DamageTargetControllerEffect extends OneShotEffect {
@ -51,7 +49,7 @@ public class DamageTargetControllerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
Player targetController = game.getPlayer(permanent.getControllerId());
if (targetController != null) {

View file

@ -35,7 +35,7 @@ public class DamageWithPowerFromOneToAnotherTargetEffect extends OneShotEffect {
throw new IllegalStateException("It must have two targets, but found " + source.getTargets().size());
}
Permanent myPermanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
Permanent myPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
Permanent anotherPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
Player anotherPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());

View file

@ -32,12 +32,13 @@ public final class MomirEmblem extends Emblem {
public MomirEmblem() {
setName("Emblem Momir Vig, Simic Visionary");
setExpansionSetCodeForImage("DIS");
// {X}, Discard a card: Put a token into play as a copy of a random creature card with converted mana cost X. Play this ability only any time you could play a sorcery and only once each turn.
// {X}, Discard a card: Create a token that's a copy of a creature card with converted mana cost X chosen at random.
// Activate this ability only any time you could cast a sorcery and only once each turn.
LimitedTimesPerTurnActivatedAbility ability = new LimitedTimesPerTurnActivatedAbility(Zone.COMMAND, new MomirEffect(), new VariableManaCost());
ability.addCost(new DiscardCardCost());
ability.setTiming(TimingRule.SORCERY);
this.getAbilities().add(ability);
}
}
@ -49,7 +50,7 @@ class MomirEffect extends OneShotEffect {
public MomirEffect(MomirEffect effect) {
super(effect);
staticText = "Put a token into play as a copy of a random creature card with converted mana cost X";
staticText = "Create a token that's a copy of a creature card with converted mana cost X chosen at random";
}
@Override
@ -60,7 +61,8 @@ class MomirEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
int value = source.getManaCostsToPay().getX();
// should this be random across card names, or card printings?
// should this be random across card names
CardCriteria criteria = new CardCriteria().types(CardType.CREATURE).convertedManaCost(value);
List<CardInfo> options = CardRepository.instance.findCards(criteria);
if (options == null || options.isEmpty()) {