use of mage.abilities.dynamicvalue.common.CountersSourceCount in project mage by magefree.
the class ChargingCinderhornDamageTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent chargingCinderhoof = game.getPermanent(source.getSourceId());
if (chargingCinderhoof != null) {
chargingCinderhoof.addCounters(CounterType.FURY.createInstance(), source.getControllerId(), source, game);
} else {
chargingCinderhoof = game.getPermanentOrLKIBattlefield(source.getSourceId());
}
if (chargingCinderhoof == null) {
return false;
}
DynamicValue amount = new CountersSourceCount(CounterType.FURY);
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
player.damage(amount.calculate(game, source, this), source.getSourceId(), source, game);
return true;
}
return false;
}
use of mage.abilities.dynamicvalue.common.CountersSourceCount in project mage by magefree.
the class NissaStewardOfElementsToken method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int count = 1 + new CountersSourceCount(CounterType.LOYALTY).calculate(game, source, this);
FilterPermanentCard filter = new FilterPermanentCard();
filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.LAND.getPredicate()));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, count));
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
controller.lookAtCards(source, null, new CardsImpl(card), game);
if (filter.match(card, game)) {
if (controller.chooseUse(outcome, "Put " + card.getName() + " onto the battlefield?", source, game)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
return true;
}
use of mage.abilities.dynamicvalue.common.CountersSourceCount in project mage by magefree.
the class PhantasmalSphereToken method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetOpponent = game.getPlayer(source.getFirstTarget());
if (controller != null && targetOpponent != null) {
Effect effect = new CreateTokenTargetEffect(new PhantasmalSphereToken(new CountersSourceCount(CounterType.P1P1).calculate(game, source, null)));
effect.setTargetPointer(new FixedTarget(targetOpponent.getId()));
effect.apply(game, source);
}
return false;
}
use of mage.abilities.dynamicvalue.common.CountersSourceCount in project mage by magefree.
the class RiptideReplicatorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
if (subType == null) {
return false;
}
int x = (new CountersSourceCount(CounterType.CHARGE)).calculate(game, source, this);
Token token = new RiptideReplicatorToken(color, subType, x);
return token.putOntoBattlefield(1, game, source, source.getControllerId());
}
use of mage.abilities.dynamicvalue.common.CountersSourceCount in project mage by magefree.
the class UnboostCreaturesDefendingPlayerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
Permanent permanent = it.next().getPermanent(game);
if (permanent != null) {
int unboostCount = -1 * new CountersSourceCount(CounterType.P1P1).calculate(game, source, this);
permanent.addPower(unboostCount);
permanent.addToughness(unboostCount);
} else {
it.remove();
}
}
return true;
}
Aggregations