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,20 +19,21 @@ 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 {
public AvengerEnDal(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.SPELLSHAPER);
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,19 +12,20 @@ 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 {
public Crumble(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{G}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{G}");
// Destroy target artifact. It can't be regenerated.
this.getSpellAbility().addTarget(new TargetArtifactPermanent());
this.getSpellAbility().addEffect(new DestroyTargetEffect(true));
// That artifact's controller gains life equal to its converted mana cost.
this.getSpellAbility().addEffect(new CrumbleEffect());
}
@ -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 {
@ -43,7 +42,7 @@ public final class DanceOfMany extends CardImpl {
}
public DanceOfMany(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}{U}");
// When Dance of Many enters the battlefield, create a token that's a copy of target nontoken creature.
Ability ability = new EntersBattlefieldTriggeredAbility(new DanceOfManyCreateTokenCopyEffect(), false);
@ -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,10 +49,10 @@ public class DamageTargetControllerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if(permanent != null) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
Player targetController = game.getPlayer(permanent.getControllerId());
if(targetController != null) {
if (targetController != null) {
targetController.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, preventable);
}
return true;
@ -68,8 +66,8 @@ public class DamageTargetControllerEffect extends OneShotEffect {
return staticText;
}
String text = "{this} deals " + amount.getMessage() + " damage to target "
+ mode.getTargets().get(0).getTargetName() + "'s controller";
if(!preventable) {
+ mode.getTargets().get(0).getTargetName() + "'s controller";
if (!preventable) {
text += ". The damage can't be prevented";
}
return text;

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()) {