forked from External/mage
* Fixed some cards that choose a subtype as entering the battlefield that did not work for copied permanents (e.g. Brass Herald for Mormir format).
This commit is contained in:
parent
3d00bd33d5
commit
7f4fc245cd
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");
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue