use of mage.abilities.keyword.BushidoAbility in project mage by magefree.
the class TakenoSamuraiGeneralEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (this.affectedObjectsSet) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
// filter may not be used again, because object can have changed filter relevant attributes but still geets boost
Permanent permanent = it.next().getPermanent(game);
if (permanent != null) {
for (Ability ability : permanent.getAbilities()) {
if (ability instanceof BushidoAbility) {
int value = ((BushidoAbility) ability).getValue(source, game, this);
permanent.addPower(value);
permanent.addToughness(value);
}
}
} else {
// no longer on the battlefield, remove reference to object
it.remove();
}
}
} else {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (!perm.getId().equals(source.getSourceId())) {
for (Ability ability : perm.getAbilities()) {
if (ability instanceof BushidoAbility) {
int value = ((BushidoAbility) ability).getValue(source, game, this);
perm.addPower(value);
perm.addToughness(value);
}
}
}
}
}
return true;
}
Aggregations