Merge remote-tracking branch 'origin/master'

This commit is contained in:
Oleg Agafonov 2019-01-03 21:23:58 +04:00
commit 0bd9bd6015
10 changed files with 99 additions and 73 deletions

View file

@ -18,6 +18,7 @@ import mage.constants.TargetController;
import mage.constants.TimingRule;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.command.Commander;
import mage.game.command.Emblem;
import mage.game.command.Plane;
import mage.game.permanent.Permanent;
@ -235,6 +236,8 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
return ((Emblem) mageObject).isControlledBy(playerId);
} else if (mageObject instanceof Plane) {
return ((Plane) mageObject).isControlledBy(playerId);
} else if (mageObject instanceof Commander) {
return ((Commander) mageObject).isControlledBy(playerId);
} else if (game.getState().getZone(this.sourceId) != Zone.BATTLEFIELD) {
return ((Card) mageObject).isOwnedBy(playerId);
}

View file

@ -1,16 +1,13 @@
package mage.abilities.costs.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.game.Game;
import java.util.UUID;
import mage.abilities.costs.Cost;
/**
*
* @author BetaSteward_at_googlemail.com
@ -36,11 +33,12 @@ public class PayLifeCost extends CostImpl {
@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
//118.4. If a cost or effect allows a player to pay an amount of life greater than 0,
//118.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 his or
//amount of the payment. If a player pays life, the payment is subtracted from his or
//her life total; in other words, the player loses that much life. (Players can always pay 0 life.)
int lifeToPayAmount = amount.calculate(game, ability, null);
// Paying 0 life is not considered paying any life.
if (lifeToPayAmount > 0 && !game.getPlayer(controllerId).canPayLifeCost()) {
return false;
}

View file

@ -1,5 +1,3 @@
package mage.abilities.costs.common;
import mage.abilities.Ability;
@ -12,7 +10,6 @@ import mage.players.Player;
*
* @author LevelX2
*/
public class PayVariableLifeCost extends VariableCostImpl {
public PayVariableLifeCost() {
@ -21,7 +18,7 @@ public class PayVariableLifeCost extends VariableCostImpl {
public PayVariableLifeCost(boolean additionalCostText) {
super("life to pay");
this.text = new StringBuilder(additionalCostText ? "as an additional cost to cast this spell, pay ":"Pay ")
this.text = new StringBuilder(additionalCostText ? "as an additional cost to cast this spell, pay " : "Pay ")
.append(xText).append(' ').append("life").toString();
}
@ -44,7 +41,10 @@ public class PayVariableLifeCost extends VariableCostImpl {
int maxValue = 0;
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
maxValue = controller.getLife();
// Paying 0 life is not considered paying any life, so paying 0 is still allowed
if (game.getPlayer(source.getControllerId()).canPayLifeCost()) {
maxValue = controller.getLife();
}
}
return maxValue;
}

View file

@ -1,5 +1,6 @@
package mage.abilities.dynamicvalue.common;
import mage.ConditionalMana;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
@ -29,6 +30,9 @@ public class ManaTypeInManaPoolCount implements DynamicValue {
Player player = game.getPlayer(sourceAbility.getControllerId());
if (player != null) {
amount = player.getManaPool().get(manaType);
for (ConditionalMana mana : player.getManaPool().getConditionalMana()) {
amount += mana.get(manaType);
}
}
return amount;
}