* Hinder - Fixed that the countered spell was always moved to top of library.

This commit is contained in:
LevelX2 2015-12-31 12:45:58 +01:00
parent 554e81a462
commit 35c672fa7a
14 changed files with 126 additions and 33 deletions

View file

@ -48,9 +48,11 @@ import mage.cards.Card;
import mage.cards.CardsImpl;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SpellAbilityType;
import mage.constants.Zone;
import mage.constants.ZoneDetail;
import mage.counters.Counter;
import mage.counters.Counters;
import mage.game.Game;
@ -328,11 +330,11 @@ public class Spell extends StackObjImpl implements Card {
@Override
public void counter(UUID sourceId, Game game) {
this.counter(sourceId, game, Zone.GRAVEYARD, false, true);
this.counter(sourceId, game, Zone.GRAVEYARD, false, ZoneDetail.NONE);
}
@Override
public void counter(UUID sourceId, Game game, Zone zone, boolean owner, boolean top) {
public void counter(UUID sourceId, Game game, Zone zone, boolean owner, ZoneDetail zoneDetail) {
this.countered = true;
if (!isCopiedSpell()) {
Player player = game.getPlayer(game.getControllerId(sourceId));
@ -346,7 +348,14 @@ public class Spell extends StackObjImpl implements Card {
counteringAbility = ((StackObject) counteringObject).getStackAbility();
}
if (zone.equals(Zone.LIBRARY)) {
if (top) {
if (zoneDetail.equals(ZoneDetail.CHOOSE)) {
if (player.chooseUse(Outcome.Detriment, "Move countered spell to the top of the library? (otherwise it goes to the bottom)", counteringAbility, game)) {
zoneDetail = ZoneDetail.TOP;
} else {
zoneDetail = ZoneDetail.BOTTOM;
}
}
if (zoneDetail.equals(ZoneDetail.TOP)) {
player.putCardsOnTopOfLibrary(new CardsImpl(card), game, counteringAbility, false);
} else {
player.putCardsOnBottomOfLibrary(new CardsImpl(card), game, counteringAbility, false);

View file

@ -32,6 +32,7 @@ import java.util.Date;
import java.util.UUID;
import mage.MageObject;
import mage.constants.Zone;
import mage.constants.ZoneDetail;
import mage.game.Game;
import mage.game.events.GameEvent;
import org.apache.log4j.Logger;
@ -82,10 +83,10 @@ public class SpellStack extends ArrayDeque<StackObject> {
}
public boolean counter(UUID objectId, UUID sourceId, Game game) {
return counter(objectId, sourceId, game, Zone.GRAVEYARD, false, true);
return counter(objectId, sourceId, game, Zone.GRAVEYARD, false, ZoneDetail.TOP);
}
public boolean counter(UUID objectId, UUID sourceId, Game game, Zone zone, boolean owner, boolean onTop) {
public boolean counter(UUID objectId, UUID sourceId, Game game, Zone zone, boolean owner, ZoneDetail zoneDetail) {
// the counter logic is copied by some spells to handle replacement effects of the countered spell
// so if logic is changed here check those spells for needed changes too
// Concerned cards to check: Hinder, Spell Crumple
@ -108,7 +109,7 @@ public class SpellStack extends ArrayDeque<StackObject> {
if (!(stackObject instanceof Spell)) { // spells are removed from stack by the card movement
this.remove(stackObject);
}
stackObject.counter(sourceId, game, zone, owner, onTop);
stackObject.counter(sourceId, game, zone, owner, zoneDetail);
if (!game.isSimulation()) {
game.informPlayers(counteredObjectName + " is countered by " + sourceObject.getLogName());
}

View file

@ -57,6 +57,7 @@ import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.EffectType;
import mage.constants.Zone;
import mage.constants.ZoneDetail;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
@ -123,11 +124,11 @@ public class StackAbility extends StackObjImpl implements Ability {
@Override
public void counter(UUID sourceId, Game game) {
// zone, owner, top ignored
this.counter(sourceId, game, Zone.GRAVEYARD, true, true);
this.counter(sourceId, game, Zone.GRAVEYARD, true, ZoneDetail.TOP);
}
@Override
public void counter(UUID sourceId, Game game, Zone zone, boolean owner, boolean top) {
public void counter(UUID sourceId, Game game, Zone zone, boolean owner, ZoneDetail zoneDetail) {
//20100716 - 603.8
if (ability instanceof StateTriggeredAbility) {
((StateTriggeredAbility) ability).counter(game);

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.constants.Zone;
import mage.constants.ZoneDetail;
import mage.filter.FilterPermanent;
import mage.game.Controllable;
import mage.game.Game;
@ -43,7 +44,7 @@ public interface StackObject extends MageObject, Controllable {
void counter(UUID sourceId, Game game);
void counter(UUID sourceId, Game game, Zone zone, boolean owner, boolean top);
void counter(UUID sourceId, Game game, Zone zone, boolean owner, ZoneDetail zoneDetail);
Ability getStackAbility();