use of mage.watchers.common.PlayerGainedLifeWatcher in project mage by magefree.
the class TivashGloomSummonerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
PlayerGainedLifeWatcher watcher = game.getState().getWatcher(PlayerGainedLifeWatcher.class);
if (player == null || watcher == null) {
return false;
}
int lifeGained = watcher.getLifeGained(source.getControllerId());
Cost cost = new PayLifeCost(lifeGained);
if (!cost.canPay(source, source, source.getControllerId(), game) || !player.chooseUse(Outcome.PutCreatureInPlay, "Pay " + lifeGained + " life?", source, game) || !cost.pay(source, game, source, source.getControllerId(), true)) {
return false;
}
new DemonFlyingToken(lifeGained).putOntoBattlefield(1, game, source, source.getControllerId());
return true;
}
use of mage.watchers.common.PlayerGainedLifeWatcher in project mage by magefree.
the class OathswornVampirePlayEffect method applies.
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
PlayerGainedLifeWatcher watcher = game.getState().getWatcher(PlayerGainedLifeWatcher.class);
if (watcher == null || watcher.getLifeGained(source.getControllerId()) < 1 || !sourceId.equals(source.getSourceId()) || !source.isControlledBy(affectedControllerId)) {
return false;
}
Card card = game.getCard(source.getSourceId());
return card != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD;
}
use of mage.watchers.common.PlayerGainedLifeWatcher in project mage by magefree.
the class RegnaTheRedeemerCondition method getInputValue.
@Override
protected int getInputValue(Game game, Ability source) {
int gainedLife = 0;
PlayerGainedLifeWatcher watcher = game.getState().getWatcher(PlayerGainedLifeWatcher.class);
if (watcher != null) {
for (UUID playerId : game.getPlayerList()) {
Player player = game.getPlayer(playerId);
if (player != null && !player.hasOpponent(source.getControllerId(), game)) {
gainedLife = watcher.getLifeGained(playerId);
if (gainedLife > 0) {
break;
}
}
}
}
return gainedLife;
}
Aggregations