Search in sources :

Example 16 with Outcome

use of mage.constants.Outcome in project mage by magefree.

the class NeverwinterHydraEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanentEntering(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (permanent == null || player == null) {
        return true;
    }
    SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
    if (spellAbility == null || !spellAbility.getSourceId().equals(source.getSourceId()) || permanent.getZoneChangeCounter(game) != spellAbility.getSourceObjectZoneChangeCounter()) {
        return true;
    }
    if (!spellAbility.getSourceId().equals(source.getSourceId())) {
        return true;
    }
    // put into play by normal cast
    int xValue = spellAbility.getManaCostsToPay().getX();
    if (xValue < 1) {
        return false;
    }
    int amount = player.rollDice(outcome, source, game, 6, xValue, 0).stream().mapToInt(x -> x).sum();
    List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
    permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game, appliedEffects);
    return true;
}
Also used : EntersBattlefieldEffect(mage.abilities.effects.EntersBattlefieldEffect) AsEntersBattlefieldAbility(mage.abilities.common.AsEntersBattlefieldAbility) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) MageInt(mage.MageInt) SubType(mage.constants.SubType) Player(mage.players.Player) ArrayList(java.util.ArrayList) CardSetInfo(mage.cards.CardSetInfo) SpellAbility(mage.abilities.SpellAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Game(mage.game.Game) List(java.util.List) WardAbility(mage.abilities.keyword.WardAbility) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) CardType(mage.constants.CardType) TrampleAbility(mage.abilities.keyword.TrampleAbility) CounterType(mage.counters.CounterType) Ability(mage.abilities.Ability) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ArrayList(java.util.ArrayList) SpellAbility(mage.abilities.SpellAbility) UUID(java.util.UUID)

Example 17 with Outcome

use of mage.constants.Outcome in project mage by magefree.

the class PainsRewardEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        PlayerList playerList = game.getPlayerList().copy();
        playerList.setCurrent(controller.getId());
        Player winner = game.getPlayer(controller.getId());
        // -1 for start with 0 min big
        int highBid = chooseLifeAmountToBid(controller, -1, game);
        game.informPlayers(winner.getLogName() + " has bet " + highBid + " lifes");
        Player currentPlayer = playerList.getNextInRange(controller, game);
        while (currentPlayer != null && !Objects.equals(currentPlayer, winner)) {
            String text = winner.getLogName() + " has bet " + highBid + " life" + (highBid > 1 ? "s" : "") + ". Top the bid?";
            // AI hint
            int safeLifeToLost = Math.min(6, currentPlayer.getLife() / 2);
            Outcome aiOutcome = (highBid + 1 <= safeLifeToLost) ? Outcome.Benefit : Outcome.Detriment;
            if (currentPlayer.chooseUse(aiOutcome, text, source, game)) {
                int newBid = chooseLifeAmountToBid(currentPlayer, highBid, game);
                if (newBid > highBid) {
                    highBid = newBid;
                    winner = currentPlayer;
                    game.informPlayers(currentPlayer.getLogName() + " bet " + newBid + " life" + (newBid > 1 ? "s" : ""));
                }
            }
            currentPlayer = playerList.getNextInRange(controller, game);
        }
        game.informPlayers(winner.getLogName() + " won the auction with a bid of " + highBid + " life" + (highBid > 1 ? "s" : ""));
        winner.loseLife(highBid, game, source, false);
        winner.drawCards(4, source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) PlayerList(mage.players.PlayerList) Outcome(mage.constants.Outcome)

Example 18 with Outcome

use of mage.constants.Outcome in project mage by magefree.

the class ReignOfTerrorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    FilterPermanent filter = player.chooseUse(outcome, "Destroy all green creatures or all white creatures?", "", "Green", "White", source, game) ? greenFilter : whiteFilter;
    int died = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game).stream().mapToInt(permanent -> permanent.destroy(source, game, true) ? 1 : 0).sum();
    return player.loseLife(2 * died, game, source, false) > 0;
}
Also used : Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) FilterPermanent(mage.filter.FilterPermanent) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) ObjectColor(mage.ObjectColor) Ability(mage.abilities.Ability) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent)

Example 19 with Outcome

use of mage.constants.Outcome in project mage by magefree.

the class RevivalExperimentTarget method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    RevivalExperimentTarget target = new RevivalExperimentTarget();
    player.choose(outcome, target, source.getSourceId(), game);
    Cards cards = new CardsImpl(target.getTargets());
    player.moveCards(cards, Zone.BATTLEFIELD, source, game);
    int toBattlefield = cards.stream().map(game.getState()::getZone).filter(Zone.EXILED::equals).mapToInt(x -> 1).sum();
    player.loseLife(3 * toBattlefield, game, source, false);
    return true;
}
Also used : StaticFilters(mage.filter.StaticFilters) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Arrays(java.util.Arrays) Zone(mage.constants.Zone) mage.cards(mage.cards) Outcome(mage.constants.Outcome) Set(java.util.Set) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) Player(mage.players.Player) CardTypeAssignment(mage.abilities.dynamicvalue.common.CardTypeAssignment) ExileSpellEffect(mage.abilities.effects.common.ExileSpellEffect) Game(mage.game.Game) CardType(mage.constants.CardType) Ability(mage.abilities.Ability) Player(mage.players.Player)

Example 20 with Outcome

use of mage.constants.Outcome in project mage by magefree.

the class DanseMacabreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int toughness = 0;
    Cards cards = new CardsImpl();
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player == null || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 1) {
            continue;
        }
        TargetPermanent target = new TargetPermanent(filter);
        target.setNotTarget(true);
        player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent == null) {
            continue;
        }
        if (source.isControlledBy(playerId)) {
            toughness += permanent.getToughness().getValue();
        }
        cards.add(permanent);
        permanent.sacrifice(source, game);
    }
    int result = controller.rollDice(outcome, source, game, 20) + toughness;
    cards.retainZone(Zone.GRAVEYARD, game);
    if (cards.isEmpty()) {
        return true;
    }
    FilterCard filterCard = new FilterCard("card put into a graveyard this way");
    filterCard.add(Predicates.or(cards.stream().map(cardId -> new CardIdPredicate(cardId)).collect(Collectors.toSet())));
    TargetCardInGraveyard target;
    if (result >= 15) {
        target = new TargetCardInGraveyard(0, 2, filterCard);
    } else if (result > 0) {
        target = new TargetCardInGraveyard(filterCard);
    } else {
        return true;
    }
    target.setNotTarget(true);
    controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game);
    controller.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) FilterCard(mage.filter.FilterCard) Zone(mage.constants.Zone) Cards(mage.cards.Cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) Predicates(mage.filter.predicate.Predicates) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) FilterPermanent(mage.filter.FilterPermanent) Collectors(java.util.stream.Collectors) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) CardType(mage.constants.CardType) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) Ability(mage.abilities.Ability) TokenPredicate(mage.filter.predicate.permanent.TokenPredicate) Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Aggregations

Outcome (mage.constants.Outcome)20 Player (mage.players.Player)19 Ability (mage.abilities.Ability)16 OneShotEffect (mage.abilities.effects.OneShotEffect)16 CardType (mage.constants.CardType)14 Game (mage.game.Game)14 UUID (java.util.UUID)13 CardImpl (mage.cards.CardImpl)13 CardSetInfo (mage.cards.CardSetInfo)13 Permanent (mage.game.permanent.Permanent)12 FilterPermanent (mage.filter.FilterPermanent)6 Target (mage.target.Target)6 Collectors (java.util.stream.Collectors)5 MageInt (mage.MageInt)5 MageObject (mage.MageObject)5 SubType (mage.constants.SubType)5 SpellAbility (mage.abilities.SpellAbility)4 Zone (mage.constants.Zone)4 CounterType (mage.counters.CounterType)4 TargetPermanent (mage.target.TargetPermanent)4