Search in sources :

Example 1 with GoblinToken

use of mage.game.permanent.token.GoblinToken in project mage by magefree.

the class BoxOfFreerangeGoblinsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int amount = controller.rollDice(outcome, source, game, 6);
        CreateTokenEffect effect = new CreateTokenEffect(new GoblinToken(), amount);
        effect.apply(game, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) GoblinToken(mage.game.permanent.token.GoblinToken)

Example 2 with GoblinToken

use of mage.game.permanent.token.GoblinToken in project mage by magefree.

the class LegionWarbossAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    CreateTokenEffect effect = new CreateTokenEffect(new GoblinToken());
    effect.apply(game, source);
    effect.getLastAddedTokenIds().stream().map((tokenId) -> {
        ContinuousEffect continuousEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
        continuousEffect.setTargetPointer(new FixedTarget(tokenId, game));
        return continuousEffect;
    }).forEachOrdered((continuousEffect) -> {
        game.addEffect(continuousEffect, source);
    });
    effect.getLastAddedTokenIds().stream().map((tokenId) -> {
        ContinuousEffect continuousEffect = new GainAbilityTargetEffect(new LegionWarbossAbility(), Duration.EndOfCombat);
        continuousEffect.setTargetPointer(new FixedTarget(tokenId, game));
        return continuousEffect;
    }).forEachOrdered((continuousEffect) -> {
        game.addEffect(continuousEffect, source);
    });
    return true;
}
Also used : BeginningOfCombatTriggeredAbility(mage.abilities.common.BeginningOfCombatTriggeredAbility) Zone(mage.constants.Zone) MentorAbility(mage.abilities.keyword.MentorAbility) HasteAbility(mage.abilities.keyword.HasteAbility) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) GoblinToken(mage.game.permanent.token.GoblinToken) MageInt(mage.MageInt) StaticAbility(mage.abilities.StaticAbility) SubType(mage.constants.SubType) TargetController(mage.constants.TargetController) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FixedTarget(mage.target.targetpointer.FixedTarget) CardSetInfo(mage.cards.CardSetInfo) Duration(mage.constants.Duration) Game(mage.game.Game) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) Ability(mage.abilities.Ability) AttacksIfAbleSourceEffect(mage.abilities.effects.common.combat.AttacksIfAbleSourceEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) FixedTarget(mage.target.targetpointer.FixedTarget) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) GoblinToken(mage.game.permanent.token.GoblinToken)

Example 3 with GoblinToken

use of mage.game.permanent.token.GoblinToken in project mage by magefree.

the class MoggInfestationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Cards creaturesDied = new CardsImpl();
    if (controller != null && getTargetPointer().getFirst(game, source) != null) {
        for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, getTargetPointer().getFirst(game, source), game)) {
            if (permanent.destroy(source, game, false)) {
                if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) {
                    // If a commander is replaced to command zone, the creature does not die
                    creaturesDied.add(permanent);
                }
            }
        }
        // Bug #8548
        game.getState().processAction(game);
        if (creaturesDied.isEmpty()) {
            return true;
        }
        for (Card c : creaturesDied.getCards(game)) {
            if (game.getState().getZone(c.getId()) == Zone.GRAVEYARD) {
                Effect effect = new CreateTokenTargetEffect(new GoblinToken(), 2);
                effect.setTargetPointer(getTargetPointer());
                effect.apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) GoblinToken(mage.game.permanent.token.GoblinToken) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 4 with GoblinToken

use of mage.game.permanent.token.GoblinToken in project mage by magefree.

the class GarbageElementalCEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        List<Integer> results = controller.rollDice(outcome, source, game, 6, 2, 0);
        int thisRoll = results.get(0);
        int thatRoll = results.get(1);
        Token token = new GoblinToken();
        return token.putOntoBattlefield(Math.abs(thatRoll - thisRoll), game, source, source.getControllerId());
    }
    return false;
}
Also used : Player(mage.players.Player) GoblinToken(mage.game.permanent.token.GoblinToken) Token(mage.game.permanent.token.Token) GoblinToken(mage.game.permanent.token.GoblinToken)

Example 5 with GoblinToken

use of mage.game.permanent.token.GoblinToken in project mage by magefree.

the class KrenkoTinStreetKingpinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (permanent == null) {
        return false;
    }
    new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
    game.getState().processAction(game);
    int xValue = permanent.getPower().getValue();
    return new CreateTokenEffect(new GoblinToken(), xValue).apply(game, source);
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) GoblinToken(mage.game.permanent.token.GoblinToken)

Aggregations

GoblinToken (mage.game.permanent.token.GoblinToken)6 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)3 Player (mage.players.Player)3 OneShotEffect (mage.abilities.effects.OneShotEffect)2 Permanent (mage.game.permanent.Permanent)2 Token (mage.game.permanent.token.Token)2 UUID (java.util.UUID)1 MageInt (mage.MageInt)1 Ability (mage.abilities.Ability)1 StaticAbility (mage.abilities.StaticAbility)1 BeginningOfCombatTriggeredAbility (mage.abilities.common.BeginningOfCombatTriggeredAbility)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 Effect (mage.abilities.effects.Effect)1 CreateTokenTargetEffect (mage.abilities.effects.common.CreateTokenTargetEffect)1 AttacksIfAbleSourceEffect (mage.abilities.effects.common.combat.AttacksIfAbleSourceEffect)1 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)1 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)1 HasteAbility (mage.abilities.keyword.HasteAbility)1 MentorAbility (mage.abilities.keyword.MentorAbility)1 Card (mage.cards.Card)1