mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00: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
|
@ -45,18 +45,18 @@ import mage.constants.CardType;
|
||||||
public class WretchedGryff extends CardImpl {
|
public class WretchedGryff extends CardImpl {
|
||||||
|
|
||||||
public WretchedGryff(UUID ownerId, CardSetInfo setInfo) {
|
public WretchedGryff(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{7}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{7}");
|
||||||
this.subtype.add("Eldrazi");
|
this.subtype.add("Eldrazi");
|
||||||
this.subtype.add("Hippogriff");
|
this.subtype.add("Hippogriff");
|
||||||
this.power = new MageInt(3);
|
this.power = new MageInt(3);
|
||||||
this.toughness = new MageInt(4);
|
this.toughness = new MageInt(4);
|
||||||
|
|
||||||
// Emerge {5}{U}
|
// Emerge {5}{U} (You may cast this spell by sacrificing a creature and paying the emerge cost reduced by that creature's converted mana cost.)
|
||||||
this.addAbility(new EmergeAbility(this, new ManaCostsImpl<>("{5}{U}")));
|
this.addAbility(new EmergeAbility(this, new ManaCostsImpl<>("{5}{U}")));
|
||||||
|
|
||||||
// When you cast Wretched Gryff, draw a card.
|
// When you cast Wretched Gryff, draw a card.
|
||||||
this.addAbility(new CastSourceTriggeredAbility(new DrawCardSourceControllerEffect(1)));
|
this.addAbility(new CastSourceTriggeredAbility(new DrawCardSourceControllerEffect(1)));
|
||||||
|
|
||||||
// Flying
|
// Flying
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* 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 org.mage.test.cards.abilities.keywords;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class EmergeTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wretched Gryff is bugged. I could not use its Emerge ability. Clicking on
|
||||||
|
* the card did not give me the interaction menu.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCastWithEmerge() {
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
|
||||||
|
// Emerge {5}{U} (You may cast this spell by sacrificing a creature and paying the emerge cost reduced by that creature's converted mana cost.)
|
||||||
|
// When you cast Wretched Gryff, draw a card.
|
||||||
|
// Flying
|
||||||
|
addCard(Zone.HAND, playerA, "Wretched Gryff"); // Creature
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wretched Gryff with emerge");
|
||||||
|
setChoice(playerA, "Silvercoat Lion");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertGraveyardCount(playerA, "Silvercoat Lion", 1);
|
||||||
|
assertPermanentCount(playerA, "Wretched Gryff", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -24,11 +24,11 @@
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities;
|
package mage.abilities;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.abilities.mana.ManaOptions;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,20 +38,30 @@ import mage.game.Game;
|
||||||
public interface ActivatedAbility extends Ability {
|
public interface ActivatedAbility extends Ability {
|
||||||
|
|
||||||
boolean canActivate(UUID playerId, Game game);
|
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.
|
* Creates a fresh copy of this activated ability.
|
||||||
*
|
*
|
||||||
* @return A new copy of this ability.
|
* @return A new copy of this ability.
|
||||||
*/
|
*/
|
||||||
@Override
|
@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.
|
* what's playbable for the player.
|
||||||
*/
|
*/
|
||||||
void setCheckPlayableMode();
|
void setCheckPlayableMode();
|
||||||
|
|
||||||
boolean isCheckPlayableMode();
|
boolean isCheckPlayableMode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import mage.abilities.costs.mana.ManaCosts;
|
||||||
import mage.abilities.costs.mana.PhyrexianManaCost;
|
import mage.abilities.costs.mana.PhyrexianManaCost;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.Effects;
|
import mage.abilities.effects.Effects;
|
||||||
|
import mage.abilities.mana.ManaOptions;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.constants.AbilityType;
|
import mage.constants.AbilityType;
|
||||||
import mage.constants.AsThoughEffectType;
|
import mage.constants.AsThoughEffectType;
|
||||||
|
@ -199,6 +200,11 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ManaOptions getMinimumCostToActivate(UUID playerId, Game game) {
|
||||||
|
return getManaCostsToPay().getOptions();
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean controlsAbility(UUID playerId, Game game) {
|
protected boolean controlsAbility(UUID playerId, Game game) {
|
||||||
if (this.controllerId != null && this.controllerId.equals(playerId)) {
|
if (this.controllerId != null && this.controllerId.equals(playerId)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -28,10 +28,12 @@
|
||||||
package mage.abilities.keyword;
|
package mage.abilities.keyword;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.Mana;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCosts;
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
|
import mage.abilities.mana.ManaOptions;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.SpellAbilityType;
|
import mage.constants.SpellAbilityType;
|
||||||
|
@ -84,6 +86,26 @@ public class EmergeAbility extends SpellAbility {
|
||||||
return false;
|
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
|
@Override
|
||||||
public boolean activate(Game game, boolean noMana) {
|
public boolean activate(Game game, boolean noMana) {
|
||||||
Player controller = game.getPlayer(this.getControllerId());
|
Player controller = game.getPlayer(this.getControllerId());
|
||||||
|
|
|
@ -2489,7 +2489,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
canBeCastRegularly = false;
|
canBeCastRegularly = false;
|
||||||
}
|
}
|
||||||
if (canBeCastRegularly) {
|
if (canBeCastRegularly) {
|
||||||
ManaOptions abilityOptions = copy.getManaCostsToPay().getOptions();
|
ManaOptions abilityOptions = copy.getMinimumCostToActivate(playerId, game);
|
||||||
if (abilityOptions.isEmpty()) {
|
if (abilityOptions.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue