mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* Fixed a problem with emerge, that the spell could not be cast with emerge, if the player had less mana available as the full emerge mana costs.
This commit is contained in:
parent
203056df0a
commit
c2ae4c6527
6 changed files with 116 additions and 12 deletions
|
|
@ -24,11 +24,11 @@
|
|||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
*/
|
||||
package mage.abilities;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
|
|
@ -38,20 +38,30 @@ import mage.game.Game;
|
|||
public interface ActivatedAbility extends Ability {
|
||||
|
||||
boolean canActivate(UUID playerId, Game game);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the minimal possible cost for what the ability can be activated
|
||||
* or cast
|
||||
*
|
||||
* @param playerId
|
||||
* @param game
|
||||
* @return
|
||||
*/
|
||||
ManaOptions getMinimumCostToActivate(UUID playerId, Game game);
|
||||
|
||||
/**
|
||||
* Creates a fresh copy of this activated ability.
|
||||
*
|
||||
*
|
||||
* @return A new copy of this ability.
|
||||
*/
|
||||
@Override
|
||||
ActivatedAbility copy();
|
||||
|
||||
ActivatedAbility copy();
|
||||
|
||||
/**
|
||||
* Set a flag to know, that the ability is only created adn used to check
|
||||
* Set a flag to know, that the ability is only created adn used to check
|
||||
* what's playbable for the player.
|
||||
*/
|
||||
void setCheckPlayableMode();
|
||||
|
||||
|
||||
boolean isCheckPlayableMode();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import mage.abilities.costs.mana.ManaCosts;
|
|||
import mage.abilities.costs.mana.PhyrexianManaCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
|
|
@ -199,6 +200,11 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaOptions getMinimumCostToActivate(UUID playerId, Game game) {
|
||||
return getManaCostsToPay().getOptions();
|
||||
}
|
||||
|
||||
protected boolean controlsAbility(UUID playerId, Game game) {
|
||||
if (this.controllerId != null && this.controllerId.equals(playerId)) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -28,10 +28,12 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SpellAbilityType;
|
||||
|
|
@ -84,6 +86,26 @@ public class EmergeAbility extends SpellAbility {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaOptions getMinimumCostToActivate(UUID playerId, Game game) {
|
||||
int maxCMC = 0;
|
||||
for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), playerId, this.getSourceId(), game)) {
|
||||
int cmc = creature.getConvertedManaCost();
|
||||
if (cmc > maxCMC) {
|
||||
maxCMC = cmc;
|
||||
}
|
||||
}
|
||||
ManaOptions manaOptions = super.getMinimumCostToActivate(playerId, game);
|
||||
for (Mana mana : manaOptions) {
|
||||
if (mana.getGeneric() > maxCMC) {
|
||||
mana.setGeneric(mana.getGeneric() - maxCMC);
|
||||
} else {
|
||||
mana.setGeneric(0);
|
||||
}
|
||||
}
|
||||
return manaOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(Game game, boolean noMana) {
|
||||
Player controller = game.getPlayer(this.getControllerId());
|
||||
|
|
|
|||
|
|
@ -2489,7 +2489,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
canBeCastRegularly = false;
|
||||
}
|
||||
if (canBeCastRegularly) {
|
||||
ManaOptions abilityOptions = copy.getManaCostsToPay().getOptions();
|
||||
ManaOptions abilityOptions = copy.getMinimumCostToActivate(playerId, game);
|
||||
if (abilityOptions.isEmpty()) {
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue