mirror of
https://github.com/correl/mage.git
synced 2025-04-08 09:11:04 -09:00
* Fixed handling of face down card selection (e.g. for Scroll Rack).
This commit is contained in:
parent
ef1a487dd5
commit
662ee7ca10
6 changed files with 142 additions and 102 deletions
Mage.Common/src/mage/view
Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human
Mage.Server/src/main/java/mage/server/game
Mage/src/mage
|
@ -1,33 +1,35 @@
|
||||||
/*
|
/*
|
||||||
* 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.view;
|
package mage.view;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.Modes;
|
import mage.abilities.Modes;
|
||||||
|
@ -35,9 +37,14 @@ import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.costs.mana.ManaCosts;
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.SplitCard;
|
import mage.cards.SplitCard;
|
||||||
import mage.constants.*;
|
import mage.constants.AbilityType;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.MageObjectType;
|
||||||
|
import mage.constants.Rarity;
|
||||||
|
import mage.constants.Zone;
|
||||||
import mage.counters.Counter;
|
import mage.counters.Counter;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
|
import mage.game.Game;
|
||||||
import mage.game.command.Emblem;
|
import mage.game.command.Emblem;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.PermanentToken;
|
import mage.game.permanent.PermanentToken;
|
||||||
|
@ -47,15 +54,11 @@ import mage.game.stack.StackAbility;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.Targets;
|
import mage.target.Targets;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.game.Game;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class CardView extends SimpleCardView {
|
public class CardView extends SimpleCardView {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
protected UUID parentId;
|
protected UUID parentId;
|
||||||
|
@ -88,7 +91,7 @@ public class CardView extends SimpleCardView {
|
||||||
|
|
||||||
protected boolean flipCard;
|
protected boolean flipCard;
|
||||||
protected boolean faceDown;
|
protected boolean faceDown;
|
||||||
|
|
||||||
protected String alternateName;
|
protected String alternateName;
|
||||||
protected String originalName;
|
protected String originalName;
|
||||||
|
|
||||||
|
@ -114,7 +117,7 @@ public class CardView extends SimpleCardView {
|
||||||
protected boolean isPlayable;
|
protected boolean isPlayable;
|
||||||
protected boolean isChoosable;
|
protected boolean isChoosable;
|
||||||
protected boolean selected;
|
protected boolean selected;
|
||||||
protected boolean canAttack;
|
protected boolean canAttack;
|
||||||
|
|
||||||
public CardView(Card card) {
|
public CardView(Card card) {
|
||||||
this(card, null, false);
|
this(card, null, false);
|
||||||
|
@ -134,13 +137,42 @@ public class CardView extends SimpleCardView {
|
||||||
*
|
*
|
||||||
* @param card
|
* @param card
|
||||||
* @param game
|
* @param game
|
||||||
* @param controlled is the card view created for the card controller - used for morph / face down cards to know which player may see information for the card
|
* @param controlled is the card view created for the card controller - used
|
||||||
|
* for morph / face down cards to know which player may see information for
|
||||||
|
* the card
|
||||||
*/
|
*/
|
||||||
public CardView(Card card, Game game, boolean controlled) {
|
public CardView(Card card, Game game, boolean controlled) {
|
||||||
|
this(card, game, controlled, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param card
|
||||||
|
* @param game
|
||||||
|
* @param controlled is the card view created for the card controller - used
|
||||||
|
* for morph / face down cards to know which player may see information for
|
||||||
|
* the card
|
||||||
|
* @param showFaceDownCard if true and the card is not on the battelfield,
|
||||||
|
* also a face dwon card is shown in the view dwon cards will be shown
|
||||||
|
*/
|
||||||
|
public CardView(Card card, Game game, boolean controlled, boolean showFaceDownCard) {
|
||||||
super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode(), game != null);
|
super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode(), game != null);
|
||||||
// no information available for face down cards as long it's not a controlled face down morph card
|
// no information available for face down cards as long it's not a controlled face down morph card
|
||||||
// TODO: Better handle this in Framework (but currently I'm not sure how to do it there) LevelX2
|
// TODO: Better handle this in Framework (but currently I'm not sure how to do it there) LevelX2
|
||||||
if (game != null && card.isFaceDown(game)) {
|
boolean showFaceUp = true;
|
||||||
|
if (game != null) {
|
||||||
|
if (card.isFaceDown(game)) {
|
||||||
|
showFaceUp = false;
|
||||||
|
if (!Zone.BATTLEFIELD.equals(game.getState().getZone(card.getId()))) {
|
||||||
|
if (showFaceDownCard) {
|
||||||
|
showFaceUp = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// boolean showFaceUp = game == null || !card.isFaceDown(game) || (!game.getState().getZone(card.getId()).equals(Zone.BATTLEFIELD) && showFaceDownCard);
|
||||||
|
|
||||||
|
if (!showFaceUp) {
|
||||||
this.fillEmpty(card, controlled);
|
this.fillEmpty(card, controlled);
|
||||||
if (card instanceof Spell) {
|
if (card instanceof Spell) {
|
||||||
// special handling for casting of Morph cards
|
// special handling for casting of Morph cards
|
||||||
|
@ -151,10 +183,10 @@ public class CardView extends SimpleCardView {
|
||||||
}
|
}
|
||||||
this.power = "2";
|
this.power = "2";
|
||||||
this.toughness = "2";
|
this.toughness = "2";
|
||||||
this.rules.add("You may cast this card as a 2/2 face-down creature, with no text," +
|
this.rules.add("You may cast this card as a 2/2 face-down creature, with no text,"
|
||||||
" no name, no subtypes, and no mana cost by paying {3} rather than paying its mana cost.");
|
+ " no name, no subtypes, and no mana cost by paying {3} rather than paying its mana cost.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (card instanceof Permanent) {
|
if (card instanceof Permanent) {
|
||||||
this.power = Integer.toString(card.getPower().getValue());
|
this.power = Integer.toString(card.getPower().getValue());
|
||||||
this.toughness = Integer.toString(card.getToughness().getValue());
|
this.toughness = Integer.toString(card.getToughness().getValue());
|
||||||
|
@ -172,7 +204,7 @@ public class CardView extends SimpleCardView {
|
||||||
rotate = true;
|
rotate = true;
|
||||||
} else {
|
} else {
|
||||||
if (card instanceof Spell) {
|
if (card instanceof Spell) {
|
||||||
switch(((Spell) card).getSpellAbility().getSpellAbilityType()) {
|
switch (((Spell) card).getSpellAbility().getSpellAbilityType()) {
|
||||||
case SPLIT_FUSED:
|
case SPLIT_FUSED:
|
||||||
splitCard = (SplitCard) ((Spell) card).getCard();
|
splitCard = (SplitCard) ((Spell) card).getCard();
|
||||||
rotate = true;
|
rotate = true;
|
||||||
|
@ -206,7 +238,7 @@ public class CardView extends SimpleCardView {
|
||||||
|
|
||||||
if (card instanceof Permanent) {
|
if (card instanceof Permanent) {
|
||||||
this.mageObjectType = MageObjectType.PERMANENT;
|
this.mageObjectType = MageObjectType.PERMANENT;
|
||||||
Permanent permanent = (Permanent)card;
|
Permanent permanent = (Permanent) card;
|
||||||
this.loyalty = Integer.toString(permanent.getCounters().getCount(CounterType.LOYALTY));
|
this.loyalty = Integer.toString(permanent.getCounters().getCount(CounterType.LOYALTY));
|
||||||
this.pairedCard = permanent.getPairedCard();
|
this.pairedCard = permanent.getPairedCard();
|
||||||
if (!permanent.getControllerId().equals(permanent.getOwnerId())) {
|
if (!permanent.getControllerId().equals(permanent.getOwnerId())) {
|
||||||
|
@ -214,7 +246,7 @@ public class CardView extends SimpleCardView {
|
||||||
}
|
}
|
||||||
if (game != null && permanent.getCounters() != null && !permanent.getCounters().isEmpty()) {
|
if (game != null && permanent.getCounters() != null && !permanent.getCounters().isEmpty()) {
|
||||||
counters = new ArrayList<>();
|
counters = new ArrayList<>();
|
||||||
for (Counter counter: permanent.getCounters().values()) {
|
for (Counter counter : permanent.getCounters().values()) {
|
||||||
counters.add(new CounterView(counter));
|
counters.add(new CounterView(counter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,7 +259,7 @@ public class CardView extends SimpleCardView {
|
||||||
this.loyalty = "";
|
this.loyalty = "";
|
||||||
if (game != null && card.getCounters(game) != null && !card.getCounters(game).isEmpty()) {
|
if (game != null && card.getCounters(game) != null && !card.getCounters(game).isEmpty()) {
|
||||||
counters = new ArrayList<>();
|
counters = new ArrayList<>();
|
||||||
for (Counter counter: card.getCounters(game).values()) {
|
for (Counter counter : card.getCounters(game).values()) {
|
||||||
counters.add(new CounterView(counter));
|
counters.add(new CounterView(counter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,8 +272,8 @@ public class CardView extends SimpleCardView {
|
||||||
this.color = card.getColor(game);
|
this.color = card.getColor(game);
|
||||||
this.canTransform = card.canTransform();
|
this.canTransform = card.canTransform();
|
||||||
this.flipCard = card.isFlipCard();
|
this.flipCard = card.isFlipCard();
|
||||||
this.faceDown = game != null ? card.isFaceDown(game) : false;
|
this.faceDown = !showFaceUp;
|
||||||
|
|
||||||
if (card instanceof PermanentToken) {
|
if (card instanceof PermanentToken) {
|
||||||
this.isToken = true;
|
this.isToken = true;
|
||||||
this.mageObjectType = MageObjectType.TOKEN;
|
this.mageObjectType = MageObjectType.TOKEN;
|
||||||
|
@ -257,7 +289,7 @@ public class CardView extends SimpleCardView {
|
||||||
//
|
//
|
||||||
// set code und card number for token copies to get the image
|
// set code und card number for token copies to get the image
|
||||||
this.rules = ((PermanentToken) card).getRules(game);
|
this.rules = ((PermanentToken) card).getRules(game);
|
||||||
this.type = ((PermanentToken)card).getToken().getTokenType();
|
this.type = ((PermanentToken) card).getToken().getTokenType();
|
||||||
} else {
|
} else {
|
||||||
this.rarity = card.getRarity();
|
this.rarity = card.getRarity();
|
||||||
this.isToken = false;
|
this.isToken = false;
|
||||||
|
@ -269,7 +301,7 @@ public class CardView extends SimpleCardView {
|
||||||
this.originalName = card.getName();
|
this.originalName = card.getName();
|
||||||
}
|
}
|
||||||
this.flipCard = card.isFlipCard();
|
this.flipCard = card.isFlipCard();
|
||||||
if (card.isFlipCard() && card.getFlipCardName() != null) {
|
if (card.isFlipCard() && card.getFlipCardName() != null) {
|
||||||
this.alternateName = card.getFlipCardName();
|
this.alternateName = card.getFlipCardName();
|
||||||
this.originalName = card.getName();
|
this.originalName = card.getName();
|
||||||
}
|
}
|
||||||
|
@ -277,8 +309,8 @@ public class CardView extends SimpleCardView {
|
||||||
if (card instanceof Spell) {
|
if (card instanceof Spell) {
|
||||||
this.mageObjectType = MageObjectType.SPELL;
|
this.mageObjectType = MageObjectType.SPELL;
|
||||||
Spell spell = (Spell) card;
|
Spell spell = (Spell) card;
|
||||||
for (SpellAbility spellAbility: spell.getSpellAbilities()) {
|
for (SpellAbility spellAbility : spell.getSpellAbilities()) {
|
||||||
for(UUID modeId : spellAbility.getModes().getSelectedModes()) {
|
for (UUID modeId : spellAbility.getModes().getSelectedModes()) {
|
||||||
spellAbility.getModes().setActiveMode(modeId);
|
spellAbility.getModes().setActiveMode(modeId);
|
||||||
if (spellAbility.getTargets().size() > 0) {
|
if (spellAbility.getTargets().size() > 0) {
|
||||||
setTargets(spellAbility.getTargets());
|
setTargets(spellAbility.getTargets());
|
||||||
|
@ -288,12 +320,12 @@ public class CardView extends SimpleCardView {
|
||||||
// show for modal spell, which mode was choosen
|
// show for modal spell, which mode was choosen
|
||||||
if (spell.getSpellAbility().isModal()) {
|
if (spell.getSpellAbility().isModal()) {
|
||||||
Modes modes = spell.getSpellAbility().getModes();
|
Modes modes = spell.getSpellAbility().getModes();
|
||||||
for(UUID modeId : modes.getSelectedModes()) {
|
for (UUID modeId : modes.getSelectedModes()) {
|
||||||
modes.setActiveMode(modeId);
|
modes.setActiveMode(modeId);
|
||||||
this.rules.add("<span color='green'><i>Chosen mode: " + spell.getSpellAbility().getEffects().getText(modes.get(modeId))+"</i></span>");
|
this.rules.add("<span color='green'><i>Chosen mode: " + spell.getSpellAbility().getEffects().getText(modes.get(modeId)) + "</i></span>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardView(MageObject object) {
|
public CardView(MageObject object) {
|
||||||
|
@ -330,7 +362,7 @@ public class CardView extends SimpleCardView {
|
||||||
this.rules = emblem.getAbilities().getRules(emblem.getName());
|
this.rules = emblem.getAbilities().getRules(emblem.getName());
|
||||||
}
|
}
|
||||||
if (this.rarity == null && object instanceof StackAbility) {
|
if (this.rarity == null && object instanceof StackAbility) {
|
||||||
StackAbility stackAbility = (StackAbility)object;
|
StackAbility stackAbility = (StackAbility) object;
|
||||||
this.rarity = Rarity.NA;
|
this.rarity = Rarity.NA;
|
||||||
this.rules = new ArrayList<>();
|
this.rules = new ArrayList<>();
|
||||||
this.rules.add(stackAbility.getRule());
|
this.rules.add(stackAbility.getRule());
|
||||||
|
@ -343,7 +375,7 @@ public class CardView extends SimpleCardView {
|
||||||
protected CardView() {
|
protected CardView() {
|
||||||
super(null, "", 0, false, "", true);
|
super(null, "", 0, false, "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardView(EmblemView emblem) {
|
public CardView(EmblemView emblem) {
|
||||||
this(true);
|
this(true);
|
||||||
this.gameObject = true;
|
this.gameObject = true;
|
||||||
|
@ -397,7 +429,7 @@ public class CardView extends SimpleCardView {
|
||||||
} else {
|
} else {
|
||||||
this.mageObjectType = MageObjectType.CARD;
|
this.mageObjectType = MageObjectType.CARD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (card instanceof PermanentToken) {
|
if (card instanceof PermanentToken) {
|
||||||
this.mageObjectType = MageObjectType.TOKEN;
|
this.mageObjectType = MageObjectType.TOKEN;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +442,7 @@ public class CardView extends SimpleCardView {
|
||||||
|
|
||||||
CardView(Token token) {
|
CardView(Token token) {
|
||||||
super(token.getId(), "", 0, false, "");
|
super(token.getId(), "", 0, false, "");
|
||||||
this.isToken = true;
|
this.isToken = true;
|
||||||
this.id = token.getId();
|
this.id = token.getId();
|
||||||
this.name = token.getName();
|
this.name = token.getName();
|
||||||
this.displayName = token.getName();
|
this.displayName = token.getName();
|
||||||
|
@ -517,11 +549,11 @@ public class CardView extends SimpleCardView {
|
||||||
public String getExpansionSetCode() {
|
public String getExpansionSetCode() {
|
||||||
return expansionSetCode;
|
return expansionSetCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExpansionSetCode(String expansionSetCode) {
|
public void setExpansionSetCode(String expansionSetCode) {
|
||||||
this.expansionSetCode = expansionSetCode;
|
this.expansionSetCode = expansionSetCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -533,8 +565,7 @@ public class CardView extends SimpleCardView {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns UUIDs for targets.
|
* Returns UUIDs for targets. Can be null if there is no target selected.
|
||||||
* Can be null if there is no target selected.
|
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -595,7 +626,8 @@ public class CardView extends SimpleCardView {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the name of the original name, to provide it for a flipped or transformed or copying card
|
* Stores the name of the original name, to provide it for a flipped or
|
||||||
|
* transformed or copying card
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -706,7 +738,7 @@ public class CardView extends SimpleCardView {
|
||||||
public boolean isChoosable() {
|
public boolean isChoosable() {
|
||||||
return isChoosable;
|
return isChoosable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChoosable(boolean isChoosable) {
|
public void setChoosable(boolean isChoosable) {
|
||||||
this.isChoosable = isChoosable;
|
this.isChoosable = isChoosable;
|
||||||
}
|
}
|
||||||
|
@ -726,5 +758,5 @@ public class CardView extends SimpleCardView {
|
||||||
public void setCanAttack(boolean canAttack) {
|
public void setCanAttack(boolean canAttack) {
|
||||||
this.canAttack = canAttack;
|
this.canAttack = canAttack;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,12 @@ public class CardsView extends LinkedHashMap<UUID, CardView> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CardsView(Game game, Collection<? extends Card> cards, boolean showFaceDown) {
|
||||||
|
for (Card card : cards) {
|
||||||
|
this.put(card.getId(), new CardView(card, game, false, showFaceDown));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public CardsView(Collection<? extends Ability> abilities, Game game) {
|
public CardsView(Collection<? extends Ability> abilities, Game game) {
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
MageObject sourceObject = null;
|
MageObject sourceObject = null;
|
||||||
|
|
|
@ -431,6 +431,7 @@ public class HumanPlayer extends PlayerImpl {
|
||||||
if (!choosable.isEmpty()) {
|
if (!choosable.isEmpty()) {
|
||||||
options.put("choosable", (Serializable) choosable);
|
options.put("choosable", (Serializable) choosable);
|
||||||
}
|
}
|
||||||
|
|
||||||
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, required, options);
|
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, required, options);
|
||||||
waitForResponse(game);
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
|
|
|
@ -825,7 +825,9 @@ public class GameController implements GameCallback {
|
||||||
@Override
|
@Override
|
||||||
public void execute(UUID playerId) {
|
public void execute(UUID playerId) {
|
||||||
if (cards != null) {
|
if (cards != null) {
|
||||||
getGameSession(playerId).target(question, new CardsView(game, cards.getCards(game)), targets, required, options);
|
Zone targetZone = (Zone) options.get("targetZone");
|
||||||
|
boolean showFaceDown = targetZone != null && targetZone.equals(Zone.PICK);
|
||||||
|
getGameSession(playerId).target(question, new CardsView(game, cards.getCards(game), showFaceDown), targets, required, options);
|
||||||
} else if (perms != null) {
|
} else if (perms != null) {
|
||||||
CardsView permsView = new CardsView();
|
CardsView permsView = new CardsView();
|
||||||
for (Permanent perm : perms) {
|
for (Permanent perm : perms) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import mage.players.Player;
|
||||||
* @author Loki
|
* @author Loki
|
||||||
*/
|
*/
|
||||||
public class MayTapOrUntapTargetEffect extends OneShotEffect {
|
public class MayTapOrUntapTargetEffect extends OneShotEffect {
|
||||||
|
|
||||||
public MayTapOrUntapTargetEffect() {
|
public MayTapOrUntapTargetEffect() {
|
||||||
super(Outcome.Benefit);
|
super(Outcome.Benefit);
|
||||||
}
|
}
|
||||||
|
@ -47,9 +48,9 @@ public class MayTapOrUntapTargetEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public String getText(Mode mode) {
|
public String getText(Mode mode) {
|
||||||
if (mode.getTargets().isEmpty()) {
|
if (mode.getTargets().isEmpty()) {
|
||||||
return "You may tap or untap it";
|
return "you may tap or untap it";
|
||||||
} else {
|
} else {
|
||||||
return "You may tap or untap target " + mode.getTargets().get(0).getTargetName();
|
return "you may tap or untap target " + mode.getTargets().get(0).getTargetName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.game;
|
package mage.game;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -39,7 +38,6 @@ import java.util.UUID;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.util.Copyable;
|
import mage.util.Copyable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -48,14 +46,14 @@ public class Exile implements Serializable, Copyable<Exile> {
|
||||||
|
|
||||||
private static final UUID PERMANENT = UUID.randomUUID();
|
private static final UUID PERMANENT = UUID.randomUUID();
|
||||||
|
|
||||||
private Map<UUID, ExileZone> exileZones = new HashMap<UUID, ExileZone>();
|
private Map<UUID, ExileZone> exileZones = new HashMap<>();
|
||||||
|
|
||||||
public Exile() {
|
public Exile() {
|
||||||
createZone(PERMANENT, "Permanent");
|
createZone(PERMANENT, "Permanent");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Exile(final Exile exile) {
|
public Exile(final Exile exile) {
|
||||||
for (Entry<UUID, ExileZone> entry: exile.exileZones.entrySet()) {
|
for (Entry<UUID, ExileZone> entry : exile.exileZones.entrySet()) {
|
||||||
exileZones.put(entry.getKey(), entry.getValue().copy());
|
exileZones.put(entry.getKey(), entry.getValue().copy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +91,7 @@ public class Exile implements Serializable, Copyable<Exile> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Card getCard(UUID cardId, Game game) {
|
public Card getCard(UUID cardId, Game game) {
|
||||||
for (ExileZone exile: exileZones.values()) {
|
for (ExileZone exile : exileZones.values()) {
|
||||||
if (exile.contains(cardId)) {
|
if (exile.contains(cardId)) {
|
||||||
return game.getCard(cardId);
|
return game.getCard(cardId);
|
||||||
}
|
}
|
||||||
|
@ -103,14 +101,14 @@ public class Exile implements Serializable, Copyable<Exile> {
|
||||||
|
|
||||||
public List<Card> getAllCards(Game game) {
|
public List<Card> getAllCards(Game game) {
|
||||||
List<Card> cards = new ArrayList<Card>();
|
List<Card> cards = new ArrayList<Card>();
|
||||||
for (ExileZone exile: exileZones.values()) {
|
for (ExileZone exile : exileZones.values()) {
|
||||||
cards.addAll(exile.getCards(game));
|
cards.addAll(exile.getCards(game));
|
||||||
}
|
}
|
||||||
return cards;
|
return cards;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCard(Card card, Game game) {
|
public void removeCard(Card card, Game game) {
|
||||||
for (ExileZone exile: exileZones.values()) {
|
for (ExileZone exile : exileZones.values()) {
|
||||||
if (exile.contains(card.getId())) {
|
if (exile.contains(card.getId())) {
|
||||||
exile.remove(card);
|
exile.remove(card);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +121,7 @@ public class Exile implements Serializable, Copyable<Exile> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
for (ExileZone exile: exileZones.values()) {
|
for (ExileZone exile : exileZones.values()) {
|
||||||
exile.clear();
|
exile.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue