forked from External/mage
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
eb8519cd78
12 changed files with 282 additions and 53 deletions
|
|
@ -109,9 +109,10 @@ public class BoostAllEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
setRuntimeData(source, game);
|
||||
if (this.affectedObjectsSet) {
|
||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
|
||||
affectedObjectList.add(new MageObjectReference(perm, game));
|
||||
}
|
||||
}
|
||||
|
|
@ -135,8 +136,9 @@ public class BoostAllEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
setRuntimeData(source, game);
|
||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
|
||||
perm.addPower(power.calculate(game, source, this));
|
||||
perm.addToughness(toughness.calculate(game, source, this));
|
||||
}
|
||||
|
|
@ -146,7 +148,29 @@ public class BoostAllEffect extends ContinuousEffectImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
/**
|
||||
* Overwrite this in effect that inherits from this
|
||||
*
|
||||
* @param source
|
||||
* @param game
|
||||
*/
|
||||
protected void setRuntimeData(Ability source, Game game) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite this in effect that inherits from this
|
||||
*
|
||||
* @param permanent
|
||||
* @param source
|
||||
* @param game
|
||||
* @return
|
||||
*/
|
||||
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void setText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (excludeSource) {
|
||||
sb.append("Other ");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.Duration;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class BoostAllOfChosenSubtypeEffect extends BoostAllEffect {
|
||||
|
||||
String subtype = null;
|
||||
|
||||
public BoostAllOfChosenSubtypeEffect(int power, int toughness, Duration duration, boolean excludeSource) {
|
||||
super(power, toughness, duration, new FilterCreaturePermanent("All creatures of the chosen type"), excludeSource);
|
||||
}
|
||||
|
||||
public BoostAllOfChosenSubtypeEffect(int power, int toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) {
|
||||
super(power, toughness, duration, filter, excludeSource);
|
||||
}
|
||||
|
||||
public BoostAllOfChosenSubtypeEffect(final BoostAllOfChosenSubtypeEffect effect) {
|
||||
super(effect);
|
||||
this.subtype = effect.subtype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoostAllOfChosenSubtypeEffect copy() {
|
||||
return new BoostAllOfChosenSubtypeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
|
||||
if (subtype != null) {
|
||||
return permanent.hasSubtype(subtype);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRuntimeData(Ability source, Game game) {
|
||||
subtype = (String) game.getState().getValue(source.getSourceId() + "_type");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -92,9 +92,10 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
setRuntimeData(source, game);
|
||||
if (this.affectedObjectsSet) {
|
||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
|
||||
affectedObjectList.add(new MageObjectReference(perm, game));
|
||||
}
|
||||
}
|
||||
|
|
@ -121,8 +122,9 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
setRuntimeData(source, game);
|
||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
|
||||
perm.addAbility(ability, source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -131,7 +133,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
|
|||
if (LKIBattlefield != null) {
|
||||
for (MageObject mageObject : LKIBattlefield.values()) {
|
||||
Permanent perm = (Permanent) mageObject;
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
|
||||
if (filter.match(perm, source.getSourceId(), source.getControllerId(), game)) {
|
||||
perm.addAbility(ability, source.getSourceId(), game, false);
|
||||
}
|
||||
|
|
@ -142,6 +144,28 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite this in effect that inherits from this
|
||||
*
|
||||
* @param source
|
||||
* @param game
|
||||
*/
|
||||
protected void setRuntimeData(Ability source, Game game) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite this in effect that inherits from this
|
||||
*
|
||||
* @param permanent
|
||||
* @param source
|
||||
* @param game
|
||||
* @return
|
||||
*/
|
||||
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.Duration;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class GainAbilityAllOfChosenSubtypeEffect extends GainAbilityAllEffect {
|
||||
|
||||
String subtype = null;
|
||||
|
||||
public GainAbilityAllOfChosenSubtypeEffect(Ability ability, Duration duration, FilterPermanent filter) {
|
||||
super(ability, duration, filter);
|
||||
}
|
||||
|
||||
public GainAbilityAllOfChosenSubtypeEffect(final GainAbilityAllOfChosenSubtypeEffect effect) {
|
||||
super(effect);
|
||||
this.subtype = effect.subtype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainAbilityAllOfChosenSubtypeEffect copy() {
|
||||
return new GainAbilityAllOfChosenSubtypeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
|
||||
if (subtype != null) {
|
||||
return permanent.hasSubtype(subtype);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRuntimeData(Ability source, Game game) {
|
||||
subtype = (String) game.getState().getValue(source.getSourceId() + "_type");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -60,14 +60,14 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl {
|
|||
public SpellsCostReductionAllEffect(FilterCard filter, int amount) {
|
||||
this(filter, amount, false);
|
||||
}
|
||||
|
||||
|
||||
public SpellsCostReductionAllEffect(FilterCard filter, int amount, boolean upTo) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
this.filter = filter;
|
||||
this.amount = amount;
|
||||
this.upTo = upTo;
|
||||
|
||||
this.staticText = filter.getMessage() + " cost " + (upTo ?"up to " :"") + "{" +amount + "} less to cast";
|
||||
|
||||
this.staticText = filter.getMessage() + " cost " + (upTo ? "up to " : "") + "{" + amount + "} less to cast";
|
||||
}
|
||||
|
||||
protected SpellsCostReductionAllEffect(SpellsCostReductionAllEffect effect) {
|
||||
|
|
@ -109,16 +109,38 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite this in effect that inherits from this
|
||||
*
|
||||
* @param source
|
||||
* @param game
|
||||
*/
|
||||
protected void setRuntimeData(Ability source, Game game) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite this in effect that inherits from this
|
||||
*
|
||||
* @param card
|
||||
* @param source
|
||||
* @param game
|
||||
* @return
|
||||
*/
|
||||
protected boolean selectedByRuntimeData(Card card, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
||||
if (spell != null) {
|
||||
return this.filter.match(spell, game);
|
||||
return this.filter.match(spell, game) && selectedByRuntimeData(spell, source, game);
|
||||
} else {
|
||||
// used at least for flashback ability because Flashback ability doesn't use stack
|
||||
Card sourceCard = game.getCard(abilityToModify.getSourceId());
|
||||
return sourceCard != null && this.filter.match(sourceCard, game);
|
||||
return sourceCard != null && this.filter.match(sourceCard, game) && selectedByRuntimeData(sourceCard, source, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common.cost;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class SpellsCostReductionAllOfChosenSubtypeEffect extends SpellsCostReductionAllEffect {
|
||||
|
||||
String subtype = null;
|
||||
|
||||
public SpellsCostReductionAllOfChosenSubtypeEffect(FilterCard filter, int amount) {
|
||||
super(filter, amount);
|
||||
}
|
||||
|
||||
public SpellsCostReductionAllOfChosenSubtypeEffect(final SpellsCostReductionAllOfChosenSubtypeEffect effect) {
|
||||
super(effect);
|
||||
this.subtype = effect.subtype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellsCostReductionAllOfChosenSubtypeEffect copy() {
|
||||
return new SpellsCostReductionAllOfChosenSubtypeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean selectedByRuntimeData(Card card, Ability source, Game game) {
|
||||
if (subtype != null) {
|
||||
return card.hasSubtype(subtype);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRuntimeData(Ability source, Game game) {
|
||||
subtype = (String) game.getState().getValue(source.getSourceId() + "_type");
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue