use of mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect in project mage by magefree.
the class MinionOfTheWastesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller == null || permanent == null) {
return false;
}
int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game);
Cost cost = new PayLifeCost(payAmount);
if (!cost.pay(source, game, source, source.getControllerId(), true)) {
return false;
}
Card sourceCard = game.getCard(source.getSourceId());
game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() + " pays " + payAmount + " life");
game.addEffect(new SetPowerToughnessSourceEffect(payAmount, payAmount, Duration.Custom, SubLayer.CharacteristicDefining_7a), source);
permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game);
return true;
}
use of mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect in project mage by magefree.
the class ElvishImpersonatorsEffect 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 firstRoll = results.get(0);
int secondRoll = results.get(1);
game.addEffect(new SetPowerToughnessSourceEffect(firstRoll, secondRoll, Duration.WhileOnBattlefield, SubLayer.SetPT_7b), source);
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect in project mage by magefree.
the class EvraHalcyonWitnessEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.isLifeTotalCanChange()) {
Permanent perm = game.getPermanent(source.getSourceId());
if (perm != null) {
int amount = perm.getPower().getValue();
int life = player.getLife();
if (life == amount) {
return false;
}
if (life < amount && !player.isCanGainLife()) {
return false;
}
if (life > amount && !player.isCanLoseLife()) {
return false;
}
player.setLife(amount, game, source);
game.addEffect(new SetPowerToughnessSourceEffect(life, Integer.MIN_VALUE, Duration.Custom, SubLayer.SetPT_7b), source);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect in project mage by magefree.
the class TrenchGorgerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, new FilterLandCard("any number of land cards"));
target.choose(outcome, controller.getId(), controller.getId(), game);
int count = 0;
for (UUID cardId : target.getTargets()) {
Card card = game.getCard(cardId);
if (card != null) {
controller.moveCardToExileWithInfo(card, null, "", source, game, Zone.LIBRARY, true);
count++;
}
}
controller.shuffleLibrary(source, game);
game.addEffect(new SetPowerToughnessSourceEffect(count, count, Duration.EndOfGame, SubLayer.SetPT_7b), source);
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect in project mage by magefree.
the class LevelerCardBuilder method build.
/**
* Main method constructing ability.
*
* @return
*/
public List<Ability> build() {
List<Ability> constructed = new ArrayList<>();
Condition condition = new SourceHasCounterCondition(CounterType.LEVEL, level1, level2);
for (Ability ability : abilities) {
ContinuousEffect effect = new GainAbilitySourceEffect(ability);
ConditionalContinuousEffect abEffect = new ConditionalContinuousEffect(effect, condition, "");
Ability staticAbility = new SimpleStaticAbility(Zone.BATTLEFIELD, abEffect);
staticAbility.setRuleVisible(false);
constructed.add(staticAbility);
}
ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.WhileOnBattlefield, SubLayer.SetPT_7b);
ConditionalContinuousEffect ptEffect = new ConditionalContinuousEffect(effect, condition, rule);
constructed.add(new SimpleStaticAbility(Zone.BATTLEFIELD, ptEffect));
return constructed;
}
Aggregations