use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class RogueSkycaptainEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && permanent != null) {
new AddCountersSourceEffect(CounterType.WAGE.createInstance(), true).apply(game, source);
Cost cost = ManaUtil.createManaCost(2 * permanent.getCounters(game).getCount(CounterType.WAGE), false);
if (!cost.pay(source, game, source, controller.getId(), false)) {
new RemoveAllCountersSourceEffect(CounterType.WAGE).apply(game, source);
Player opponent;
Set<UUID> opponents = game.getOpponents(controller.getId());
if (opponents.size() == 1) {
opponent = game.getPlayer(opponents.iterator().next());
} else {
Target target = new TargetOpponent(true);
target.setNotTarget(true);
target.choose(Outcome.GainControl, source.getControllerId(), source.getSourceId(), game);
opponent = game.getPlayer(target.getFirstTarget());
}
if (opponent != null) {
permanent.changeControllerId(opponent.getId(), game, source);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class UlamogsDespoilerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetCardInExile(2, 2, filter, null);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
if (controller.chooseTarget(outcome, target, source, game)) {
Cards cardsToGraveyard = new CardsImpl(target.getTargets());
controller.moveCards(cardsToGraveyard, Zone.GRAVEYARD, source, game);
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(4)).apply(game, source);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class GemstoneCavernsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean result = false;
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = game.getCard(source.getSourceId());
if (card != null) {
ContinuousEffect effect = new EntersBattlefieldEffect(new AddCountersSourceEffect(CounterType.LUCK.createInstance()), "");
effect.setDuration(Duration.OneUse);
game.addEffect(effect, source);
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
Cost cost = new ExileFromHandCost(new TargetCardInHand());
if (cost.canPay(source, source, source.getControllerId(), game)) {
result = cost.pay(source, game, source, source.getControllerId(), true, null);
}
}
}
}
}
return result;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class MoritteOfTheFrostCopyApplier method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
blueprint.addSuperType(SuperType.LEGENDARY);
blueprint.addSuperType(SuperType.SNOW);
if (!isCopyOfCopy(source, blueprint, copyToObjectId) && blueprint.isCreature(game)) {
blueprint.getAbilities().add(new ChangelingAbility());
blueprint.getAbilities().add(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2), false)));
}
return true;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class PiousKitsuneEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean result;
result = new AddCountersSourceEffect(CounterType.DEVOTION.createInstance()).apply(game, source);
if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
int life = permanent.getCounters(game).getCount(CounterType.DEVOTION);
if (life > 0) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.gainLife(life, game, source);
}
}
}
}
return result;
}
Aggregations