forked from External/mage
Refactored Ent's Fury
This commit is contained in:
parent
202f4b5112
commit
b1e7e589ee
2 changed files with 77 additions and 50 deletions
|
|
@ -2,39 +2,55 @@ package mage.cards.e;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.common.TargetObjectMatchesFilterCondition;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.FightTargetsEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.PowerPredicate;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.target.common.TargetOpponentsCreaturePermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TiagoMDG
|
||||
*/
|
||||
public final class EntsFury extends CardImpl {
|
||||
|
||||
private static final FilterControlledCreaturePermanent FILTER = new FilterControlledCreaturePermanent("creature with power 4 or greater");
|
||||
|
||||
static {
|
||||
FILTER.add(new PowerPredicate(ComparisonType.MORE_THAN, 3));
|
||||
}
|
||||
|
||||
public EntsFury(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[] { CardType.SORCERY }, "{1}{G}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{G}");
|
||||
|
||||
// Put a +1/+1 counter on target creature you control if its power is 4 or greater.
|
||||
// Then that creature gets +1/+1 until end of turn and fights target
|
||||
// creature you don't control.
|
||||
|
||||
this.getSpellAbility().addEffect(new EntsFuryEffect());
|
||||
Effect conditionalEffect = new ConditionalOneShotEffect(
|
||||
new AddCountersTargetEffect(CounterType.P1P1.createInstance()),
|
||||
new TargetObjectMatchesFilterCondition(FILTER));
|
||||
conditionalEffect.setText("Put a +1/+1 counter on target creature you control if its power is 4 or greater");
|
||||
ContinuousEffect boostEffect = new BoostTargetEffect(1, 1, Duration.EndOfTurn);
|
||||
boostEffect.setText("Then that creature gets +1/+1 until end of turn");
|
||||
Effect fightEffect = new FightTargetsEffect(false);
|
||||
fightEffect.setText(" and fights target creature you don't control.");
|
||||
this.getSpellAbility().addEffect(conditionalEffect);
|
||||
this.getSpellAbility().addEffect(boostEffect);
|
||||
this.getSpellAbility().addEffect(fightEffect);
|
||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
||||
this.getSpellAbility().addTarget(new TargetPermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL));
|
||||
this.getSpellAbility().addTarget(new TargetOpponentsCreaturePermanent());
|
||||
}
|
||||
|
||||
private EntsFury(final EntsFury card) {
|
||||
|
|
@ -46,41 +62,3 @@ public final class EntsFury extends CardImpl {
|
|||
return new EntsFury(this);
|
||||
}
|
||||
}
|
||||
|
||||
class EntsFuryEffect extends OneShotEffect {
|
||||
|
||||
public EntsFuryEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Put a +1/+1 counter on target creature you control if its power is 4 or greater. " +
|
||||
"Then that creature gets +1/+1 until end of turn and fights target creature you don't control.";
|
||||
}
|
||||
|
||||
private EntsFuryEffect(final EntsFuryEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntsFuryEffect copy() {
|
||||
return new EntsFuryEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
if (permanent == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
// Checks if the creature's power is 4 or greater
|
||||
if (permanent.getPower().getValue() >= 4){
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(1), source.getControllerId(), source, game);
|
||||
}
|
||||
|
||||
// Adds temporary +1/+1 until end of turn and adds fight effect
|
||||
ContinuousEffect effect = new BoostTargetEffect(1, 1, Duration.EndOfTurn);
|
||||
effect.setTargetPointer(new FixedTarget(permanent, game));
|
||||
game.addEffect(effect, source);
|
||||
game.getState().processAction(game);
|
||||
return new FightTargetsEffect(false).apply(game, source);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.filter.FilterObject;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jwadsworth
|
||||
*/
|
||||
public class TargetObjectMatchesFilterCondition implements Condition {
|
||||
|
||||
private final FilterObject FILTER;
|
||||
private final String text;
|
||||
|
||||
public TargetObjectMatchesFilterCondition(FilterObject filter) {
|
||||
this(null, filter);
|
||||
}
|
||||
|
||||
public TargetObjectMatchesFilterCondition(String text, FilterObject filter) {
|
||||
this.FILTER = filter;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (!source.getTargets().isEmpty()) {
|
||||
MageObject mageObject = game.getObject(source.getFirstTarget());
|
||||
if (mageObject != null) {
|
||||
return FILTER.match(mageObject, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (text != null) {
|
||||
return text;
|
||||
}
|
||||
return super.toString();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue