mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
for AI: made BoostTargetEffect negative effect for */-X spells
This commit is contained in:
parent
30264a4326
commit
b983bb2e7d
2 changed files with 20 additions and 1 deletions
|
@ -58,6 +58,9 @@ public class DomainValue implements DynamicValue {
|
||||||
return amount.toString();
|
return amount.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
|
|
|
@ -34,6 +34,8 @@ import mage.Constants.SubLayer;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
import mage.abilities.Mode;
|
||||||
import mage.abilities.dynamicvalue.DynamicValue;
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
|
import mage.abilities.dynamicvalue.common.DomainValue;
|
||||||
|
import mage.abilities.dynamicvalue.common.SignInversionDynamicValue;
|
||||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -64,7 +66,7 @@ public class BoostTargetEffect extends ContinuousEffectImpl<BoostTargetEffect> {
|
||||||
* @param lockedIn if true, power and toughness will be calculated only once, when the ability resolves
|
* @param lockedIn if true, power and toughness will be calculated only once, when the ability resolves
|
||||||
*/
|
*/
|
||||||
public BoostTargetEffect(DynamicValue power, DynamicValue toughness, Duration duration, boolean lockedIn) {
|
public BoostTargetEffect(DynamicValue power, DynamicValue toughness, Duration duration, boolean lockedIn) {
|
||||||
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, isCanKill(toughness) ? Outcome.UnboostCreature : Outcome.BoostCreature);
|
||||||
this.power = power;
|
this.power = power;
|
||||||
this.toughness = toughness;
|
this.toughness = toughness;
|
||||||
this.lockedIn = lockedIn;
|
this.lockedIn = lockedIn;
|
||||||
|
@ -77,6 +79,20 @@ public class BoostTargetEffect extends ContinuousEffectImpl<BoostTargetEffect> {
|
||||||
this.lockedIn = effect.lockedIn;
|
this.lockedIn = effect.lockedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isCanKill(DynamicValue toughness) {
|
||||||
|
if (toughness instanceof StaticValue) {
|
||||||
|
return toughness.calculate(null, null) < 0;
|
||||||
|
}
|
||||||
|
if (toughness instanceof SignInversionDynamicValue) {
|
||||||
|
// count this class as used for "-{something_positive}"
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (toughness instanceof DomainValue) {
|
||||||
|
return ((DomainValue)toughness).getAmount() < 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoostTargetEffect copy() {
|
public BoostTargetEffect copy() {
|
||||||
return new BoostTargetEffect(this);
|
return new BoostTargetEffect(this);
|
||||||
|
|
Loading…
Reference in a new issue