mirror of
https://github.com/correl/mage.git
synced 2025-01-12 11:08:01 +00:00
Fixed AsThoughEffects: fixed Issue#23. Tests pass.
This commit is contained in:
parent
965565c680
commit
a3faf6eb90
1 changed files with 26 additions and 6 deletions
|
@ -263,19 +263,39 @@ public class ContinuousEffects implements Serializable {
|
|||
}
|
||||
|
||||
public boolean asThough(UUID objectId, AsThoughEffectType type, Game game) {
|
||||
for (AsThoughEffect entry: asThoughEffects) {
|
||||
AsThoughEffect effect = entry;
|
||||
List<AsThoughEffect> asThoughEffectsList = getApplicableAsThoughEffects(game);
|
||||
|
||||
for (AsThoughEffect effect: asThoughEffectsList) {
|
||||
if (effect.getAsThoughEffectType() == type) {
|
||||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
if (effect.applies(objectId, asThoughEffects.getAbility(entry.getId()), game)) {
|
||||
return true;
|
||||
}
|
||||
if (effect.applies(objectId, asThoughEffects.getAbility(effect.getId()), game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters out asThough effects that are not active.
|
||||
*
|
||||
* @param game
|
||||
* @return
|
||||
*/
|
||||
private List<AsThoughEffect> getApplicableAsThoughEffects(Game game) {
|
||||
List<AsThoughEffect> asThoughEffectsList = new ArrayList<AsThoughEffect>();
|
||||
|
||||
for (AsThoughEffect effect: asThoughEffects) {
|
||||
Ability ability = asThoughEffects.getAbility(effect.getId());
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, false)) {
|
||||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
asThoughEffectsList.add(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return asThoughEffectsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inspects all {@link Permanent permanent's} {@link Ability abilities} on the battlefield
|
||||
* for {@link CostModificationEffect cost modification effects} and applies them if necessary.
|
||||
|
|
Loading…
Reference in a new issue