mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Merge origin/master
This commit is contained in:
commit
4785ebd5f8
16 changed files with 420 additions and 138 deletions
|
@ -34,6 +34,7 @@ import mage.ConditionalMana;
|
|||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
|
@ -80,8 +81,9 @@ public class CavernOfSouls extends CardImpl {
|
|||
this.addAbility(new ColorlessManaAbility());
|
||||
|
||||
// {T}: Add one mana of any color to your mana pool. Spend this mana only to cast a creature spell of the chosen type, and that spell can't be countered.
|
||||
this.addAbility(new ConditionalAnyColorManaAbility(new TapSourceCost(), 1, new CavernOfSoulsManaBuilder(), true), new CavernOfSoulsWatcher());
|
||||
this.addAbility(new SimpleStaticAbility(Zone.ALL, new CavernOfSoulsCantCounterEffect()));
|
||||
Ability ability = new ConditionalAnyColorManaAbility(new TapSourceCost(), 1, new CavernOfSoulsManaBuilder(), true);
|
||||
this.addAbility(ability, new CavernOfSoulsWatcher(ability.getOriginalId()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.ALL, new CavernOfSoulsCantCounterEffect()));
|
||||
}
|
||||
|
||||
public CavernOfSouls(final CavernOfSouls card) {
|
||||
|
@ -146,14 +148,12 @@ class CavernOfSoulsManaBuilder extends ConditionalManaBuilder {
|
|||
if (controller != null && sourceObject != null) {
|
||||
game.informPlayers(controller.getName() + " produces " + mana.toString() + " with " + sourceObject.getLogName() +
|
||||
" (can only be spend to cast for creatures of type " + creatureType + " and that spell can't be countered)");
|
||||
}
|
||||
|
||||
}
|
||||
return super.setMana(mana, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConditionalMana build(Object... options) {
|
||||
this.mana.setFlag(true); // indicates that the mana is from second ability
|
||||
return new CavernOfSoulsConditionalMana(this.mana, creatureType);
|
||||
}
|
||||
|
||||
|
@ -196,15 +196,18 @@ class CavernOfSoulsManaCondition extends CreatureCastManaCondition {
|
|||
|
||||
class CavernOfSoulsWatcher extends Watcher {
|
||||
|
||||
public List<UUID> spells = new ArrayList<>();
|
||||
|
||||
public CavernOfSoulsWatcher() {
|
||||
super("ManaPaidFromCavernOfSoulsWatcher", WatcherScope.GAME);
|
||||
private List<UUID> spells = new ArrayList<>();
|
||||
private final String originalId;
|
||||
|
||||
public CavernOfSoulsWatcher(UUID originalId) {
|
||||
super("ManaPaidFromCavernOfSoulsWatcher", WatcherScope.CARD);
|
||||
this.originalId = originalId.toString();
|
||||
}
|
||||
|
||||
public CavernOfSoulsWatcher(final CavernOfSoulsWatcher watcher) {
|
||||
super(watcher);
|
||||
this.spells.addAll(watcher.spells);
|
||||
this.originalId = watcher.originalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -215,13 +218,15 @@ class CavernOfSoulsWatcher extends Watcher {
|
|||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.MANA_PAYED) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
// TODO: Replace identification by name by better method that also works if ability is copied from other land with other name
|
||||
if (object != null && object.getName().equals("Cavern of Souls") && event.getFlag()) {
|
||||
if (event.getData() != null && event.getData().equals(originalId)) {
|
||||
spells.add(event.getTargetId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean spellCantBeCountered(UUID spellId) {
|
||||
return spells.contains(spellId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
@ -267,8 +272,8 @@ class CavernOfSoulsCantCounterEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
CavernOfSoulsWatcher watcher = (CavernOfSoulsWatcher) game.getState().getWatchers().get("ManaPaidFromCavernOfSoulsWatcher");
|
||||
CavernOfSoulsWatcher watcher = (CavernOfSoulsWatcher) game.getState().getWatchers().get("ManaPaidFromCavernOfSoulsWatcher", source.getSourceId());
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
return spell != null && watcher.spells.contains(spell.getId());
|
||||
return spell != null && watcher != null && watcher.spellCantBeCountered(spell.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
*/
|
||||
package mage.sets.betrayersofkamigawa;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -38,13 +36,10 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.common.PlayerCastCreatureWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -110,41 +105,3 @@ class GoblinCohortEffect extends RestrictionEffect {
|
|||
}
|
||||
}
|
||||
|
||||
class PlayerCastCreatureWatcher extends Watcher {
|
||||
|
||||
Set<UUID> playerIds = new HashSet<>();
|
||||
|
||||
public PlayerCastCreatureWatcher() {
|
||||
super("PlayerCastCreature", WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayerCastCreatureWatcher(final PlayerCastCreatureWatcher watcher) {
|
||||
super(watcher);
|
||||
this.playerIds.addAll(watcher.playerIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||
if (spell.getCardType().contains(CardType.CREATURE)) {
|
||||
playerIds.add(spell.getControllerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerCastCreatureWatcher copy() {
|
||||
return new PlayerCastCreatureWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
playerIds.clear();
|
||||
}
|
||||
|
||||
public boolean playerDidCastCreatureThisTurn(UUID playerId) {
|
||||
return playerIds.contains(playerId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,11 +52,6 @@ public class Progenitus extends CardImpl {
|
|||
this.subtype.add("Hydra");
|
||||
this.subtype.add("Avatar");
|
||||
|
||||
this.color.setRed(true);
|
||||
this.color.setBlue(true);
|
||||
this.color.setGreen(true);
|
||||
this.color.setBlack(true);
|
||||
this.color.setWhite(true);
|
||||
this.power = new MageInt(10);
|
||||
this.toughness = new MageInt(10);
|
||||
|
||||
|
|
|
@ -106,17 +106,23 @@ class GrindstoneEffect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
colorShared = false;
|
||||
Card card1 = targetPlayer.getLibrary().removeFromTop(game);
|
||||
if (card1 != null) {
|
||||
targetPlayer.moveCardToGraveyardWithInfo(card1, source.getSourceId(), game, Zone.LIBRARY);
|
||||
Card card2 = targetPlayer.getLibrary().removeFromTop(game);
|
||||
if (card2 != null) {
|
||||
targetPlayer.moveCardToGraveyardWithInfo(card2, source.getSourceId(), game, Zone.LIBRARY);
|
||||
Card card1 = null;
|
||||
Card card2 = null;
|
||||
if (targetPlayer.getLibrary().size() > 0) {
|
||||
card1 = targetPlayer.getLibrary().removeFromTop(game);
|
||||
if (targetPlayer.getLibrary().size() > 0) {
|
||||
card2 = targetPlayer.getLibrary().removeFromTop(game);
|
||||
if (card1.getColor().hasColor() && card2.getColor().hasColor()) {
|
||||
colorShared = card1.getColor().shares(card2.getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (card1 != null) {
|
||||
targetPlayer.moveCardToGraveyardWithInfo(card1, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
if (card2 != null) {
|
||||
targetPlayer.moveCardToGraveyardWithInfo(card2, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
} while (colorShared && targetPlayer.isInGame());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
*/
|
||||
package mage.sets.tempest;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -38,13 +36,10 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.common.PlayerCastCreatureWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -107,42 +102,3 @@ class MoggConscriptsEffect extends RestrictionEffect {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class PlayerCastCreatureWatcher extends Watcher {
|
||||
|
||||
Set<UUID> playerIds = new HashSet<>();
|
||||
|
||||
public PlayerCastCreatureWatcher() {
|
||||
super("PlayerCastCreature", WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayerCastCreatureWatcher(final PlayerCastCreatureWatcher watcher) {
|
||||
super(watcher);
|
||||
this.playerIds.addAll(watcher.playerIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||
if (spell.getCardType().contains(CardType.CREATURE)) {
|
||||
playerIds.add(spell.getControllerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerCastCreatureWatcher copy() {
|
||||
return new PlayerCastCreatureWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
playerIds.clear();
|
||||
}
|
||||
|
||||
public boolean playerDidCastCreatureThisTurn(UUID playerId) {
|
||||
return playerIds.contains(playerId);
|
||||
}
|
||||
}
|
|
@ -35,6 +35,8 @@ import mage.abilities.common.SimpleStaticAbility;
|
|||
import mage.abilities.condition.common.CardsInControllerGraveCondition;
|
||||
import mage.abilities.costs.common.DiscardCardCost;
|
||||
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||
import mage.abilities.decorator.ConditionalRestrictionEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.combat.CantBlockSourceEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
|
||||
|
@ -57,7 +59,6 @@ public class PutridImp extends CardImpl {
|
|||
this.subtype.add("Zombie");
|
||||
this.subtype.add("Imp");
|
||||
|
||||
this.color.setBlack(true);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
|
@ -68,8 +69,9 @@ public class PutridImp extends CardImpl {
|
|||
new BoostSourceEffect(1, 1, Duration.WhileOnBattlefield),
|
||||
new CardsInControllerGraveCondition(7),
|
||||
"<i>Threshold</i> - As long as seven or more cards are in your graveyard, {this} gets +1/+1"));
|
||||
ability.addEffect(new ConditionalContinuousEffect(new CantBlockSourceEffect(Duration.WhileOnBattlefield), new CardsInControllerGraveCondition(7),
|
||||
"and can't block"));
|
||||
Effect effect = new ConditionalRestrictionEffect(new CantBlockSourceEffect(Duration.WhileOnBattlefield), new CardsInControllerGraveCondition(7));
|
||||
effect.setText("and can't block");
|
||||
ability.addEffect(effect);
|
||||
this.addAbility(ability);
|
||||
|
||||
}
|
||||
|
|
|
@ -287,4 +287,42 @@ public class ManifestTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerB, "face down creature", 1);
|
||||
|
||||
}
|
||||
|
||||
// Check if a Megamorph card is manifested and truned by their megamorph ability
|
||||
// it gets the +1/+1 counter.
|
||||
|
||||
@Test
|
||||
public void testManifestMegamorph() {
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Plains", 5);
|
||||
// {1}{B}, {T}, Sacrifice another creature: Manifest the top card of your library.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Qarsi High Priest", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
|
||||
|
||||
addCard(Zone.LIBRARY, playerB, "Sandstorm Charger", 1);
|
||||
addCard(Zone.LIBRARY, playerB, "Mountain", 1);
|
||||
|
||||
skipInitShuffling();
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "{1}{B},{T}, Sacrifice another creature");
|
||||
addTarget(playerB, "Silvercoat Lion");
|
||||
|
||||
activateAbility(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "{4}{W}: Turn");
|
||||
|
||||
setStopAt(2, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
// no life gain
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
|
||||
|
||||
assertPermanentCount(playerB, "face down creature", 0);
|
||||
assertPermanentCount(playerB, "Sandstorm Charger", 1);
|
||||
assertPowerToughness(playerB, "Sandstorm Charger", 4, 5); // 3/4 and the +1/+1 counter from Megamorph
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -476,6 +476,10 @@ public class MorphTest extends CardTestPlayerBase {
|
|||
|
||||
@Test
|
||||
public void testDiesTriggeredDoesNotTriggerIfFaceDown() {
|
||||
// Flying
|
||||
// When Ashcloud Phoenix dies, return it to the battlefield face down.
|
||||
// Morph (You may cast this card face down as a 2/2 creature for . Turn it face up any time for its morph cost.)
|
||||
// When Ashcloud Phoenix is turned face up, it deals 2 damage to each player.
|
||||
addCard(Zone.HAND, playerA, "Ashcloud Phoenix", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
|
||||
|
||||
|
@ -505,5 +509,47 @@ public class MorphTest extends CardTestPlayerBase {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Check that a DiesTriggeredAbility of a creature does not trigger
|
||||
* if the creature dies face down in combat
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testDiesTriggeredDoesNotTriggerInCombatIfFaceDown() {
|
||||
// Flying
|
||||
// When Ashcloud Phoenix dies, return it to the battlefield face down.
|
||||
// Morph (You may cast this card face down as a 2/2 creature for . Turn it face up any time for its morph cost.)
|
||||
// When Ashcloud Phoenix is turned face up, it deals 2 damage to each player.
|
||||
addCard(Zone.HAND, playerA, "Ashcloud Phoenix", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
|
||||
|
||||
// First strike, forestwalk, vigilance
|
||||
// (This creature deals combat damage before creatures without first strike, it can't be blocked as long as defending player controls a Forest, and attacking doesn't cause this creature to tap.)
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Mirri, Cat Warrior");
|
||||
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ashcloud Phoenix");
|
||||
setChoice(playerA, "Yes"); // cast it face down as 2/2 creature
|
||||
|
||||
attack(2, playerB, "Mirri, Cat Warrior");
|
||||
block(2, playerA, "face down creature", "Mirri, Cat Warrior");
|
||||
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Ashcloud Phoenix", 1);
|
||||
|
||||
|
||||
for (Card card: playerA.getGraveyard().getCards(currentGame)) {
|
||||
if (card.getName().equals("Ashcloud Phoenix")) {
|
||||
Assert.assertEquals("Ashcloud Phoenix has to be face up in graveyard", false, card.isFaceDown(currentGame));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* 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 ProvokeTest extends CardTestPlayerBase{
|
||||
|
||||
@Test
|
||||
public void testProvokeTappedCreature() {
|
||||
// Creature - Beast 5/3
|
||||
// Trample
|
||||
// Provoke (When this attacks, you may have target creature defending player controls untap and block it if able.)
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Brontotherium");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
|
||||
|
||||
attack(2, playerB, "Silvercoat Lion"); // So it's tapped
|
||||
|
||||
attack(3, playerA, "Brontotherium");
|
||||
addTarget(playerA, "Silvercoat Lion");
|
||||
|
||||
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 18); // one attack from Lion
|
||||
assertLife(playerB, 17); // Because of Trample
|
||||
|
||||
assertPermanentCount(playerA, "Brontotherium", 1);
|
||||
assertGraveyardCount(playerB,"Silvercoat Lion", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProvokeCreatureThatCantBlock() {
|
||||
// Creature - Beast 5/3
|
||||
// Trample
|
||||
// Provoke (When this attacks, you may have target creature defending player controls untap and block it if able.)
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Brontotherium");
|
||||
|
||||
// Creature - Zombie Imp 1/1
|
||||
// Discard a card: Putrid Imp gains flying until end of turn.
|
||||
// Threshold - As long as seven or more cards are in your graveyard, Putrid Imp gets +1/+1 and can't block.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Putrid Imp", 1);
|
||||
addCard(Zone.GRAVEYARD, playerB, "Swamp", 7);
|
||||
|
||||
attack(2, playerB, "Putrid Imp"); // So it's tapped
|
||||
|
||||
attack(3, playerA, "Brontotherium");
|
||||
addTarget(playerA, "Putrid Imp");
|
||||
|
||||
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Brontotherium", 1);
|
||||
assertPermanentCount(playerB, "Putrid Imp", 1); // Can't Block so still alive
|
||||
|
||||
assertLife(playerA, 18); // one attack from Imp
|
||||
assertLife(playerB, 15); // Not blocked
|
||||
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ package org.mage.test.cards.replacement;
|
|||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
|
@ -40,11 +41,11 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
|||
public class GrindstoneTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* Tests that instead of one spore counter there were two spore counters added to Pallid Mycoderm
|
||||
* if Doubling Season is on the battlefield.
|
||||
* Tests that Grindstone mills all cards to graveyard while Painter's Servant is in play
|
||||
* Leaving one Progenius in play
|
||||
*/
|
||||
@Test
|
||||
public void testGrindstoneTest() {
|
||||
public void testGrindstoneProgenius() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
|
||||
// As Painter's Servant enters the battlefield, choose a color.
|
||||
// All cards that aren't on the battlefield, spells, and permanents are the chosen color in addition to their other colors.
|
||||
|
@ -52,18 +53,88 @@ public class GrindstoneTest extends CardTestPlayerBase {
|
|||
// {3}, {T}: Target player puts the top two cards of his or her library into his or her graveyard. If both cards share a color, repeat this process.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Grindstone");
|
||||
|
||||
addCard(Zone.LIBRARY, playerA, "Progenitus", 2);
|
||||
// Protection from everything
|
||||
// If Progenitus would be put into a graveyard from anywhere, reveal Progenitus and shuffle it into its owner's library instead.
|
||||
addCard(Zone.LIBRARY, playerB, "Progenitus", 1);
|
||||
skipInitShuffling();
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Painter's Servant");
|
||||
setChoice(playerA, "Blue");
|
||||
|
||||
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{3},{T}: Target player puts the top two cards of his or her library into his or her graveyard. If both cards share a color, repeat this process.");
|
||||
addTarget(playerA, playerB);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
Assert.assertEquals("Progenitus has to be in the libarary", 1, playerB.getLibrary().size());
|
||||
assertPermanentCount(playerA, "Painter's Servant", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Grindstone mills all cards to graveyard while Painter's Servant is in play
|
||||
* Iterating with two Progenius for a draw
|
||||
*/
|
||||
@Test
|
||||
public void testGrindstoneProgeniusDraw() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
|
||||
// As Painter's Servant enters the battlefield, choose a color.
|
||||
// All cards that aren't on the battlefield, spells, and permanents are the chosen color in addition to their other colors.
|
||||
addCard(Zone.HAND, playerA, "Painter's Servant");
|
||||
// {3}, {T}: Target player puts the top two cards of his or her library into his or her graveyard. If both cards share a color, repeat this process.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Grindstone");
|
||||
|
||||
// Protection from everything
|
||||
// If Progenitus would be put into a graveyard from anywhere, reveal Progenitus and shuffle it into its owner's library instead.
|
||||
addCard(Zone.LIBRARY, playerB, "Progenitus", 2);
|
||||
skipInitShuffling();
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Painter's Servant");
|
||||
setChoice(playerA, "Blue");
|
||||
|
||||
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{3},{T}: Target player puts the top two cards of his or her library into his or her graveyard. If both cards share a color, repeat this process.");
|
||||
addTarget(playerA, playerB);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
Assert.assertTrue("Has to be a draw because of endless iteration", currentGame.isADraw());
|
||||
assertPermanentCount(playerA, "Painter's Servant", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Grindstone mills all cards to graveyard while Painter's Servant is in play
|
||||
* Iterating with two Progenius for a draw
|
||||
*/
|
||||
@Test
|
||||
public void testGrindstoneUlamog() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
|
||||
// As Painter's Servant enters the battlefield, choose a color.
|
||||
// All cards that aren't on the battlefield, spells, and permanents are the chosen color in addition to their other colors.
|
||||
addCard(Zone.HAND, playerA, "Painter's Servant");
|
||||
// {3}, {T}: Target player puts the top two cards of his or her library into his or her graveyard. If both cards share a color, repeat this process.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Grindstone");
|
||||
|
||||
// When you cast Ulamog, the Infinite Gyre, destroy target permanent.
|
||||
// Annihilator 4 (Whenever this creature attacks, defending player sacrifices four permanents.)
|
||||
// Ulamog is indestructible.
|
||||
// When Ulamog is put into a graveyard from anywhere, its owner shuffles his or her graveyard into his or her library.
|
||||
addCard(Zone.LIBRARY, playerB, "Ulamog, the Infinite Gyre", 2);
|
||||
skipInitShuffling();
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Painter's Servant");
|
||||
setChoice(playerA, "Blue");
|
||||
|
||||
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{3},{T}: Target player puts the top two cards of his or her library into his or her graveyard. If both cards share a color, repeat this process.");
|
||||
addTarget(playerA, playerB);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
// No cards in graveyard because Ulamog shuffle all cards back to Lib
|
||||
assertGraveyardCount(playerB, 0);
|
||||
assertPermanentCount(playerA, "Painter's Servant", 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -66,16 +66,22 @@ public class ConditionalMana extends Mana implements Serializable {
|
|||
*/
|
||||
private UUID manaProducerId;
|
||||
|
||||
/**
|
||||
* UUID originalId of source ability for mana.
|
||||
*/
|
||||
private UUID manaProducerOriginalId;
|
||||
|
||||
public ConditionalMana(Mana mana) {
|
||||
super(mana);
|
||||
}
|
||||
|
||||
public ConditionalMana(ConditionalMana conditionalMana) {
|
||||
public ConditionalMana(final ConditionalMana conditionalMana) {
|
||||
super(conditionalMana);
|
||||
conditions = conditionalMana.conditions;
|
||||
scope = conditionalMana.scope;
|
||||
staticText = conditionalMana.staticText;
|
||||
manaProducerId = conditionalMana.manaProducerId;
|
||||
manaProducerOriginalId = conditionalMana.manaProducerOriginalId;
|
||||
}
|
||||
|
||||
public void addCondition(Condition condition) {
|
||||
|
@ -154,6 +160,14 @@ public class ConditionalMana extends Mana implements Serializable {
|
|||
public void setManaProducerId(UUID manaProducerId) {
|
||||
this.manaProducerId = manaProducerId;
|
||||
}
|
||||
|
||||
public UUID getManaProducerOriginalId() {
|
||||
return manaProducerOriginalId;
|
||||
}
|
||||
|
||||
public void setManaProducerOriginalId(UUID manaProducerOriginalId) {
|
||||
this.manaProducerOriginalId = manaProducerOriginalId;
|
||||
}
|
||||
|
||||
public void clear(ManaType manaType) {
|
||||
switch(manaType) {
|
||||
|
|
|
@ -56,7 +56,7 @@ public class NamePredicate implements Predicate<MageObject> {
|
|||
SplitCard card = (SplitCard) ((Spell)input).getCard();
|
||||
return name.equals(card.getLeftHalfCard().getName()) || name.equals(card.getRightHalfCard().getLogName());
|
||||
} else {
|
||||
return name.equals(input.getName());
|
||||
return name.equals(input.getLogName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -229,8 +229,9 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
}
|
||||
}
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_ATTACKERS, attackerId, attackerId));
|
||||
if (!game.isSimulation())
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder(player.getName()).append(" attacks with ").append(groups.size()).append(groups.size() == 1 ? " creature":" creatures").toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkAttackRequirements(Player player, Game game) {
|
||||
|
@ -283,8 +284,9 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
for (UUID attackingCreatureId : group.getAttackers()) {
|
||||
Permanent attacker = game.getPermanent(attackingCreatureId);
|
||||
if (count > 1 && attacker != null && attacker.getAbilities().containsKey(CanAttackOnlyAloneAbility.getInstance().getId())) {
|
||||
if (!game.isSimulation())
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(attacker.getLogName() + " can only attack alone. Removing it from combat.");
|
||||
}
|
||||
tobeRemoved.add(attackingCreatureId);
|
||||
count--;
|
||||
}
|
||||
|
@ -301,8 +303,9 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
for (UUID attackingCreatureId : group.getAttackers()) {
|
||||
Permanent attacker = game.getPermanent(attackingCreatureId);
|
||||
if (attacker != null && attacker.getAbilities().containsKey(CantAttackAloneAbility.getInstance().getId())) {
|
||||
if (!game.isSimulation())
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(attacker.getLogName() + " can't attack alone. Removing it from combat.");
|
||||
}
|
||||
tobeRemoved.add(attackingCreatureId);
|
||||
}
|
||||
}
|
||||
|
@ -360,8 +363,9 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, defenderId, defenderId));
|
||||
|
||||
// add info about attacker blocked by blocker to the game log
|
||||
if (!game.isSimulation())
|
||||
if (!game.isSimulation()) {
|
||||
this.logBlockerInfo(defender, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
// tool to catch the bug about flyers blocked by non flyers or intimidate blocked by creatures with other colors
|
||||
|
@ -467,7 +471,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
for (Ability ability : requirementEntry.getValue()) {
|
||||
UUID attackingCreatureId = requirementEntry.getKey().mustBlockAttacker(ability, game);
|
||||
Player defender = game.getPlayer(possibleBlocker.getControllerId());
|
||||
if (attackingCreatureId != null && defender != null) {
|
||||
if (attackingCreatureId != null && defender != null && possibleBlocker.canBlock(attackingCreatureId, game)) {
|
||||
if (creatureMustBlockAttackers.containsKey(possibleBlocker.getId())) {
|
||||
creatureMustBlockAttackers.get(possibleBlocker.getId()).add(attackingCreatureId);
|
||||
} else {
|
||||
|
@ -671,8 +675,9 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
}
|
||||
}
|
||||
if (possibleBlockerAvailable) {
|
||||
if (!game.isSimulation())
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayer(controller, new StringBuilder(toBeBlockedCreature.getLogName()).append(" has to be blocked by at least one creature.").toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,7 +120,9 @@ public class ManaPool implements Serializable {
|
|||
}
|
||||
boolean spendAnyMana = spendAnyMana(ability, game);
|
||||
if (mana.get(manaType) > 0 || (spendAnyMana && mana.count() > 0)) {
|
||||
game.fireEvent(new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getSourceId(), ability.getControllerId(), 0, mana.getFlag()));
|
||||
GameEvent event = new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getSourceId(), ability.getControllerId(), 0, mana.getFlag());
|
||||
event.setData(mana.getOriginalId().toString());
|
||||
game.fireEvent(event);
|
||||
if (spendAnyMana) {
|
||||
mana.removeAny();
|
||||
} else {
|
||||
|
@ -354,13 +356,13 @@ public class ManaPool implements Serializable {
|
|||
Mana mana = manaToAdd.copy();
|
||||
if (!game.replaceEvent(new ManaEvent(EventType.ADD_MANA, source.getId(), source.getSourceId(), source.getControllerId(), mana))) {
|
||||
if (mana instanceof ConditionalMana) {
|
||||
ManaPoolItem item = new ManaPoolItem((ConditionalMana)mana, source.getSourceId());
|
||||
ManaPoolItem item = new ManaPoolItem((ConditionalMana)mana, source.getSourceId(), source.getOriginalId());
|
||||
if (emptyOnTurnsEnd) {
|
||||
item.setDuration(Duration.EndOfTurn);
|
||||
}
|
||||
this.manaItems.add(item);
|
||||
} else {
|
||||
ManaPoolItem item = new ManaPoolItem(mana.getRed(), mana.getGreen(), mana.getBlue(), mana.getWhite(), mana.getBlack(), mana.getColorless(), source.getSourceId(), mana.getFlag());
|
||||
ManaPoolItem item = new ManaPoolItem(mana.getRed(), mana.getGreen(), mana.getBlue(), mana.getWhite(), mana.getBlack(), mana.getColorless(), source.getSourceId(), source.getOriginalId(), mana.getFlag());
|
||||
if (emptyOnTurnsEnd) {
|
||||
item.setDuration(Duration.EndOfTurn);
|
||||
}
|
||||
|
@ -398,7 +400,9 @@ public class ManaPool implements Serializable {
|
|||
for (ConditionalMana mana : getConditionalMana()) {
|
||||
if (mana.get(manaType) > 0 && mana.apply(ability, game, mana.getManaProducerId())) {
|
||||
mana.set(manaType, mana.get(manaType) - 1);
|
||||
game.fireEvent(new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getManaProducerId(), ability.getControllerId(), 0, mana.getFlag()));
|
||||
GameEvent event = new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getManaProducerId(), ability.getControllerId(), 0, mana.getFlag());
|
||||
event.setData(mana.getManaProducerOriginalId().toString());
|
||||
game.fireEvent(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,12 +48,13 @@ public class ManaPoolItem implements Serializable {
|
|||
private int colorless = 0;
|
||||
private ConditionalMana conditionalMana;
|
||||
private UUID sourceId;
|
||||
private UUID originalId; // originalId of the mana producing ability
|
||||
private boolean flag = false;
|
||||
private Duration duration;
|
||||
|
||||
public ManaPoolItem() {}
|
||||
|
||||
public ManaPoolItem(int red, int green, int blue, int white, int black, int colorless, UUID sourceId, boolean flag) {
|
||||
public ManaPoolItem(int red, int green, int blue, int white, int black, int colorless, UUID sourceId, UUID originalId, boolean flag) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
|
@ -61,14 +62,17 @@ public class ManaPoolItem implements Serializable {
|
|||
this.black = black;
|
||||
this.colorless = colorless;
|
||||
this.sourceId = sourceId;
|
||||
this.originalId = originalId;
|
||||
this.flag = flag;
|
||||
this.duration = Duration.EndOfStep;
|
||||
}
|
||||
|
||||
public ManaPoolItem(ConditionalMana conditionalMana, UUID sourceId) {
|
||||
public ManaPoolItem(ConditionalMana conditionalMana, UUID sourceId, UUID originalId) {
|
||||
this.conditionalMana = conditionalMana;
|
||||
this.sourceId = sourceId;
|
||||
this.originalId = originalId;
|
||||
this.conditionalMana.setManaProducerId(sourceId);
|
||||
this.conditionalMana.setManaProducerOriginalId(originalId);
|
||||
this.flag = conditionalMana.getFlag();
|
||||
this.duration = Duration.EndOfStep;
|
||||
}
|
||||
|
@ -84,6 +88,7 @@ public class ManaPoolItem implements Serializable {
|
|||
this.conditionalMana = item.conditionalMana.copy();
|
||||
}
|
||||
this.sourceId = item.sourceId;
|
||||
this.originalId = item.originalId;
|
||||
this.flag = item.flag;
|
||||
this.duration = item.duration;
|
||||
}
|
||||
|
@ -96,6 +101,10 @@ public class ManaPoolItem implements Serializable {
|
|||
return sourceId;
|
||||
}
|
||||
|
||||
public UUID getOriginalId() {
|
||||
return originalId;
|
||||
}
|
||||
|
||||
public boolean getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
|
81
Mage/src/mage/watchers/common/PlayerCastCreatureWatcher.java
Normal file
81
Mage/src/mage/watchers/common/PlayerCastCreatureWatcher.java
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* 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 mage.watchers.common;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class PlayerCastCreatureWatcher extends Watcher {
|
||||
|
||||
Set<UUID> playerIds = new HashSet<>();
|
||||
|
||||
public PlayerCastCreatureWatcher() {
|
||||
super("PlayerCastCreature", WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayerCastCreatureWatcher(final PlayerCastCreatureWatcher watcher) {
|
||||
super(watcher);
|
||||
this.playerIds.addAll(watcher.playerIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||
if (spell.getCardType().contains(CardType.CREATURE)) {
|
||||
playerIds.add(spell.getControllerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerCastCreatureWatcher copy() {
|
||||
return new PlayerCastCreatureWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
playerIds.clear();
|
||||
}
|
||||
|
||||
public boolean playerDidCastCreatureThisTurn(UUID playerId) {
|
||||
return playerIds.contains(playerId);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue