Search in sources :

Example 1 with MostCommonColorCondition

use of mage.abilities.condition.common.MostCommonColorCondition in project mage by magefree.

the class CallToArmsStateTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    UUID playerId = (UUID) game.getState().getValue(source.getSourceId() + ChooseOpponentEffect.VALUE_KEY);
    if (permanent != null) {
        Player opponent = game.getPlayer(playerId);
        if (opponent != null) {
            ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
            Condition condition = new MostCommonColorCondition(color, true, new ControllerIdPredicate(playerId));
            if (condition.apply(game, source)) {
                Effect effect = new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, false);
                return effect.apply(game, source);
            }
        }
    }
    return false;
}
Also used : MostCommonColorCondition(mage.abilities.condition.common.MostCommonColorCondition) Condition(mage.abilities.condition.Condition) Player(mage.players.Player) MostCommonColorCondition(mage.abilities.condition.common.MostCommonColorCondition) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ObjectColor(mage.ObjectColor) ChooseColorEffect(mage.abilities.effects.common.ChooseColorEffect) Effect(mage.abilities.effects.Effect) ChooseOpponentEffect(mage.abilities.effects.common.ChooseOpponentEffect) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect) UUID(java.util.UUID) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect)

Example 2 with MostCommonColorCondition

use of mage.abilities.condition.common.MostCommonColorCondition in project mage by magefree.

the class CallToArmsStateTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent permanent = game.getPermanent(getSourceId());
    UUID playerId = (UUID) game.getState().getValue(getSourceId() + ChooseOpponentEffect.VALUE_KEY);
    if (permanent != null) {
        Player opponent = game.getPlayer(playerId);
        if (opponent != null) {
            ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
            Condition condition = new MostCommonColorCondition(color, true, new ControllerIdPredicate(playerId));
            return !condition.apply(game, this);
        }
    }
    return false;
}
Also used : MostCommonColorCondition(mage.abilities.condition.common.MostCommonColorCondition) Condition(mage.abilities.condition.Condition) Player(mage.players.Player) MostCommonColorCondition(mage.abilities.condition.common.MostCommonColorCondition) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ObjectColor(mage.ObjectColor) UUID(java.util.UUID)

Example 3 with MostCommonColorCondition

use of mage.abilities.condition.common.MostCommonColorCondition in project mage by magefree.

the class TsabosAssasinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent != null) {
        Condition condition = new MostCommonColorCondition(permanent.getColor(game));
        if (condition.apply(game, source)) {
            Effect effect = new DestroyTargetEffect();
            effect.setTargetPointer(new FixedTarget(permanent, game));
            return effect.apply(game, source);
        }
    }
    return false;
}
Also used : MostCommonColorCondition(mage.abilities.condition.common.MostCommonColorCondition) Condition(mage.abilities.condition.Condition) FixedTarget(mage.target.targetpointer.FixedTarget) MostCommonColorCondition(mage.abilities.condition.common.MostCommonColorCondition) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect)

Example 4 with MostCommonColorCondition

use of mage.abilities.condition.common.MostCommonColorCondition in project mage by magefree.

the class BarrinsUnmakingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (permanent != null) {
        Condition condition = new MostCommonColorCondition(permanent.getColor(game));
        if (condition.apply(game, source)) {
            Effect effect = new ReturnToHandTargetEffect();
            effect.setTargetPointer(new FixedTarget(permanent, game));
            return effect.apply(game, source);
        }
    }
    return false;
}
Also used : MostCommonColorCondition(mage.abilities.condition.common.MostCommonColorCondition) Condition(mage.abilities.condition.Condition) FixedTarget(mage.target.targetpointer.FixedTarget) MostCommonColorCondition(mage.abilities.condition.common.MostCommonColorCondition) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect)

Aggregations

Condition (mage.abilities.condition.Condition)4 MostCommonColorCondition (mage.abilities.condition.common.MostCommonColorCondition)4 Permanent (mage.game.permanent.Permanent)4 Effect (mage.abilities.effects.Effect)3 UUID (java.util.UUID)2 ObjectColor (mage.ObjectColor)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)2 Player (mage.players.Player)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 ChooseColorEffect (mage.abilities.effects.common.ChooseColorEffect)1 ChooseOpponentEffect (mage.abilities.effects.common.ChooseOpponentEffect)1 DestroyTargetEffect (mage.abilities.effects.common.DestroyTargetEffect)1 ReturnToHandTargetEffect (mage.abilities.effects.common.ReturnToHandTargetEffect)1 SacrificeSourceEffect (mage.abilities.effects.common.SacrificeSourceEffect)1 BoostAllEffect (mage.abilities.effects.common.continuous.BoostAllEffect)1 TargetPermanent (mage.target.TargetPermanent)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1