mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 13:19:18 -08:00
Fixed Issue#35. All tests pass now.
This commit is contained in:
parent
aa071912cb
commit
c61e4f2b32
13 changed files with 230 additions and 18 deletions
|
|
@ -33,16 +33,23 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -71,10 +78,8 @@ public class DearlyDeparted extends CardImpl<DearlyDeparted> {
|
|||
this.addAbility(FlyingAbility.getInstance());
|
||||
|
||||
// As long as Dearly Departed is in your graveyard, each Human creature you control enters the battlefield with an additional +1/+1 counter on it.
|
||||
Ability ability = new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(1)));
|
||||
ContinuousEffect effect = new GainAbilityControlledEffect(ability, Constants.Duration.WhileInGraveyard, filterHuman);
|
||||
effect.overrideRuleText(ruleText);
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.GRAVEYARD, effect));
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.GRAVEYARD,
|
||||
new EntersBattlefieldEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(1)), ruleText)));
|
||||
}
|
||||
|
||||
public DearlyDeparted(final DearlyDeparted card) {
|
||||
|
|
@ -86,3 +91,80 @@ public class DearlyDeparted extends CardImpl<DearlyDeparted> {
|
|||
return new DearlyDeparted(this);
|
||||
}
|
||||
}
|
||||
|
||||
class EntersBattlefieldEffect extends ReplacementEffectImpl<EntersBattlefieldEffect> {
|
||||
|
||||
protected Effects baseEffects = new Effects();
|
||||
protected String text;
|
||||
|
||||
public static final String SOURCE_CAST_SPELL_ABILITY = "sourceCastSpellAbility";
|
||||
|
||||
public EntersBattlefieldEffect(Effect baseEffect) {
|
||||
this(baseEffect, "");
|
||||
}
|
||||
|
||||
public EntersBattlefieldEffect(Effect baseEffect, String text) {
|
||||
super(Constants.Duration.OneUse, baseEffect.getOutcome());
|
||||
this.baseEffects.add(baseEffect);
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public EntersBattlefieldEffect(EntersBattlefieldEffect effect) {
|
||||
super(effect);
|
||||
this.baseEffects = effect.baseEffects.copy();
|
||||
this.text = effect.text;
|
||||
}
|
||||
|
||||
public void addEffect(Effect effect) {
|
||||
baseEffects.add(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && permanent.getControllerId().equals(source.getControllerId()) && permanent.hasSubtype("Human")) {
|
||||
setValue("target", permanent);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Spell spell = game.getStack().getSpell(event.getSourceId());
|
||||
for (Effect effect: baseEffects) {
|
||||
Object target = getValue("target");
|
||||
if (target != null && target instanceof Permanent) {
|
||||
effect.setTargetPointer(new FixedTarget(((Permanent)target).getId()));
|
||||
if (effect instanceof ContinuousEffect) {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
else {
|
||||
if (spell != null) {
|
||||
effect.setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility());
|
||||
}
|
||||
effect.apply(game, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
return (text == null || text.isEmpty()) ? baseEffects.getText(mode) : text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntersBattlefieldEffect copy() {
|
||||
return new EntersBattlefieldEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue