mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
Added lockedIn parameter to BoostEffects.
This commit is contained in:
parent
98606e16b7
commit
8618b45bc8
3 changed files with 153 additions and 138 deletions
|
|
@ -48,89 +48,96 @@ public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledE
|
||||||
|
|
||||||
private DynamicValue power;
|
private DynamicValue power;
|
||||||
private DynamicValue toughness;
|
private DynamicValue toughness;
|
||||||
protected boolean excludeSource;
|
protected FilterCreaturePermanent filter;
|
||||||
protected FilterCreaturePermanent filter;
|
protected boolean excludeSource;
|
||||||
// if true, all dynamic values should be calculated once
|
protected boolean lockedIn = false;
|
||||||
protected boolean isLockedIn = false;
|
|
||||||
|
|
||||||
public BoostControlledEffect(int power, int toughness, Duration duration) {
|
public BoostControlledEffect(int power, int toughness, Duration duration) {
|
||||||
this(power, toughness, duration, new FilterCreaturePermanent(), false);
|
this(power, toughness, duration, new FilterCreaturePermanent(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoostControlledEffect(DynamicValue power, DynamicValue toughness, Duration duration) {
|
public BoostControlledEffect(DynamicValue power, DynamicValue toughness, Duration duration) {
|
||||||
this(power, toughness, duration, new FilterCreaturePermanent(), false);
|
this(power, toughness, duration, new FilterCreaturePermanent(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoostControlledEffect(int power, int toughness, Duration duration, boolean excludeSource) {
|
public BoostControlledEffect(int power, int toughness, Duration duration, boolean excludeSource) {
|
||||||
this(power, toughness, duration, new FilterCreaturePermanent(), excludeSource);
|
this(power, toughness, duration, new FilterCreaturePermanent(), excludeSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoostControlledEffect(int power, int toughness, Duration duration, FilterCreaturePermanent filter) {
|
public BoostControlledEffect(int power, int toughness, Duration duration, FilterCreaturePermanent filter) {
|
||||||
this(new StaticValue(power), new StaticValue(toughness), duration, filter, false);
|
this(new StaticValue(power), new StaticValue(toughness), duration, filter, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoostControlledEffect(int power, int toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) {
|
public BoostControlledEffect(int power, int toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) {
|
||||||
this(new StaticValue(power), new StaticValue(toughness), duration, filter, excludeSource);
|
this(new StaticValue(power), new StaticValue(toughness), duration, filter, excludeSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoostControlledEffect(DynamicValue power, DynamicValue toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) {
|
public BoostControlledEffect(DynamicValue power, DynamicValue toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) {
|
||||||
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
this(power, toughness, duration, filter, excludeSource, false);
|
||||||
this.power = power;
|
}
|
||||||
this.toughness = toughness;
|
|
||||||
this.filter = filter;
|
|
||||||
this.excludeSource = excludeSource;
|
|
||||||
setText();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BoostControlledEffect(final BoostControlledEffect effect) {
|
/**
|
||||||
super(effect);
|
* @param lockedIn if true, power and toughness will be calculated only once, when the ability resolves
|
||||||
this.power = effect.power;
|
*/
|
||||||
this.toughness = effect.toughness;
|
public BoostControlledEffect(DynamicValue power, DynamicValue toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource, boolean lockedIn) {
|
||||||
this.filter = effect.filter.copy();
|
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
||||||
this.excludeSource = effect.excludeSource;
|
this.power = power;
|
||||||
this.isLockedIn = effect.isLockedIn;
|
this.toughness = toughness;
|
||||||
}
|
this.filter = filter;
|
||||||
|
this.excludeSource = excludeSource;
|
||||||
|
this.lockedIn = lockedIn;
|
||||||
|
setText();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public BoostControlledEffect(final BoostControlledEffect effect) {
|
||||||
public BoostControlledEffect copy() {
|
super(effect);
|
||||||
return new BoostControlledEffect(this);
|
this.power = effect.power;
|
||||||
}
|
this.toughness = effect.toughness;
|
||||||
|
this.filter = effect.filter.copy();
|
||||||
|
this.excludeSource = effect.excludeSource;
|
||||||
|
this.lockedIn = effect.lockedIn;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public BoostControlledEffect copy() {
|
||||||
super.init(source, game);
|
return new BoostControlledEffect(this);
|
||||||
if (this.affectedObjectsSet) {
|
}
|
||||||
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
|
||||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
@Override
|
||||||
objects.add(perm.getId());
|
public void init(Ability source, Game game) {
|
||||||
}
|
super.init(source, game);
|
||||||
}
|
if (this.affectedObjectsSet) {
|
||||||
}
|
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||||
if (this.isLockedIn) {
|
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||||
|
objects.add(perm.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.lockedIn) {
|
||||||
power = new StaticValue(power.calculate(game, source));
|
power = new StaticValue(power.calculate(game, source));
|
||||||
toughness = new StaticValue(toughness.calculate(game, source));
|
toughness = new StaticValue(toughness.calculate(game, source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||||
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
|
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
|
||||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||||
perm.addPower(power.calculate(game, source));
|
perm.addPower(power.calculate(game, source));
|
||||||
perm.addToughness(toughness.calculate(game, source));
|
perm.addToughness(toughness.calculate(game, source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setText() {
|
private void setText() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (excludeSource)
|
if (excludeSource)
|
||||||
sb.append("Other ");
|
sb.append("Other ");
|
||||||
sb.append(filter.getMessage());
|
sb.append(filter.getMessage());
|
||||||
sb.append(" you control get ");
|
sb.append(" you control get ");
|
||||||
|
|
||||||
String p = power.toString();
|
String p = power.toString();
|
||||||
if(!p.startsWith("-")) {
|
if(!p.startsWith("-")) {
|
||||||
|
|
@ -147,16 +154,15 @@ public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledE
|
||||||
}
|
}
|
||||||
sb.append(t);
|
sb.append(t);
|
||||||
|
|
||||||
sb.append((duration==Duration.EndOfTurn?" until end of turn":""));
|
sb.append((duration==Duration.EndOfTurn?" until end of turn":""));
|
||||||
staticText = sb.toString();
|
staticText = sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRule(String rule) {
|
public void setRule(String rule) {
|
||||||
staticText = rule;
|
staticText = rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLockedIn(boolean isLockedIn) {
|
public void setLockedIn(boolean lockedIn) {
|
||||||
this.isLockedIn =isLockedIn;
|
this.lockedIn = lockedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,49 +44,68 @@ import mage.game.permanent.Permanent;
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class BoostSourceEffect extends ContinuousEffectImpl<BoostSourceEffect> {
|
public class BoostSourceEffect extends ContinuousEffectImpl<BoostSourceEffect> {
|
||||||
private DynamicValue power;
|
private DynamicValue power;
|
||||||
private DynamicValue toughness;
|
private DynamicValue toughness;
|
||||||
|
private boolean lockedIn;
|
||||||
|
|
||||||
public BoostSourceEffect(int power, int toughness, Duration duration) {
|
public BoostSourceEffect(int power, int toughness, Duration duration) {
|
||||||
this(new StaticValue(power), new StaticValue(toughness), duration);
|
this(new StaticValue(power), new StaticValue(toughness), duration, false);
|
||||||
}
|
|
||||||
|
|
||||||
public BoostSourceEffect(DynamicValue power, DynamicValue toughness, Duration duration) {
|
|
||||||
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
|
||||||
this.power = power;
|
|
||||||
this.toughness = toughness;
|
|
||||||
setText();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoostSourceEffect(final BoostSourceEffect effect) {
|
public BoostSourceEffect(DynamicValue power, DynamicValue toughness, Duration duration) {
|
||||||
super(effect);
|
this(power, toughness, duration, false);
|
||||||
this.power = effect.power.clone();
|
}
|
||||||
this.toughness = effect.toughness.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public BoostSourceEffect copy() {
|
* @param lockedIn if true, power and toughness will be calculated only once, when the ability resolves
|
||||||
return new BoostSourceEffect(this);
|
*/
|
||||||
}
|
public BoostSourceEffect(DynamicValue power, DynamicValue toughness, Duration duration, boolean lockedIn) {
|
||||||
|
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
||||||
|
this.power = power;
|
||||||
|
this.toughness = toughness;
|
||||||
|
this.lockedIn = lockedIn;
|
||||||
|
setText();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public BoostSourceEffect(final BoostSourceEffect effect) {
|
||||||
public boolean apply(Game game, Ability source) {
|
super(effect);
|
||||||
Permanent target = game.getPermanent(source.getSourceId());
|
this.power = effect.power.clone();
|
||||||
if (target != null) {
|
this.toughness = effect.toughness.clone();
|
||||||
target.addPower(power.calculate(game, source));
|
this.lockedIn = effect.lockedIn;
|
||||||
target.addToughness(toughness.calculate(game, source));
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRule(String value) {
|
@Override
|
||||||
staticText = value;
|
public BoostSourceEffect copy() {
|
||||||
}
|
return new BoostSourceEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
private void setText() {
|
@Override
|
||||||
StringBuilder sb = new StringBuilder();
|
public void init(Ability source, Game game) {
|
||||||
sb.append("{this} gets ");
|
super.init(source, game);
|
||||||
|
if (lockedIn) {
|
||||||
|
power = new StaticValue(power.calculate(game, source));
|
||||||
|
toughness = new StaticValue(toughness.calculate(game, source));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Permanent target = game.getPermanent(source.getSourceId());
|
||||||
|
if (target != null) {
|
||||||
|
target.addPower(power.calculate(game, source));
|
||||||
|
target.addToughness(toughness.calculate(game, source));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRule(String value) {
|
||||||
|
staticText = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setText() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("{this} gets ");
|
||||||
String p = power.toString();
|
String p = power.toString();
|
||||||
if(!p.startsWith("-"))
|
if(!p.startsWith("-"))
|
||||||
sb.append("+");
|
sb.append("+");
|
||||||
|
|
@ -99,8 +118,8 @@ public class BoostSourceEffect extends ContinuousEffectImpl<BoostSourceEffect> {
|
||||||
sb.append("+");
|
sb.append("+");
|
||||||
}
|
}
|
||||||
sb.append(t);
|
sb.append(t);
|
||||||
if (duration != Duration.WhileOnBattlefield)
|
if (duration != Duration.WhileOnBattlefield)
|
||||||
sb.append(" ").append(duration.toString());
|
sb.append(" ").append(duration.toString());
|
||||||
String message = power.getMessage();
|
String message = power.getMessage();
|
||||||
if (message.length() == 0)
|
if (message.length() == 0)
|
||||||
message = toughness.getMessage();
|
message = toughness.getMessage();
|
||||||
|
|
@ -108,7 +127,7 @@ public class BoostSourceEffect extends ContinuousEffectImpl<BoostSourceEffect> {
|
||||||
sb.append(" for each ");
|
sb.append(" for each ");
|
||||||
}
|
}
|
||||||
sb.append(message);
|
sb.append(message);
|
||||||
staticText = sb.toString();
|
staticText = sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,37 +49,31 @@ public class BoostTargetEffect extends ContinuousEffectImpl<BoostTargetEffect> {
|
||||||
|
|
||||||
private DynamicValue power;
|
private DynamicValue power;
|
||||||
private DynamicValue toughness;
|
private DynamicValue toughness;
|
||||||
// if true, all dynamic values should be calculated once
|
private boolean lockedIn;
|
||||||
protected boolean isLockedIn = false;
|
|
||||||
|
|
||||||
public BoostTargetEffect(int power, int toughness, Duration duration) {
|
public BoostTargetEffect(int power, int toughness, Duration duration) {
|
||||||
this(new StaticValue(power), new StaticValue(toughness), duration);
|
this(new StaticValue(power), new StaticValue(toughness), duration, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoostTargetEffect(DynamicValue power, DynamicValue toughness, Duration duration) {
|
public BoostTargetEffect(DynamicValue power, DynamicValue toughness, Duration duration) {
|
||||||
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
this(power, toughness, duration, false);
|
||||||
this.power = power;
|
|
||||||
this.toughness = toughness;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param power power value to boost
|
* @param lockedIn if true, power and toughness will be calculated only once, when the ability resolves
|
||||||
* @param toughness toughness value to boost
|
|
||||||
* @param duration how long does the effecct apply
|
|
||||||
* @param continuousCalculation true = power and toughness will be calculated continuously
|
|
||||||
* false = power and toughness will be calculated once during resolution
|
|
||||||
*/
|
*/
|
||||||
public BoostTargetEffect(DynamicValue power, DynamicValue toughness, Duration duration, boolean isLockedIn) {
|
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, Outcome.BoostCreature);
|
||||||
this.power = power;
|
this.power = power;
|
||||||
this.toughness = toughness;
|
this.toughness = toughness;
|
||||||
this.isLockedIn = isLockedIn;
|
this.lockedIn = lockedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoostTargetEffect(final BoostTargetEffect effect) {
|
public BoostTargetEffect(final BoostTargetEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.power = effect.power.clone();
|
this.power = effect.power.clone();
|
||||||
this.toughness = effect.toughness.clone();
|
this.toughness = effect.toughness.clone();
|
||||||
this.isLockedIn = effect.isLockedIn;
|
this.lockedIn = effect.lockedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -89,11 +83,11 @@ public class BoostTargetEffect extends ContinuousEffectImpl<BoostTargetEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (isLockedIn) {
|
if (lockedIn) {
|
||||||
power = new StaticValue(power.calculate(game, source));
|
power = new StaticValue(power.calculate(game, source));
|
||||||
toughness = new StaticValue(toughness.calculate(game, source));
|
toughness = new StaticValue(toughness.calculate(game, source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -132,7 +126,7 @@ public class BoostTargetEffect extends ContinuousEffectImpl<BoostTargetEffect> {
|
||||||
}
|
}
|
||||||
sb.append(t);
|
sb.append(t);
|
||||||
if (duration != Duration.WhileOnBattlefield)
|
if (duration != Duration.WhileOnBattlefield)
|
||||||
sb.append(" ").append(duration.toString());
|
sb.append(" ").append(duration.toString());
|
||||||
String message = power.getMessage();
|
String message = power.getMessage();
|
||||||
if (message.length() > 0) {
|
if (message.length() > 0) {
|
||||||
sb.append(" for each ");
|
sb.append(" for each ");
|
||||||
|
|
@ -140,8 +134,4 @@ public class BoostTargetEffect extends ContinuousEffectImpl<BoostTargetEffect> {
|
||||||
sb.append(message);
|
sb.append(message);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLockedIn(boolean isLockedIn) {
|
|
||||||
this.isLockedIn =isLockedIn;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue