Search in sources :

Example 1 with BushidoAbility

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;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) BushidoAbility(mage.abilities.keyword.BushidoAbility) Ability(mage.abilities.Ability) BushidoAbility(mage.abilities.keyword.BushidoAbility) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) MageObjectReference(mage.MageObjectReference)

Aggregations

MageObjectReference (mage.MageObjectReference)1 Ability (mage.abilities.Ability)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 BushidoAbility (mage.abilities.keyword.BushidoAbility)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1 Permanent (mage.game.permanent.Permanent)1