forked from External/mage
[FIN] Implement Excalibur II
This commit is contained in:
parent
51d199f75b
commit
06f5fe0cff
3 changed files with 73 additions and 17 deletions
|
|
@ -1,19 +1,20 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
|
@ -31,14 +32,14 @@ public class BoostEquippedEffect extends ContinuousEffectImpl {
|
|||
this(StaticValue.get(power), StaticValue.get(toughness), duration);
|
||||
}
|
||||
|
||||
public BoostEquippedEffect(DynamicValue powerDynamicValue, DynamicValue toughnessDynamicValue) {
|
||||
this(powerDynamicValue, toughnessDynamicValue, Duration.WhileOnBattlefield);
|
||||
public BoostEquippedEffect(DynamicValue power, DynamicValue toughness) {
|
||||
this(power, toughness, Duration.WhileOnBattlefield);
|
||||
}
|
||||
|
||||
public BoostEquippedEffect(DynamicValue powerDynamicValue, DynamicValue toughnessDynamicValue, Duration duration) {
|
||||
public BoostEquippedEffect(DynamicValue power, DynamicValue toughness, Duration duration) {
|
||||
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
||||
this.power = powerDynamicValue;
|
||||
this.toughness = toughnessDynamicValue;
|
||||
this.power = power;
|
||||
this.toughness = toughness;
|
||||
if (duration == Duration.EndOfTurn) {
|
||||
fixedTarget = true;
|
||||
}
|
||||
|
|
@ -70,21 +71,22 @@ public class BoostEquippedEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent creature = null;
|
||||
Permanent creature;
|
||||
if (fixedTarget) {
|
||||
creature = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
} else {
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
creature = game.getPermanent(equipment.getAttachedTo());
|
||||
}
|
||||
creature = Optional
|
||||
.ofNullable(source)
|
||||
.map(Ability::getSourceId)
|
||||
.map(game::getPermanent)
|
||||
.map(Permanent::getAttachedTo)
|
||||
.map(game::getPermanent)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
if (creature != null) {
|
||||
creature.addPower(power.calculate(game, source, this));
|
||||
creature.addToughness(toughness.calculate(game, source, this));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue