use of mage.game.permanent.token.FractalToken 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.FractalToken in project mage by magefree.
the class EmergentSequenceWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
// put land
TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND_A);
player.searchLibrary(target, source, game);
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
Permanent permanent = null;
if (card != null) {
player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
permanent = game.getPermanent(target.getFirstTarget());
}
player.shuffleLibrary(source, game);
if (permanent == null) {
return true;
}
// boost land
game.addEffect(new BecomesCreatureTargetEffect(new FractalToken(), false, true, Duration.Custom).setTargetPointer(new FixedTarget(permanent, game)), source);
// rules
// The last sentence of Emergent Sequence’s ability counts the land it put onto the battlefield.
// (2021-04-16)
// no ETB yet, so add +1 manually
int amount = 1 + EmergentSequenceWatcher.getAmount(source.getControllerId(), game);
permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game);
return true;
}
use of mage.game.permanent.token.FractalToken in project mage by magefree.
the class OversimplifyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
List<Permanent> permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game);
Map<UUID, Integer> playerMap = permanents.stream().filter(Objects::nonNull).collect(Collectors.toMap(Controllable::getControllerId, p -> p.getPower().getValue(), Integer::sum));
controller.moveCards(new CardsImpl(permanents), Zone.EXILED, source, game);
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Token token = new FractalToken();
token.putOntoBattlefield(1, game, source, playerId);
int counter = playerMap.getOrDefault(playerId, 0);
for (UUID tokenId : token.getLastAddedTokenIds()) {
Permanent permanent = game.getPermanent(tokenId);
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(counter), playerId, source, game);
}
}
}
return true;
}
Aggregations