forked from External/mage
* Void Winnower - Fixed that the check for even casting costs did not work correctly.
This commit is contained in:
parent
50b5602459
commit
d3000da3a3
11 changed files with 163 additions and 25 deletions
|
|
@ -31,6 +31,7 @@ import java.util.UUID;
|
|||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
|
|
@ -44,7 +45,6 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -109,16 +109,16 @@ class VoidWinnowerCantCastEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.CAST_SPELL;
|
||||
return event.getType() == EventType.CAST_SPELL_LATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
if (object != null && (object instanceof Spell)) {
|
||||
Ability ability = (Ability) getValue("targetAbility");
|
||||
if (ability != null && (ability instanceof SpellAbility)) {
|
||||
// the low bit will always be set on an odd number.
|
||||
return (((Spell) object).getConvertedManaCost() & 1) == 0;
|
||||
return (((SpellAbility) ability).getConvertedManaCost() & 1) == 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -247,6 +247,7 @@ public class EvolveTest extends CardTestPlayerBase {
|
|||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Adaptive Snapjaw");
|
||||
addTarget(playerA, "Adaptive Snapjaw");
|
||||
addTarget(playerA, "Adaptive Snapjaw");
|
||||
setChoice(playerA, "Whenever {this} evolves");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
|
@ -255,8 +256,8 @@ public class EvolveTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, "Ivy Lane Denizen", 2);
|
||||
assertPermanentCount(playerA, "Adaptive Snapjaw", 1);
|
||||
|
||||
assertPowerToughness(playerA, "Adaptive Snapjaw", 9, 5); // +2 from Ivys +1 from add to all with +1/+1 counter
|
||||
assertPowerToughness(playerA, "Renegade Krasis", 5, 4); // +1 Evolve by Ivy +1 Evolve by Snapjaw
|
||||
assertPowerToughness(playerA, "Adaptive Snapjaw", 9, 5); // +2 from Ivys and +1 from add to all with +1/+1 counter
|
||||
assertPowerToughness(playerA, "Renegade Krasis", 5, 4); // +1 Evolve by Ivy and +1 Evolve by Snapjaw
|
||||
assertPowerToughness(playerA, "Ivy Lane Denizen", 2, 3, Filter.ComparisonScope.Any);
|
||||
assertPowerToughness(playerA, "Ivy Lane Denizen", 5, 6, Filter.ComparisonScope.Any); // +1 from Other Ivy + 2 from Krasis
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* 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.rules;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CantCastTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* I control Void Winnower. But my opponent can cast Jayemdae Tome (that's
|
||||
* converted mana cost is even) He can cast other even spell.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testVoidWinnower() {
|
||||
// Your opponent can't cast spells with even converted mana costs. (Zero is even.)
|
||||
// Your opponents can't block with creatures with even converted mana costs.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Void Winnower");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
|
||||
|
||||
addCard(Zone.HAND, playerA, "Jayemdae Tome", 1);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Jayemdae Tome");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertHandCount(playerA, "Jayemdae Tome", 1);
|
||||
|
||||
assertPermanentCount(playerA, "Jayemdae Tome", 0);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVoidWinnower2() {
|
||||
// Your opponent can't cast spells with even converted mana costs. (Zero is even.)
|
||||
// Your opponents can't block with creatures with even converted mana costs.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Void Winnower");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
|
||||
|
||||
// Blaze deals X damage to target creature or player.
|
||||
addCard(Zone.HAND, playerA, "Blaze", 1);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Blaze", playerA);
|
||||
setChoice(playerA, "X=3");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertHandCount(playerA, "Blaze", 1);
|
||||
|
||||
assertLife(playerB, 20);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVoidWinnower3() {
|
||||
// Your opponent can't cast spells with even converted mana costs. (Zero is even.)
|
||||
// Your opponents can't block with creatures with even converted mana costs.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Void Winnower");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
|
||||
|
||||
// Blaze deals X damage to target creature or player.
|
||||
addCard(Zone.HAND, playerA, "Blaze", 1);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Blaze", playerB);
|
||||
setChoice(playerA, "X=4");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertHandCount(playerA, "Blaze", 0);
|
||||
assertGraveyardCount(playerA, "Blaze", 1);
|
||||
|
||||
assertLife(playerB, 16);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -317,7 +317,10 @@ public abstract class AbilityImpl implements Ability {
|
|||
// its mana cost; see rule 107.3), the player announces the value of that variable.
|
||||
VariableManaCost variableManaCost = handleManaXCosts(game, noMana, controller);
|
||||
String announceString = handleOtherXCosts(game, controller);
|
||||
|
||||
// For effects from cards like Void Winnower x costs have to be set
|
||||
if (game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL_LATE, getId(), getSourceId(), getControllerId()), this)) {
|
||||
return false;
|
||||
}
|
||||
for (Mode mode : this.getModes().getSelectedModes()) {
|
||||
this.getModes().setActiveMode(mode);
|
||||
//20121001 - 601.2c
|
||||
|
|
|
|||
|
|
@ -178,4 +178,23 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
return cardName;
|
||||
}
|
||||
|
||||
public int getConvertedManaCost() {
|
||||
int cmc = 0;
|
||||
int xMultiplier = 0;
|
||||
for (String symbolString : getManaCosts().getSymbols()) {
|
||||
int index = symbolString.indexOf("{X}");
|
||||
while (index != -1) {
|
||||
xMultiplier++;
|
||||
symbolString = symbolString.substring(index + 3);
|
||||
index = symbolString.indexOf("{X}");
|
||||
}
|
||||
}
|
||||
if (getSpellAbilityType().equals(SpellAbilityType.BASE_ALTERNATE)) {
|
||||
cmc += getManaCostsToPay().getX() * xMultiplier;
|
||||
} else {
|
||||
cmc += getManaCosts().convertedManaCost() + getManaCostsToPay().getX() * xMultiplier;
|
||||
}
|
||||
return cmc;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,6 +290,8 @@ public interface Game extends MageItem, Serializable {
|
|||
|
||||
boolean replaceEvent(GameEvent event);
|
||||
|
||||
boolean replaceEvent(GameEvent event, Ability targetAbility);
|
||||
|
||||
/**
|
||||
* Creates and fires an damage prevention event
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2291,6 +2291,11 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
return state.replaceEvent(event, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability targetAbility) {
|
||||
return state.replaceEvent(event, targetAbility, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreventionEffectData preventDamage(GameEvent event, Ability source, Game game, boolean preventAllDamage) {
|
||||
return preventDamage(event, source, game, Integer.MAX_VALUE);
|
||||
|
|
|
|||
|
|
@ -668,7 +668,11 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
}
|
||||
|
||||
public boolean replaceEvent(GameEvent event, Game game) {
|
||||
if (effects.preventedByRuleModification(event, null, game, false)) {
|
||||
return replaceEvent(event, null, game);
|
||||
}
|
||||
|
||||
public boolean replaceEvent(GameEvent event, Ability targetAbility, Game game) {
|
||||
if (effects.preventedByRuleModification(event, targetAbility, game, false)) {
|
||||
return true;
|
||||
}
|
||||
return effects.replaceEvent(event, game);
|
||||
|
|
|
|||
|
|
@ -109,6 +109,10 @@ public class GameEvent implements Serializable {
|
|||
LOSE_LIFE, LOST_LIFE,
|
||||
PLAY_LAND, LAND_PLAYED,
|
||||
CAST_SPELL,
|
||||
/* SPELL_CAST
|
||||
x-Costs are already defined
|
||||
*/
|
||||
CAST_SPELL_LATE,
|
||||
/* SPELL_CAST
|
||||
targetId id of the spell that's cast
|
||||
sourceId sourceId of the spell that's cast
|
||||
|
|
|
|||
|
|
@ -491,21 +491,8 @@ public class Spell extends StackObjImpl implements Card {
|
|||
if (faceDown) {
|
||||
return 0;
|
||||
}
|
||||
for (Ability spellAbility : spellAbilities) {
|
||||
int xMultiplier = 0;
|
||||
for (String symbolString : spellAbility.getManaCosts().getSymbols()) {
|
||||
int index = symbolString.indexOf("{X}");
|
||||
while (index != -1) {
|
||||
xMultiplier++;
|
||||
symbolString = symbolString.substring(index + 3);
|
||||
index = symbolString.indexOf("{X}");
|
||||
}
|
||||
}
|
||||
if (this.getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.BASE_ALTERNATE)) {
|
||||
cmc += spellAbility.getManaCostsToPay().getX() * xMultiplier;
|
||||
} else {
|
||||
cmc += spellAbility.getManaCosts().convertedManaCost() + spellAbility.getManaCostsToPay().getX() * xMultiplier;
|
||||
}
|
||||
for (SpellAbility spellAbility : spellAbilities) {
|
||||
cmc += spellAbility.getConvertedManaCost();
|
||||
}
|
||||
if (this.getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.BASE_ALTERNATE)) {
|
||||
cmc += getCard().getManaCost().convertedManaCost();
|
||||
|
|
|
|||
|
|
@ -945,7 +945,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
//20091005 - 601.2a
|
||||
Card card = game.getCard(ability.getSourceId());
|
||||
if (card != null) {
|
||||
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, ability.getId(), ability.getSourceId(), playerId))) {
|
||||
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, ability.getId(), ability.getSourceId(), playerId), ability)) {
|
||||
int bookmark = game.bookmarkState();
|
||||
Zone fromZone = game.getState().getZone(card.getMainCard().getId());
|
||||
card.cast(game, fromZone, ability, playerId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue