for AI: made BoostTargetEffect negative effect for */-X spells

This commit is contained in:
magenoxx 2012-06-28 10:11:03 +04:00
parent 30264a4326
commit b983bb2e7d
2 changed files with 20 additions and 1 deletions

View file

@ -58,6 +58,9 @@ public class DomainValue implements DynamicValue {
return amount.toString();
}
public Integer getAmount() {
return amount;
}
@Override
public String getMessage() {

View file

@ -34,6 +34,8 @@ import mage.Constants.SubLayer;
import mage.abilities.Ability;
import mage.abilities.Mode;
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.effects.ContinuousEffectImpl;
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
*/
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.toughness = toughness;
this.lockedIn = lockedIn;
@ -77,6 +79,20 @@ public class BoostTargetEffect extends ContinuousEffectImpl<BoostTargetEffect> {
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
public BoostTargetEffect copy() {
return new BoostTargetEffect(this);