use of mage.game.permanent.token.Token in project mage by magefree.
the class BaruFistOfKrosaEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int xValue = game.getBattlefield().countAll(filter, source.getControllerId(), game);
Token token = new BaruFistOfKrosaToken(xValue);
token.putOntoBattlefield(1, game, source, source.getControllerId());
return true;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class ChatterfangSquirrelGeneralReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
if (event instanceof CreateTokenEvent) {
CreateTokenEvent tokenEvent = (CreateTokenEvent) event;
SquirrelToken squirrelToken = null;
int amount = 0;
Map<Token, Integer> tokens = tokenEvent.getTokens();
for (Map.Entry<Token, Integer> entry : tokens.entrySet()) {
amount += entry.getValue();
if (entry.getKey() instanceof SquirrelToken) {
squirrelToken = (SquirrelToken) entry.getKey();
}
}
if (squirrelToken == null) {
squirrelToken = new SquirrelToken();
}
tokens.put(squirrelToken, tokens.getOrDefault(squirrelToken, 0) + amount);
}
return false;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class DinOfTheFireherdEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean applied;
Token token = new DinOfTheFireherdToken();
applied = token.putOntoBattlefield(1, game, source, source.getControllerId());
int blackCreaturesControllerControls = game.getBattlefield().countAll(blackCreatureFilter, source.getControllerId(), game);
int redCreaturesControllerControls = game.getBattlefield().countAll(redCreatureFilter, source.getControllerId(), game);
Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
if (targetOpponent != null) {
Effect effect = new SacrificeEffect(new FilterControlledCreaturePermanent(), blackCreaturesControllerControls, "Target Opponent");
effect.setTargetPointer(new FixedTarget(targetOpponent.getId()));
effect.apply(game, source);
Effect effect2 = new SacrificeEffect(new FilterControlledLandPermanent(), redCreaturesControllerControls, "Target Opponent");
effect2.setTargetPointer(new FixedTarget(targetOpponent.getId()));
effect2.apply(game, source);
applied = true;
}
return applied;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class FractalHarnessDoubleEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Token token = new FractalToken();
token.putOntoBattlefield(1, game, source, source.getControllerId());
int xValue = ManacostVariableValue.ETB.calculate(game, source, this);
boolean flag = true;
for (UUID tokenId : token.getLastAddedTokenIds()) {
Permanent permanent = game.getPermanent(tokenId);
if (permanent == null) {
continue;
}
if (flag && permanent.addAttachment(source.getSourceId(), source, game)) {
flag = false;
}
permanent.addCounters(CounterType.P1P1.createInstance(xValue), source.getControllerId(), source, game);
}
return true;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class LoyalApprenticeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Token token = new ThopterColorlessToken();
token.putOntoBattlefield(1, game, source, source.getControllerId());
game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList()), game)), source);
return true;
}
Aggregations