Search in sources :

Example 1 with Condition

use of mage.abilities.condition.Condition in project mage by magefree.

the class ChaosLordEffect method checkInterveningIfClause.

@Override
public boolean checkInterveningIfClause(Game game) {
    Condition condition = new ControlsPermanentsComparedToOpponentsCondition(ComparisonType.EQUAL_TO, new FilterPermanent());
    Player controller = game.getPlayer(controllerId);
    if (controller != null && condition.apply(game, this)) {
        return super.checkInterveningIfClause(game);
    }
    return false;
}
Also used : ControlsPermanentsComparedToOpponentsCondition(mage.abilities.condition.common.ControlsPermanentsComparedToOpponentsCondition) Condition(mage.abilities.condition.Condition) ControlsPermanentsComparedToOpponentsCondition(mage.abilities.condition.common.ControlsPermanentsComparedToOpponentsCondition) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent)

Example 2 with Condition

use of mage.abilities.condition.Condition 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 3 with Condition

use of mage.abilities.condition.Condition 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 4 with Condition

use of mage.abilities.condition.Condition in project mage by magefree.

the class SanctuaryInterveningIfTriggeredAbility method makeAndCondition.

private static Condition makeAndCondition(ObjectColor color1, ObjectColor color2) {
    FilterPermanent filter1 = new FilterPermanent();
    filter1.add(new ColorPredicate(color1));
    Condition condition1 = new PermanentsOnTheBattlefieldCondition(filter1);
    FilterPermanent filter2 = new FilterPermanent();
    filter2.add(new ColorPredicate(color2));
    Condition condition2 = new PermanentsOnTheBattlefieldCondition(filter2);
    return new CompoundCondition(condition1, condition2);
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) CompoundCondition(mage.abilities.condition.CompoundCondition) Condition(mage.abilities.condition.Condition) PermanentsOnTheBattlefieldCondition(mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition) InvertCondition(mage.abilities.condition.InvertCondition) FilterPermanent(mage.filter.FilterPermanent) PermanentsOnTheBattlefieldCondition(mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition) CompoundCondition(mage.abilities.condition.CompoundCondition)

Example 5 with Condition

use of mage.abilities.condition.Condition 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)

Aggregations

Condition (mage.abilities.condition.Condition)9 Permanent (mage.game.permanent.Permanent)5 MostCommonColorCondition (mage.abilities.condition.common.MostCommonColorCondition)4 Effect (mage.abilities.effects.Effect)4 OneShotEffect (mage.abilities.effects.OneShotEffect)4 Player (mage.players.Player)4 FixedTarget (mage.target.targetpointer.FixedTarget)4 UUID (java.util.UUID)2 ObjectColor (mage.ObjectColor)2 Ability (mage.abilities.Ability)2 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)2 ContinuousEffect (mage.abilities.effects.ContinuousEffect)2 FilterPermanent (mage.filter.FilterPermanent)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)2 ArrayList (java.util.ArrayList)1 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)1 AtTheEndOfCombatDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)1