mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
correct fix for Umezawa's Jitte
This commit is contained in:
parent
d924b6c017
commit
429a03b557
2 changed files with 36 additions and 45 deletions
|
@ -37,6 +37,7 @@ import mage.abilities.common.SimpleActivatedAbility;
|
|||
import mage.abilities.costs.common.RemoveCountersSourceCost;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.common.GainLifeEffect;
|
||||
import mage.abilities.effects.common.continious.BoostEquippedEffect;
|
||||
import mage.abilities.effects.common.continious.BoostTargetEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.keyword.EquipAbility;
|
||||
|
@ -69,8 +70,7 @@ public class UmezawasJitte extends CardImpl<UmezawasJitte> {
|
|||
this.addAbility(new UmezawasJitteAbility());
|
||||
|
||||
// Remove a charge counter from Umezawa's Jitte: Choose one Equipped creature gets +2/+2 until end of turn; or target creature gets -1/-1 until end of turn; or you gain 2 life.
|
||||
|
||||
Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new UmezawasJitteEffect(), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance()));
|
||||
Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new BoostEquippedEffect(2, 2, Constants.Duration.EndOfTurn), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance()));
|
||||
Mode mode = new Mode();
|
||||
mode.getEffects().add(new BoostTargetEffect(-1, -1, Constants.Duration.EndOfTurn));
|
||||
mode.getTargets().add(new TargetCreaturePermanent());
|
||||
|
@ -125,34 +125,3 @@ class UmezawasJitteAbility extends TriggeredAbilityImpl<UmezawasJitteAbility> {
|
|||
return "Whenever equipped creature deals combat damage, put two charge counters on {this}.";
|
||||
}
|
||||
}
|
||||
|
||||
class UmezawasJitteEffect extends OneShotEffect<UmezawasJitteEffect> {
|
||||
|
||||
UmezawasJitteEffect() {
|
||||
super(Constants.Outcome.BoostCreature);
|
||||
staticText = "Equipped creature gets +2/+2 until end of turn";
|
||||
}
|
||||
|
||||
UmezawasJitteEffect(final UmezawasJitteEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null) {
|
||||
Permanent equipped = game.getPermanent(equipment.getAttachedTo());
|
||||
if (equipped != null) {
|
||||
Effect effect = new BoostSourceEffect(2, 2, Constants.Duration.EndOfTurn);
|
||||
equipped.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect), game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UmezawasJitteEffect copy() {
|
||||
return new UmezawasJitteEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,15 +38,16 @@ import mage.abilities.dynamicvalue.common.StaticValue;
|
|||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class BoostEquippedEffect extends ContinuousEffectImpl<BoostEquippedEffect> {
|
||||
|
||||
private DynamicValue power;
|
||||
private DynamicValue toughness;
|
||||
private boolean fixedTarget = false;
|
||||
|
||||
public BoostEquippedEffect(int power, int toughness) {
|
||||
this(power, toughness, Duration.WhileOnBattlefield);
|
||||
|
@ -64,6 +65,9 @@ public class BoostEquippedEffect extends ContinuousEffectImpl<BoostEquippedEffec
|
|||
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
||||
this.power = powerDynamicValue;
|
||||
this.toughness = toughnessDynamicValue;
|
||||
if (duration == Duration.EndOfTurn) {
|
||||
fixedTarget = true;
|
||||
}
|
||||
setText();
|
||||
}
|
||||
|
||||
|
@ -71,6 +75,7 @@ public class BoostEquippedEffect extends ContinuousEffectImpl<BoostEquippedEffec
|
|||
super(effect);
|
||||
this.power = effect.power.clone();
|
||||
this.toughness = effect.toughness.clone();
|
||||
this.fixedTarget = effect.fixedTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,15 +84,33 @@ public class BoostEquippedEffect extends ContinuousEffectImpl<BoostEquippedEffec
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
Permanent creature = game.getPermanent(equipment.getAttachedTo());
|
||||
if (creature != null) {
|
||||
creature.addPower(power.calculate(game, source));
|
||||
creature.addToughness(toughness.calculate(game, source));
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (fixedTarget) {
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
this.setTargetPointer(new FixedTarget(equipment.getAttachedTo()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent creature = null;
|
||||
if (fixedTarget) {
|
||||
creature = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
} else {
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
creature = game.getPermanent(equipment.getAttachedTo());
|
||||
}
|
||||
}
|
||||
|
||||
if (creature != null) {
|
||||
creature.addPower(power.calculate(game, source));
|
||||
creature.addToughness(toughness.calculate(game, source));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -95,12 +118,12 @@ public class BoostEquippedEffect extends ContinuousEffectImpl<BoostEquippedEffec
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Equipped creature gets ");
|
||||
String p = power.toString();
|
||||
if(!p.startsWith("-"))
|
||||
if (!p.startsWith("-"))
|
||||
sb.append("+");
|
||||
sb.append(p).append("/");
|
||||
String t = toughness.toString();
|
||||
if(!t.startsWith("-")){
|
||||
if(p.startsWith("-"))
|
||||
if (!t.startsWith("-")) {
|
||||
if (p.startsWith("-"))
|
||||
sb.append("-");
|
||||
else
|
||||
sb.append("+");
|
||||
|
@ -115,5 +138,4 @@ public class BoostEquippedEffect extends ContinuousEffectImpl<BoostEquippedEffec
|
|||
sb.append(message);
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue