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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations