forked from External/mage
[Refactor] Added DamageWithPowerEffect and change some cards
This commit is contained in:
parent
2f94355516
commit
656e658fb4
5 changed files with 90 additions and 155 deletions
|
|
@ -28,21 +28,16 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DamageWithPowerTargetEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
|
|
@ -61,17 +56,17 @@ public class ClearShot extends CardImpl {
|
|||
public ClearShot(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{G}");
|
||||
|
||||
// Target creature you control gets +1/+1 until end of turn. It deals damage equal to its power to target creature you don't control.
|
||||
// Target creature you control gets +1/+1 until end of turn.
|
||||
Effect effect = new BoostTargetEffect(1, 1, Duration.EndOfTurn);
|
||||
effect.setApplyEffectsAfter(); // needed to count the boost for the second effect
|
||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
|
||||
effect = new ClearShotDamageEffect();
|
||||
// It deals damage equal to its power to target creature you don't control.
|
||||
effect = new DamageWithPowerTargetEffect();
|
||||
effect.setText("It deals damage equal to its power to target creature you don't control");
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
Target target = new TargetCreaturePermanent(filter);
|
||||
this.getSpellAbility().addTarget(target);
|
||||
}
|
||||
|
||||
public ClearShot(final ClearShot card) {
|
||||
|
|
@ -83,34 +78,3 @@ public class ClearShot extends CardImpl {
|
|||
return new ClearShot(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ClearShotDamageEffect extends OneShotEffect {
|
||||
|
||||
public ClearShotDamageEffect() {
|
||||
super(Outcome.Damage);
|
||||
this.staticText = "It deals damage equal to its power to target creature you don't control";
|
||||
}
|
||||
|
||||
public ClearShotDamageEffect(final ClearShotDamageEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClearShotDamageEffect copy() {
|
||||
return new ClearShotDamageEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent ownCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
|
||||
if (ownCreature != null) {
|
||||
int damage = ownCreature.getPower().getValue();
|
||||
Permanent targetCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
if (targetCreature != null) {
|
||||
targetCreature.damage(damage, ownCreature.getId(), game, false, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,9 +28,8 @@
|
|||
package mage.cards.n;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DamageWithPowerTargetEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.abilities.keyword.VigilanceAbility;
|
||||
|
|
@ -38,13 +37,9 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
|
|
@ -63,16 +58,20 @@ public class NaturesWay extends CardImpl {
|
|||
public NaturesWay(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{G}");
|
||||
|
||||
// Target creature you control gains vigilance and trample until end of turn. It deals damage equal to its power to target creature you don't control.
|
||||
// Target creature you control gains vigilance and trample until end of turn.
|
||||
Effect effect = new GainAbilityTargetEffect(VigilanceAbility.getInstance(), Duration.EndOfTurn);
|
||||
effect.setText("Target creature you control gains vigilance");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn);
|
||||
effect.setText("and trample until end of turn");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
this.getSpellAbility().addEffect(new NaturesWayEffect());
|
||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
||||
|
||||
// It deals damage equal to its power to target creature you don't control.
|
||||
effect = new DamageWithPowerTargetEffect();
|
||||
effect.setText("It deals damage equal to its power to target creature you don't control");
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
}
|
||||
|
||||
public NaturesWay(final NaturesWay card) {
|
||||
|
|
@ -84,34 +83,3 @@ public class NaturesWay extends CardImpl {
|
|||
return new NaturesWay(this);
|
||||
}
|
||||
}
|
||||
|
||||
class NaturesWayEffect extends OneShotEffect {
|
||||
|
||||
public NaturesWayEffect() {
|
||||
super(Outcome.Damage);
|
||||
this.staticText = "It deals damage equal to its power to target creature you don't control";
|
||||
}
|
||||
|
||||
public NaturesWayEffect(final NaturesWayEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NaturesWayEffect copy() {
|
||||
return new NaturesWayEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent controlledCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
|
||||
if (controller != null && controlledCreature != null) {
|
||||
Permanent targetCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
if (targetCreature != null) {
|
||||
targetCreature.damage(controlledCreature.getPower().getValue(), controlledCreature.getId(), game, false, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,17 +28,13 @@
|
|||
package mage.cards.r;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DamageWithPowerTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
|
|
@ -55,12 +51,12 @@ public class RabidBite extends CardImpl {
|
|||
}
|
||||
|
||||
public RabidBite(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{G}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{G}");
|
||||
|
||||
// Target creature you control deals damage equal to its power to target creature you don't control.
|
||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
|
||||
this.getSpellAbility().addEffect(new RabidBiteEffect());
|
||||
this.getSpellAbility().addEffect(new DamageWithPowerTargetEffect());
|
||||
}
|
||||
|
||||
public RabidBite(final RabidBite card) {
|
||||
|
|
@ -72,31 +68,3 @@ public class RabidBite extends CardImpl {
|
|||
return new RabidBite(this);
|
||||
}
|
||||
}
|
||||
|
||||
class RabidBiteEffect extends OneShotEffect {
|
||||
|
||||
public RabidBiteEffect() {
|
||||
super(Outcome.Damage);
|
||||
staticText = "Target creature you control deals damage equal to its power to target creature you don't control";
|
||||
}
|
||||
|
||||
public RabidBiteEffect(final RabidBiteEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
|
||||
Permanent targetPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
if (sourcePermanent != null && targetPermanent != null) {
|
||||
targetPermanent.damage(sourcePermanent.getPower().getValue(), sourcePermanent.getId(), game, false, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RabidBiteEffect copy() {
|
||||
return new RabidBiteEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,18 +28,13 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DamageWithPowerTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
|
|
@ -54,13 +49,14 @@ public class TailSlash extends CardImpl {
|
|||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.NOT_YOU));
|
||||
}
|
||||
|
||||
public TailSlash(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{R}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{R}");
|
||||
|
||||
// Target creature you control deals damage equal to its power to target creature you don't control.
|
||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
|
||||
this.getSpellAbility().addEffect(new TailSlashEffect());
|
||||
this.getSpellAbility().addEffect(new DamageWithPowerTargetEffect());
|
||||
}
|
||||
|
||||
public TailSlash(final TailSlash card) {
|
||||
|
|
@ -72,35 +68,3 @@ public class TailSlash extends CardImpl {
|
|||
return new TailSlash(this);
|
||||
}
|
||||
}
|
||||
|
||||
class TailSlashEffect extends OneShotEffect {
|
||||
|
||||
public TailSlashEffect() {
|
||||
super(Outcome.Damage);
|
||||
staticText = "Target creature you control deals damage equal to its power to target creature you don't control";
|
||||
}
|
||||
|
||||
public TailSlashEffect(final TailSlashEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getFirstTarget());
|
||||
if (sourcePermanent == null) {
|
||||
sourcePermanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
|
||||
}
|
||||
|
||||
Permanent targetPermanent = (Permanent) game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
if (sourcePermanent != null && targetPermanent != null) {
|
||||
targetPermanent.damage(sourcePermanent.getPower().getValue(), sourcePermanent.getId(), game, false, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TailSlashEffect copy() {
|
||||
return new TailSlashEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 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
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 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
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* 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
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* 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
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class DamageWithPowerTargetEffect extends OneShotEffect {
|
||||
|
||||
public DamageWithPowerTargetEffect() {
|
||||
super(Outcome.Damage);
|
||||
staticText = "Target creature you control deals damage equal to its power to target creature you don't control";
|
||||
}
|
||||
|
||||
public DamageWithPowerTargetEffect(final DamageWithPowerTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent controlledCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
|
||||
Permanent targetCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
if (controller != null) {
|
||||
if (targetCreature != null && controlledCreature != null) {
|
||||
targetCreature.damage(controlledCreature.getPower().getValue(), controlledCreature.getId(), game, false, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageWithPowerTargetEffect copy() {
|
||||
return new DamageWithPowerTargetEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue