mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 22:42:03 -08:00
* Some more rework of card mobement handling.
This commit is contained in:
parent
78ff4e58e7
commit
55fe68d718
18 changed files with 298 additions and 284 deletions
|
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.effects.keyword;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
|
|
@ -53,7 +53,7 @@ public class ManifestEffect extends OneShotEffect {
|
|||
|
||||
private final int amount;
|
||||
|
||||
public ManifestEffect(int amount) {
|
||||
public ManifestEffect(int amount) {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.amount = amount;
|
||||
this.staticText = setText();
|
||||
|
|
@ -75,8 +75,8 @@ public class ManifestEffect extends OneShotEffect {
|
|||
if (controller != null) {
|
||||
Ability newSource = source.copy();
|
||||
newSource.setWorksFaceDown(true);
|
||||
List<Card> cards = controller.getLibrary().getTopCards(game, amount);
|
||||
for (Card card: cards) {
|
||||
Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
|
||||
for (Card card : cards) {
|
||||
ManaCosts manaCosts = null;
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
manaCosts = card.getSpellAbility().getManaCosts();
|
||||
|
|
@ -84,7 +84,7 @@ public class ManifestEffect extends OneShotEffect {
|
|||
manaCosts = new ManaCostsImpl("{0}");
|
||||
}
|
||||
}
|
||||
MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) +1, game);
|
||||
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
|
||||
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
|
||||
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, newSource.getSourceId(), false, true);
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
|
|
|
|||
|
|
@ -27,12 +27,11 @@
|
|||
*/
|
||||
package mage.abilities.effects.keyword;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect;
|
||||
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect.FaceDownType;
|
||||
|
|
@ -44,20 +43,18 @@ import mage.constants.Zone;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class ManifestTargetPlayerEffect extends OneShotEffect {
|
||||
|
||||
private final int amount;
|
||||
private final String prefix;
|
||||
|
||||
public ManifestTargetPlayerEffect(int amount, String prefix) {
|
||||
public ManifestTargetPlayerEffect(int amount, String prefix) {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.amount = amount;
|
||||
this.prefix = prefix;
|
||||
|
|
@ -81,8 +78,8 @@ public class ManifestTargetPlayerEffect extends OneShotEffect {
|
|||
if (targetPlayer != null) {
|
||||
Ability newSource = source.copy();
|
||||
newSource.setWorksFaceDown(true);
|
||||
List<Card> cards = targetPlayer.getLibrary().getTopCards(game, amount);
|
||||
for (Card card: cards) {
|
||||
Set<Card> cards = targetPlayer.getLibrary().getTopCards(game, amount);
|
||||
for (Card card : cards) {
|
||||
ManaCosts manaCosts = null;
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
manaCosts = card.getSpellAbility().getManaCosts();
|
||||
|
|
@ -90,13 +87,13 @@ public class ManifestTargetPlayerEffect extends OneShotEffect {
|
|||
manaCosts = new ManaCostsImpl("{0}");
|
||||
}
|
||||
}
|
||||
MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) +1, game);
|
||||
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
|
||||
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
|
||||
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
|
||||
targetPlayer.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, newSource.getSourceId(), false, true);
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null) {
|
||||
permanent.setManifested(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.cards;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -39,18 +38,33 @@ import mage.game.Game;
|
|||
public interface Cards extends Set<UUID>, Serializable {
|
||||
|
||||
void add(Card card);
|
||||
|
||||
Card get(UUID cardId, Game game);
|
||||
|
||||
void remove(Card card);
|
||||
|
||||
void setOwner(UUID ownerId, Game game);
|
||||
|
||||
void addAll(List<Card> createCards);
|
||||
|
||||
void addAll(Set<Card> createCards);
|
||||
|
||||
Set<Card> getCards(Game game);
|
||||
|
||||
Set<Card> getCards(FilterCard filter, Game game);
|
||||
|
||||
Set<Card> getCards(FilterCard filter, UUID sourceId, UUID playerId, Game game);
|
||||
|
||||
String getValue(Game game);
|
||||
|
||||
Collection<Card> getUniqueCards(Game game);
|
||||
|
||||
Card getRandom(Game game);
|
||||
|
||||
int count(FilterCard filter, Game game);
|
||||
|
||||
int count(FilterCard filter, UUID playerId, Game game);
|
||||
|
||||
int count(FilterCard filter, UUID sourceId, UUID playerId, Game game);
|
||||
|
||||
Cards copy();
|
||||
|
|
|
|||
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.cards;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -44,20 +43,20 @@ import mage.filter.FilterCard;
|
|||
import mage.game.Game;
|
||||
import mage.util.ThreadLocalStringBuilder;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializable {
|
||||
|
||||
|
||||
private static final transient ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(200);
|
||||
|
||||
private static Random rnd = new Random();
|
||||
private UUID ownerId;
|
||||
private Zone zone;
|
||||
|
||||
public CardsImpl() { }
|
||||
public CardsImpl() {
|
||||
}
|
||||
|
||||
public CardsImpl(Card card) {
|
||||
if (card != null) {
|
||||
|
|
@ -74,10 +73,10 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
public CardsImpl(Zone zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
|
||||
public CardsImpl(Zone zone, Collection<Card> cards) {
|
||||
this(zone);
|
||||
for (Card card: cards) {
|
||||
for (Card card : cards) {
|
||||
this.add(card.getId());
|
||||
}
|
||||
}
|
||||
|
|
@ -117,7 +116,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
@Override
|
||||
public void setOwner(UUID ownerId, Game game) {
|
||||
this.ownerId = ownerId;
|
||||
for (UUID card: this) {
|
||||
for (UUID card : this) {
|
||||
game.getCard(card).setOwnerId(ownerId);
|
||||
}
|
||||
}
|
||||
|
|
@ -134,7 +133,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
@Override
|
||||
public int count(FilterCard filter, Game game) {
|
||||
int result = 0;
|
||||
for (UUID cardId: this) {
|
||||
for (UUID cardId : this) {
|
||||
if (filter.match(game.getCard(cardId), game)) {
|
||||
result++;
|
||||
}
|
||||
|
|
@ -145,7 +144,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
@Override
|
||||
public int count(FilterCard filter, UUID playerId, Game game) {
|
||||
int result = 0;
|
||||
for (UUID card: this) {
|
||||
for (UUID card : this) {
|
||||
if (filter.match(game.getCard(card), playerId, game)) {
|
||||
result++;
|
||||
}
|
||||
|
|
@ -159,7 +158,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
return count(filter, playerId, game);
|
||||
}
|
||||
int result = 0;
|
||||
for (UUID card: this) {
|
||||
for (UUID card : this) {
|
||||
if (filter.match(game.getCard(card), sourceId, playerId, game)) {
|
||||
result++;
|
||||
}
|
||||
|
|
@ -170,7 +169,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
@Override
|
||||
public Set<Card> getCards(FilterCard filter, UUID sourceId, UUID playerId, Game game) {
|
||||
Set<Card> cards = new LinkedHashSet<>();
|
||||
for (UUID card: this) {
|
||||
for (UUID card : this) {
|
||||
boolean match = filter.match(game.getCard(card), sourceId, playerId, game);
|
||||
if (match) {
|
||||
cards.add(game.getCard(card));
|
||||
|
|
@ -182,7 +181,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
@Override
|
||||
public Set<Card> getCards(FilterCard filter, Game game) {
|
||||
Set<Card> cards = new LinkedHashSet<>();
|
||||
for (UUID card: this) {
|
||||
for (UUID card : this) {
|
||||
boolean match = filter.match(game.getCard(card), game);
|
||||
if (match) {
|
||||
cards.add(game.getCard(card));
|
||||
|
|
@ -194,11 +193,11 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
@Override
|
||||
public Set<Card> getCards(Game game) {
|
||||
Set<Card> cards = new LinkedHashSet<>();
|
||||
for (UUID cardId: this) {
|
||||
for (UUID cardId : this) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) { // this can happen during the cancelation (player concedes) of a game
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
|
|
@ -207,12 +206,12 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
public String getValue(Game game) {
|
||||
StringBuilder sb = threadLocalBuilder.get();
|
||||
List<String> cards = new ArrayList<>();
|
||||
for (UUID cardId: this) {
|
||||
for (UUID cardId : this) {
|
||||
Card card = game.getCard(cardId);
|
||||
cards.add(card.getName());
|
||||
}
|
||||
Collections.sort(cards);
|
||||
for (String name: cards) {
|
||||
for (String name : cards) {
|
||||
sb.append(name).append(":");
|
||||
}
|
||||
return sb.toString();
|
||||
|
|
@ -220,7 +219,14 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
|
||||
@Override
|
||||
public void addAll(List<Card> cards) {
|
||||
for (Card card: cards) {
|
||||
for (Card card : cards) {
|
||||
add(card.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAll(Set<Card> cards) {
|
||||
for (Card card : cards) {
|
||||
add(card.getId());
|
||||
}
|
||||
}
|
||||
|
|
@ -228,7 +234,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
@Override
|
||||
public Collection<Card> getUniqueCards(Game game) {
|
||||
Map<String, Card> cards = new HashMap<>();
|
||||
for(UUID cardId: this) {
|
||||
for (UUID cardId : this) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (!cards.containsKey(card.getName())) {
|
||||
cards.put(card.getName(), card);
|
||||
|
|
|
|||
|
|
@ -1,33 +1,33 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.game.events;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Zone;
|
||||
|
|
@ -37,18 +37,18 @@ import mage.constants.Zone;
|
|||
* @author LevelX2
|
||||
*/
|
||||
public class ZoneChangeGroupEvent extends GameEvent {
|
||||
|
||||
|
||||
private final Zone fromZone;
|
||||
private final Zone toZone;
|
||||
private final List<Card> cards;
|
||||
private final Set<Card> cards;
|
||||
|
||||
public ZoneChangeGroupEvent(List<Card> cards, UUID sourceId, UUID playerId, Zone fromZone, Zone toZone) {
|
||||
public ZoneChangeGroupEvent(Set<Card> cards, UUID sourceId, UUID playerId, Zone fromZone, Zone toZone) {
|
||||
super(EventType.ZONE_CHANGE_GROUP, null, sourceId, playerId);
|
||||
this.fromZone = fromZone;
|
||||
this.toZone = toZone;
|
||||
this.cards = cards;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Zone getFromZone() {
|
||||
return fromZone;
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ public class ZoneChangeGroupEvent extends GameEvent {
|
|||
return toZone;
|
||||
}
|
||||
|
||||
public List<Card> getCards() {
|
||||
public Set<Card> getCards() {
|
||||
return cards;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.players;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -35,6 +34,7 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -65,14 +65,13 @@ public class Library implements Serializable {
|
|||
public Library(final Library lib) {
|
||||
this.emptyDraw = lib.emptyDraw;
|
||||
this.playerId = lib.playerId;
|
||||
for (UUID id: lib.library) {
|
||||
for (UUID id : lib.library) {
|
||||
this.library.addLast(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't use this directly.
|
||||
* Use <player.shuffleLibrary(game)> instead.
|
||||
* Don't use this directly. Use <player.shuffleLibrary(game)> instead.
|
||||
*/
|
||||
public void shuffle() {
|
||||
UUID[] shuffled = library.toArray(new UUID[0]);
|
||||
|
|
@ -88,7 +87,7 @@ public class Library implements Serializable {
|
|||
|
||||
/**
|
||||
* Removes the top card of the Library and returns it
|
||||
*
|
||||
*
|
||||
* @param game
|
||||
* @return Card
|
||||
* @see Card
|
||||
|
|
@ -133,8 +132,7 @@ public class Library implements Serializable {
|
|||
if (card.getOwnerId().equals(playerId)) {
|
||||
card.setZone(Zone.LIBRARY, game);
|
||||
library.addFirst(card.getId());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
game.getPlayer(card.getOwnerId()).getLibrary().putOnTop(card, game);
|
||||
}
|
||||
}
|
||||
|
|
@ -146,8 +144,7 @@ public class Library implements Serializable {
|
|||
library.remove(card.getId());
|
||||
}
|
||||
library.add(card.getId());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
game.getPlayer(card.getOwnerId()).getLibrary().putOnBottom(card, game);
|
||||
}
|
||||
}
|
||||
|
|
@ -166,7 +163,7 @@ public class Library implements Serializable {
|
|||
|
||||
public void set(Library newLibrary) {
|
||||
library.clear();
|
||||
for (UUID card: newLibrary.getCardList()) {
|
||||
for (UUID card : newLibrary.getCardList()) {
|
||||
library.add(card);
|
||||
}
|
||||
}
|
||||
|
|
@ -177,17 +174,17 @@ public class Library implements Serializable {
|
|||
|
||||
public List<Card> getCards(Game game) {
|
||||
List<Card> cards = new ArrayList<>();
|
||||
for (UUID cardId: library) {
|
||||
for (UUID cardId : library) {
|
||||
cards.add(game.getCard(cardId));
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
|
||||
public List<Card> getTopCards(Game game, int amount) {
|
||||
List<Card> cards = new ArrayList<>();
|
||||
public Set<Card> getTopCards(Game game, int amount) {
|
||||
Set<Card> cards = new HashSet<>();
|
||||
Iterator<UUID> it = library.iterator();
|
||||
int count = 0;
|
||||
while(it.hasNext() && count < amount) {
|
||||
while (it.hasNext() && count < amount) {
|
||||
UUID cardId = it.next();
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
|
|
@ -200,7 +197,7 @@ public class Library implements Serializable {
|
|||
|
||||
public Collection<Card> getUniqueCards(Game game) {
|
||||
Map<String, Card> cards = new HashMap<>();
|
||||
for (UUID cardId: library) {
|
||||
for (UUID cardId : library) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (!cards.containsKey(card.getName())) {
|
||||
cards.put(card.getName(), card);
|
||||
|
|
@ -211,7 +208,7 @@ public class Library implements Serializable {
|
|||
|
||||
public int count(FilterCard filter, Game game) {
|
||||
int result = 0;
|
||||
for (UUID card: library) {
|
||||
for (UUID card : library) {
|
||||
if (filter.match(game.getCard(card), game)) {
|
||||
result++;
|
||||
}
|
||||
|
|
@ -219,20 +216,19 @@ public class Library implements Serializable {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
public boolean isEmptyDraw() {
|
||||
return emptyDraw;
|
||||
}
|
||||
|
||||
public void addAll(Set<Card> cards, Game game) {
|
||||
for (Card card: cards) {
|
||||
for (Card card : cards) {
|
||||
card.setZone(Zone.LIBRARY, game);
|
||||
library.add(card.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public Card getCard(UUID cardId, Game game) {
|
||||
for (UUID card: library) {
|
||||
for (UUID card : library) {
|
||||
if (card.equals(cardId)) {
|
||||
return game.getCard(card);
|
||||
}
|
||||
|
|
@ -242,7 +238,7 @@ public class Library implements Serializable {
|
|||
|
||||
public Card remove(UUID cardId, Game game) {
|
||||
Iterator<UUID> it = library.iterator();
|
||||
while(it.hasNext()) {
|
||||
while (it.hasNext()) {
|
||||
UUID card = it.next();
|
||||
if (card.equals(cardId)) {
|
||||
it.remove();
|
||||
|
|
|
|||
|
|
@ -626,9 +626,11 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName);
|
||||
|
||||
boolean moveCards(List<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game);
|
||||
boolean moveCards(Set<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game);
|
||||
|
||||
boolean moveCards(List<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName);
|
||||
boolean moveCards(Set<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName);
|
||||
|
||||
boolean moveCardsToExile(Set<Card> cards, Ability source, Game game, boolean withName, UUID exileId, String exileZoneName);
|
||||
|
||||
/**
|
||||
* Uses card.moveToZone and posts a inform message about moving the card
|
||||
|
|
@ -637,7 +639,6 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param card
|
||||
* @param sourceId
|
||||
* @param game
|
||||
* @param fromZone if null, this info isn't postet
|
||||
* @return
|
||||
*/
|
||||
boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game);
|
||||
|
|
@ -687,7 +688,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param fromZone if null, this info isn't postet
|
||||
* @return
|
||||
*/
|
||||
boolean moveCardsToGraveyardWithInfo(List<Card> cards, Ability source, Game game, Zone fromZone);
|
||||
boolean moveCardsToGraveyardWithInfo(Set<Card> cards, Ability source, Game game, Zone fromZone);
|
||||
|
||||
/**
|
||||
* Uses card.moveToZone and posts a inform message about moving the card to
|
||||
|
|
|
|||
|
|
@ -859,14 +859,16 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
/**
|
||||
* Can be cards or permanents that go to library
|
||||
*
|
||||
* @param cards
|
||||
* @param cardsToLibrary
|
||||
* @param game
|
||||
* @param source
|
||||
* @param anyOrder
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean putCardsOnTopOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder) {
|
||||
public boolean putCardsOnTopOfLibrary(Cards cardsToLibrary, Game game, Ability source, boolean anyOrder) {
|
||||
Cards cards = new CardsImpl(cardsToLibrary); // prevent possible ConcurrentModificationException
|
||||
cards.addAll(cardsToLibrary);
|
||||
if (cards.size() != 0) {
|
||||
if (!anyOrder) {
|
||||
for (UUID cardId : cards) {
|
||||
|
|
@ -2879,7 +2881,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
@Override
|
||||
public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) {
|
||||
ArrayList<Card> cardList = new ArrayList<>();
|
||||
Set<Card> cardList = new HashSet<>();
|
||||
for (UUID cardId : cards) {
|
||||
if (fromZone == null) {
|
||||
fromZone = game.getState().getZone(cardId);
|
||||
|
|
@ -2906,7 +2908,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
@Override
|
||||
public boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) {
|
||||
ArrayList<Card> cardList = new ArrayList<>();
|
||||
Set<Card> cardList = new HashSet<>();
|
||||
if (card != null) {
|
||||
cardList.add(card);
|
||||
}
|
||||
|
|
@ -2914,12 +2916,12 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCards(List<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game) {
|
||||
public boolean moveCards(Set<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game) {
|
||||
return moveCards(cards, fromZone, toZone, source, game, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCards(List<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) {
|
||||
public boolean moveCards(Set<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) {
|
||||
if (cards.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2960,6 +2962,20 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCardsToExile(Set<Card> cards, Ability source, Game game, boolean withName, UUID exileId, String exileZoneName) {
|
||||
if (cards.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
game.fireEvent(new ZoneChangeGroupEvent(cards, source == null ? null : source.getSourceId(), this.getId(), null, Zone.EXILED));
|
||||
boolean result = false;
|
||||
for (Card card : cards) {
|
||||
Zone fromZone = game.getState().getZone(card.getId());
|
||||
result |= moveCardToExileWithInfo(card, exileId, exileZoneName, source == null ? null : source.getSourceId(), game, fromZone, withName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game) {
|
||||
return this.moveCardToHandWithInfo(card, sourceId, game, true);
|
||||
|
|
@ -2974,7 +2990,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
card = game.getCard(card.getId());
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
StringBuilder sb = new StringBuilder(this.getLogName()).append(" puts ").append(withName ? card.getLogName() : "a face down card");
|
||||
StringBuilder sb = new StringBuilder(this.getLogName()).append(" puts ").append(withName ? card.getLogName() : (card.isFaceDown(game) ? "a face down card" : "a card"));
|
||||
switch (fromZone) {
|
||||
case EXILED:
|
||||
sb.append(" from exile zone ");
|
||||
|
|
@ -2992,7 +3008,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCardsToGraveyardWithInfo(List<Card> allCards, Ability source, Game game, Zone fromZone) {
|
||||
public boolean moveCardsToGraveyardWithInfo(Set<Card> allCards, Ability source, Game game, Zone fromZone) {
|
||||
boolean result = true;
|
||||
UUID sourceId = source == null ? null : source.getSourceId();
|
||||
while (!allCards.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -1,33 +1,33 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.target.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
|
@ -42,7 +42,6 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -86,8 +85,7 @@ public class TargetCardInLibrary extends TargetCard {
|
|||
if (librarySearchLimit == Integer.MAX_VALUE) {
|
||||
cards = targetPlayer.getLibrary().getCards(game);
|
||||
} else {
|
||||
int maxCards = Math.min(librarySearchLimit, targetPlayer.getLibrary().size());
|
||||
cards = targetPlayer.getLibrary().getTopCards(game, maxCards);
|
||||
cards = new ArrayList<>(targetPlayer.getLibrary().getTopCards(game, librarySearchLimit));
|
||||
}
|
||||
Collections.sort(cards, new CardNameComparator());
|
||||
while (!isChosen() && !doneChosing()) {
|
||||
|
|
@ -124,7 +122,6 @@ public class TargetCardInLibrary extends TargetCard {
|
|||
this.librarySearchLimit = librarySearchLimit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class CardNameComparator implements Comparator<Card> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue