forked from External/mage
Refactor: replaced sourceId by source and introduced source param in some methods;
This commit is contained in:
parent
2bb472607b
commit
db239a1055
3205 changed files with 7080 additions and 6795 deletions
|
|
@ -7,9 +7,11 @@ import mage.abilities.Abilities;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.mana.*;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.common.InfoEffect;
|
||||
import mage.abilities.effects.common.asthought.CanPlayCardControllerEffect;
|
||||
import mage.abilities.effects.common.asthought.YouMaySpendManaAsAnyColorToCastTargetEffect;
|
||||
import mage.abilities.hint.Hint;
|
||||
|
|
@ -23,6 +25,7 @@ import mage.filter.Filter;
|
|||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.CardState;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.permanent.PermanentMeld;
|
||||
|
|
@ -849,13 +852,14 @@ public final class CardUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Put card to battlefield without resolve
|
||||
* Put card to battlefield without resolve (for cheats and tests only)
|
||||
*
|
||||
* @param source must be non null (if you need it empty then use fakeSourceAbility)
|
||||
* @param game
|
||||
* @param card
|
||||
* @param player
|
||||
*/
|
||||
public static void putCardOntoBattlefieldWithEffects(Game game, Card card, Player player) {
|
||||
public static void putCardOntoBattlefieldWithEffects(Ability source, Game game, Card card, Player player) {
|
||||
// same logic as ZonesHandler->maybeRemoveFromSourceZone
|
||||
|
||||
// prepare card and permanent
|
||||
|
|
@ -870,8 +874,8 @@ public final class CardUtil {
|
|||
|
||||
// put onto battlefield with possible counters
|
||||
game.getPermanentsEntering().put(permanent.getId(), permanent);
|
||||
card.checkForCountersToAdd(permanent, game);
|
||||
permanent.entersBattlefield(permanent.getId(), game, Zone.OUTSIDE, false);
|
||||
card.checkForCountersToAdd(permanent, source, game);
|
||||
permanent.entersBattlefield(source, game, Zone.OUTSIDE, false);
|
||||
game.addPermanent(permanent, game.getState().getNextPermanentOrderNumber());
|
||||
game.getPermanentsEntering().remove(permanent.getId());
|
||||
|
||||
|
|
@ -1010,4 +1014,36 @@ public final class CardUtil {
|
|||
game.addEffect(new CanPlayCardControllerEffect(game, card.getId(), zcc, duration), source);
|
||||
game.addEffect(new YouMaySpendManaAsAnyColorToCastTargetEffect(duration).setTargetPointer(new FixedTarget(card.getId(), zcc)), source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pay life in effects
|
||||
* @param lifeToPay
|
||||
* @param player
|
||||
* @param source
|
||||
* @param game
|
||||
* @return true on good pay
|
||||
*/
|
||||
public static boolean tryPayLife(int lifeToPay, Player player, Ability source, Game game) {
|
||||
// rules:
|
||||
// 119.4. If a cost or effect allows a player to pay an amount of life greater than 0, the player may do so
|
||||
// only if their life total is greater than or equal to the amount of the payment. If a player pays life,
|
||||
// the payment is subtracted from their life total; in other words, the player loses that much life.
|
||||
// (Players can always pay 0 life.)
|
||||
if (lifeToPay == 0) {
|
||||
return true;
|
||||
} else if (lifeToPay < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lifeToPay > player.getLife()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.loseLife(lifeToPay, game, source, false) >= lifeToPay) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LIFE_PAID, player.getId(), source, player.getId(), lifeToPay));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue