Some changes to framework objects.

This commit is contained in:
LevelX2 2014-11-13 00:17:52 +01:00
parent 839076755f
commit 8bf72382e4
6 changed files with 82 additions and 54 deletions

View file

@ -1,31 +1,30 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 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 * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * 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 * 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 * 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 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * 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 * 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 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* 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.effects.common; package mage.abilities.effects.common;
import java.util.UUID; import java.util.UUID;
@ -55,9 +54,9 @@ public class ReturnFromExileEffect extends OneShotEffect {
this(exileId, zone, false); this(exileId, zone, false);
} }
public ReturnFromExileEffect(UUID exileId, Zone zone, String text) { public ReturnFromExileEffect(UUID exileId, Zone zone, String text) {
this(exileId, zone, false); this(exileId, zone, false);
staticText = text; staticText = text;
} }
public ReturnFromExileEffect(UUID exileId, Zone zone, boolean tapped) { public ReturnFromExileEffect(UUID exileId, Zone zone, boolean tapped) {
@ -65,7 +64,7 @@ public class ReturnFromExileEffect extends OneShotEffect {
this.exileId = exileId; this.exileId = exileId;
this.zone = zone; this.zone = zone;
this.tapped = tapped; this.tapped = tapped;
setText(); setText();
} }
public ReturnFromExileEffect(final ReturnFromExileEffect effect) { public ReturnFromExileEffect(final ReturnFromExileEffect effect) {
@ -86,7 +85,7 @@ public class ReturnFromExileEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null && exile != null) { if (controller != null && exile != null) {
exile = exile.copy(); exile = exile.copy();
for (UUID cardId: exile) { for (UUID cardId : exile) {
Card card = game.getCard(cardId); Card card = game.getCard(cardId);
Player owner = game.getPlayer(card.getOwnerId()); Player owner = game.getPlayer(card.getOwnerId());
if (owner != null) { if (owner != null) {
@ -119,7 +118,7 @@ public class ReturnFromExileEffect extends OneShotEffect {
private void setText() { private void setText() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("return the exiled cards "); sb.append("return the exiled cards ");
switch(zone) { switch (zone) {
case BATTLEFIELD: case BATTLEFIELD:
sb.append("to the battlefield under its owner's control"); sb.append("to the battlefield under its owner's control");
if (tapped) { if (tapped) {

View file

@ -49,7 +49,6 @@ import mage.util.CardUtil;
public class ScryEffect extends OneShotEffect { public class ScryEffect extends OneShotEffect {
protected static FilterCard filter1 = new FilterCard("card to put on the bottom of your library"); protected static FilterCard filter1 = new FilterCard("card to put on the bottom of your library");
protected static FilterCard filter2 = new FilterCard("card to put on the top of your library (last chosen will be on top)");
protected int scryNumber; protected int scryNumber;
@ -91,22 +90,7 @@ public class ScryEffect extends OneShotEffect {
target1.clearChosen(); target1.clearChosen();
} }
// move cards to the top of the library // move cards to the top of the library
if (cards.size() > 1) { player.putCardsOnTopOfLibrary(cards, game, source, true);
TargetCard target2 = new TargetCard(Zone.LIBRARY, filter2);
while (player.isInGame() && cards.size() > 1) {
player.choose(Outcome.Benefit, cards, target2, game);
Card card = cards.get(target2.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, true, false);
}
target2.clearChosen();
}
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, true, false);
}
game.fireEvent(new GameEvent(GameEvent.EventType.SCRY, source.getControllerId(), source.getSourceId(), source.getControllerId())); game.fireEvent(new GameEvent(GameEvent.EventType.SCRY, source.getControllerId(), source.getSourceId(), source.getControllerId()));
player.setTopCardRevealed(revealed); player.setTopCardRevealed(revealed);
return true; return true;

View file

@ -74,8 +74,8 @@ public abstract class DraftCube {
private final String name; private final String name;
private final int boosterSize = 15; private final int boosterSize = 15;
protected List<CardIdentity> cubeCards = new ArrayList<CardIdentity>(); protected List<CardIdentity> cubeCards = new ArrayList<>();
protected List<CardIdentity> leftCubeCards = new ArrayList<CardIdentity>(); protected List<CardIdentity> leftCubeCards = new ArrayList<>();
public DraftCube(String name) { public DraftCube(String name) {
this.name = name; this.name = name;
@ -90,7 +90,7 @@ public abstract class DraftCube {
} }
public List<Card> createBooster() { public List<Card> createBooster() {
List<Card> booster = new ArrayList<Card>(); List<Card> booster = new ArrayList<>();
if (leftCubeCards.isEmpty()) { if (leftCubeCards.isEmpty()) {
leftCubeCards.addAll(cubeCards); leftCubeCards.addAll(cubeCards);
} }

View file

@ -29,7 +29,6 @@
package mage.game.draft; package mage.game.draft;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View file

@ -297,7 +297,7 @@ public interface Player extends MageItem, Copyable<Player> {
boolean playMana(ManaCost unpaid, Game game); boolean playMana(ManaCost unpaid, Game game);
/** /**
* Moves the cards form <cards> to the bottom of the players library. * Moves the cards from cards to the bottom of the players library.
* *
* @param cards - list of cards that have to be moved * @param cards - list of cards that have to be moved
* @param game - game * @param game - game
@ -307,6 +307,17 @@ public interface Player extends MageItem, Copyable<Player> {
*/ */
boolean putCardsOnBottomOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder); boolean putCardsOnBottomOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder);
/**
* Moves the cards from cards to the top of players library.
*
* @param cards - list of cards that have to be moved
* @param game - game
* @param anyOrder - true if player can determine the order of the cards
* @param source - source ability
* @return
*/
boolean putCardsOnTopOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder);
// set the value for X mana spells and abilities // set the value for X mana spells and abilities
int announceXMana(int min, int max, String message, Game game, Ability ability); int announceXMana(int min, int max, String message, Game game, Ability ability);

View file

@ -804,6 +804,41 @@ public abstract class PlayerImpl implements Player, Serializable {
return true; return true;
} }
@Override
public boolean putCardsOnTopOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder) {
if (cards.size() != 0) {
if (!anyOrder) {
for (UUID cardId : cards) {
Card card =game.getCard(cardId);
if (card != null) {
Zone fromZone = game.getState().getZone(cardId);
this.moveCardToLibraryWithInfo(card, source.getSourceId(), game, fromZone, true, false);
}
}
} else {
TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put on the top of your library (last one chosen will be topmost)"));
target.setRequired(true);
while (isInGame() && cards.size() > 1) {
this.choose(Outcome.Neutral, cards, target, game);
Card chosenCard = cards.get(target.getFirstTarget(), game);
if (chosenCard != null) {
cards.remove(chosenCard);
Zone fromZone = game.getState().getZone(chosenCard.getId());
this.moveCardToLibraryWithInfo(chosenCard, source.getSourceId(), game, fromZone, true, false);
}
target.clearChosen();
}
if (cards.size() == 1) {
Card chosenCard = cards.get(cards.iterator().next(), game);
Zone fromZone = game.getState().getZone(chosenCard.getId());
this.moveCardToLibraryWithInfo(chosenCard, source.getSourceId(), game, fromZone, true, false);
}
}
}
return true;
}
@Override @Override
public void setCastSourceIdWithoutMana(UUID sourceId) { public void setCastSourceIdWithoutMana(UUID sourceId) {
castSourceIdWithoutMana = sourceId; castSourceIdWithoutMana = sourceId;