mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
* UI: added playable card marks in look-at windows;
This commit is contained in:
parent
ff1299cca9
commit
cde9957f54
15 changed files with 200 additions and 122 deletions
|
@ -517,7 +517,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSelected(boolean selected) {
|
public void setSelected(boolean isSelected) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1205,11 +1205,11 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
needSelectable = new HashSet<>();
|
needSelectable = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<UUID> needPlayable;
|
Map<UUID, Integer> needPlayable;
|
||||||
if (showPlayable && gameView.getCanPlayObjects() != null) {
|
if (showPlayable && gameView.getCanPlayObjects() != null) {
|
||||||
needPlayable = gameView.getCanPlayObjects();
|
needPlayable = gameView.getCanPlayObjects();
|
||||||
} else {
|
} else {
|
||||||
needPlayable = new HashSet<>();
|
needPlayable = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needChoosen.isEmpty() && needSelectable.isEmpty() && needPlayable.isEmpty()) {
|
if (needChoosen.isEmpty() && needSelectable.isEmpty() && needPlayable.isEmpty()) {
|
||||||
|
@ -1225,8 +1225,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
if (needChoosen.contains(card.getId())) {
|
if (needChoosen.contains(card.getId())) {
|
||||||
card.setSelected(true);
|
card.setSelected(true);
|
||||||
}
|
}
|
||||||
if (needPlayable.contains(card.getId())) {
|
if (needPlayable.containsKey(card.getId())) {
|
||||||
card.setPlayable(true);
|
card.setPlayable(true);
|
||||||
|
card.setPlayableAmount(needPlayable.get(card.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1254,8 +1255,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
if (needChoosen.contains(perm.getKey())) {
|
if (needChoosen.contains(perm.getKey())) {
|
||||||
perm.getValue().setSelected(true);
|
perm.getValue().setSelected(true);
|
||||||
}
|
}
|
||||||
if (needPlayable.contains(perm.getKey())) {
|
if (needPlayable.containsKey(perm.getKey())) {
|
||||||
perm.getValue().setPlayable(true);
|
perm.getValue().setPlayable(true);
|
||||||
|
perm.getValue().setPlayableAmount(needPlayable.get(perm.getKey()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1271,8 +1273,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
if (needChoosen.contains(card.getKey())) {
|
if (needChoosen.contains(card.getKey())) {
|
||||||
card.getValue().setSelected(true);
|
card.getValue().setSelected(true);
|
||||||
}
|
}
|
||||||
if (needPlayable.contains(card.getKey())) {
|
if (needPlayable.containsKey(card.getKey())) {
|
||||||
card.getValue().setPlayable(true);
|
card.getValue().setPlayable(true);
|
||||||
|
card.getValue().setPlayableAmount(needPlayable.get(card.getKey()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1288,8 +1291,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
if (needChoosen.contains(card.getKey())) {
|
if (needChoosen.contains(card.getKey())) {
|
||||||
card.getValue().setSelected(true);
|
card.getValue().setSelected(true);
|
||||||
}
|
}
|
||||||
if (needPlayable.contains(card.getKey())) {
|
if (needPlayable.containsKey(card.getKey())) {
|
||||||
card.getValue().setPlayable(true);
|
card.getValue().setPlayable(true);
|
||||||
|
card.getValue().setPlayableAmount(needPlayable.get(card.getKey()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1305,8 +1309,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
if (needChoosen.contains(com.getId())) {
|
if (needChoosen.contains(com.getId())) {
|
||||||
com.setSelected(true);
|
com.setSelected(true);
|
||||||
}
|
}
|
||||||
if (needPlayable.contains(com.getId())) {
|
if (needPlayable.containsKey(com.getId())) {
|
||||||
com.setPlayable(true);
|
com.setPlayable(true);
|
||||||
|
com.setPlayableAmount(needPlayable.get(com.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1321,8 +1326,19 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
if (needChoosen.contains(card.getKey())) {
|
if (needChoosen.contains(card.getKey())) {
|
||||||
card.getValue().setSelected(true);
|
card.getValue().setSelected(true);
|
||||||
}
|
}
|
||||||
if (needPlayable.contains(card.getKey())) {
|
if (needPlayable.containsKey(card.getKey())) {
|
||||||
card.getValue().setPlayable(true);
|
card.getValue().setPlayable(true);
|
||||||
|
card.getValue().setPlayableAmount(needPlayable.get(card.getKey()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// looked at
|
||||||
|
for (LookedAtView look : gameView.getLookedAt()) {
|
||||||
|
for (Map.Entry<UUID, SimpleCardView> card : look.getCards().entrySet()) {
|
||||||
|
if (needPlayable.containsKey(card.getKey())) {
|
||||||
|
card.getValue().setPlayable(true);
|
||||||
|
card.getValue().setPlayableAmount(needPlayable.get(card.getKey()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
// can play
|
// can play
|
||||||
if (gameView != null && gameView.getCanPlayObjects() != null && !gameView.getCanPlayObjects().isEmpty()) {
|
if (gameView != null && gameView.getCanPlayObjects() != null && !gameView.getCanPlayObjects().isEmpty()) {
|
||||||
for (CardView card : cards) {
|
for (CardView card : cards) {
|
||||||
if (gameView.getCanPlayObjects().contains(card.getId())) {
|
if (gameView.getCanPlayObjects().containsKey(card.getId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
|
|
||||||
Color commandColor = Color.BLACK;
|
Color commandColor = Color.BLACK;
|
||||||
for (CommandObjectView com : player.getCommandObjectList()) {
|
for (CommandObjectView com : player.getCommandObjectList()) {
|
||||||
if (game != null && game.getCanPlayObjects() != null && game.getCanPlayObjects().contains(com.getId())) {
|
if (game != null && game.getCanPlayObjects() != null && game.getCanPlayObjects().containsKey(com.getId())) {
|
||||||
commandColor = activeValueColor;
|
commandColor = activeValueColor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
|
|
||||||
if (!MageFrame.isLite()) {
|
if (!MageFrame.isLite()) {
|
||||||
int id = player.getUserData().getAvatarId();
|
int id = player.getUserData().getAvatarId();
|
||||||
if (!(id >= 1000) && (id <= 0 || (id <= MIN_AVATAR_ID && id > MAX_AVATAR_ID))) {
|
if (!(id > 1000) && (id != 64) && (id < MIN_AVATAR_ID || id > MAX_AVATAR_ID)) {
|
||||||
id = DEFAULT_AVATAR_ID;
|
id = DEFAULT_AVATAR_ID;
|
||||||
}
|
}
|
||||||
if (id != avatarId) {
|
if (id != avatarId) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ public final class CardsViewUtil {
|
||||||
CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
|
CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
|
||||||
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
|
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
cards.put(simple.getId(), new CardView(card, simple.getId()));
|
cards.put(simple.getId(), new CardView(card, simple));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public final class CardsViewUtil {
|
||||||
loadedCards.put(key, card);
|
loadedCards.put(key, card);
|
||||||
}
|
}
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
cards.put(simple.getId(), new CardView(card, simple.getId()));
|
cards.put(simple.getId(), new CardView(card, simple));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ import java.util.stream.Collectors;
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class CardView extends SimpleCardView implements SelectableObjectView {
|
public class CardView extends SimpleCardView {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -104,9 +104,6 @@ public class CardView extends SimpleCardView implements SelectableObjectView {
|
||||||
protected boolean rotate;
|
protected boolean rotate;
|
||||||
protected boolean hideInfo; // controls if the tooltip window is shown (eg. controlled face down morph card)
|
protected boolean hideInfo; // controls if the tooltip window is shown (eg. controlled face down morph card)
|
||||||
|
|
||||||
protected boolean isPlayable;
|
|
||||||
protected boolean isChoosable;
|
|
||||||
protected boolean selected;
|
|
||||||
protected boolean canAttack;
|
protected boolean canAttack;
|
||||||
protected boolean canBlock;
|
protected boolean canBlock;
|
||||||
protected boolean inViewerOnly;
|
protected boolean inViewerOnly;
|
||||||
|
@ -117,9 +114,13 @@ public class CardView extends SimpleCardView implements SelectableObjectView {
|
||||||
this(card, null, false);
|
this(card, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardView(Card card, UUID cardId) {
|
public CardView(Card card, SimpleCardView simpleCardView) {
|
||||||
this(card, null, false);
|
this(card, null, false);
|
||||||
this.id = cardId;
|
this.id = simpleCardView.getId();
|
||||||
|
|
||||||
|
this.isPlayable = simpleCardView.isPlayable;
|
||||||
|
this.isChoosable = simpleCardView.isChoosable;
|
||||||
|
this.isSelected = simpleCardView.isSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardView(Card card, Game game, UUID cardId) {
|
public CardView(Card card, Game game, UUID cardId) {
|
||||||
|
@ -128,10 +129,12 @@ public class CardView extends SimpleCardView implements SelectableObjectView {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardView(CardView cardView) {
|
public CardView(CardView cardView) {
|
||||||
super(cardView.id, cardView.expansionSetCode, cardView.cardNumber, cardView.usesVariousArt, cardView.tokenSetCode, cardView.gameObject, cardView.tokenDescriptor);
|
super(cardView);
|
||||||
this.originalCard = cardView.originalCard;
|
this.originalCard = cardView.originalCard;
|
||||||
|
|
||||||
|
// generetate new ID
|
||||||
this.id = UUID.randomUUID();
|
this.id = UUID.randomUUID();
|
||||||
|
|
||||||
this.parentId = cardView.parentId;
|
this.parentId = cardView.parentId;
|
||||||
this.name = cardView.name;
|
this.name = cardView.name;
|
||||||
this.displayName = cardView.displayName;
|
this.displayName = cardView.displayName;
|
||||||
|
@ -198,9 +201,6 @@ public class CardView extends SimpleCardView implements SelectableObjectView {
|
||||||
this.rotate = cardView.rotate;
|
this.rotate = cardView.rotate;
|
||||||
this.hideInfo = cardView.hideInfo;
|
this.hideInfo = cardView.hideInfo;
|
||||||
|
|
||||||
this.isPlayable = cardView.isPlayable;
|
|
||||||
this.isChoosable = cardView.isChoosable;
|
|
||||||
this.selected = cardView.selected;
|
|
||||||
this.canAttack = cardView.canAttack;
|
this.canAttack = cardView.canAttack;
|
||||||
this.canBlock = cardView.canBlock;
|
this.canBlock = cardView.canBlock;
|
||||||
this.inViewerOnly = cardView.inViewerOnly;
|
this.inViewerOnly = cardView.inViewerOnly;
|
||||||
|
@ -468,8 +468,6 @@ public class CardView extends SimpleCardView implements SelectableObjectView {
|
||||||
|
|
||||||
// Get starting loyalty
|
// Get starting loyalty
|
||||||
this.startingLoyalty = "" + card.getStartingLoyalty();
|
this.startingLoyalty = "" + card.getStartingLoyalty();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardView(MageObject object) {
|
public CardView(MageObject object) {
|
||||||
|
@ -964,30 +962,6 @@ public class CardView extends SimpleCardView implements SelectableObjectView {
|
||||||
return hideInfo;
|
return hideInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayable() {
|
|
||||||
return isPlayable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayable(boolean isPlayable) {
|
|
||||||
this.isPlayable = isPlayable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isChoosable() {
|
|
||||||
return isChoosable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChoosable(boolean isChoosable) {
|
|
||||||
this.isChoosable = isChoosable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSelected() {
|
|
||||||
return selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelected(boolean selected) {
|
|
||||||
this.selected = selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCanAttack() {
|
public boolean isCanAttack() {
|
||||||
return canAttack;
|
return canAttack;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class EmblemView implements CommandObjectView, Serializable {
|
||||||
protected String expansionSetCode;
|
protected String expansionSetCode;
|
||||||
protected List<String> rules;
|
protected List<String> rules;
|
||||||
protected boolean isPlayable = false;
|
protected boolean isPlayable = false;
|
||||||
|
protected int playableAmount = 0;
|
||||||
|
|
||||||
public EmblemView(Emblem emblem, Card sourceCard) {
|
public EmblemView(Emblem emblem, Card sourceCard) {
|
||||||
this.id = emblem.getId();
|
this.id = emblem.getId();
|
||||||
|
@ -67,6 +68,16 @@ public class EmblemView implements CommandObjectView, Serializable {
|
||||||
this.isPlayable = isPlayable;
|
this.isPlayable = isPlayable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPlayableAmount(int playableAmount) {
|
||||||
|
this.playableAmount = playableAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPlayableAmount() {
|
||||||
|
return playableAmount;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChoosable() {
|
public boolean isChoosable() {
|
||||||
// unsupported
|
// unsupported
|
||||||
|
@ -85,7 +96,7 @@ public class EmblemView implements CommandObjectView, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSelected(boolean selected) {
|
public void setSelected(boolean isSelected) {
|
||||||
// unsupported
|
// unsupported
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,10 @@ import mage.watchers.common.CastSpellLastTurnWatcher;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -39,7 +42,7 @@ public class GameView implements Serializable {
|
||||||
private final int priorityTime;
|
private final int priorityTime;
|
||||||
private final List<PlayerView> players = new ArrayList<>();
|
private final List<PlayerView> players = new ArrayList<>();
|
||||||
private CardsView hand;
|
private CardsView hand;
|
||||||
private Set<UUID> canPlayObjects;
|
private Map<UUID, Integer> canPlayObjects;
|
||||||
private Map<String, SimpleCardsView> opponentHands;
|
private Map<String, SimpleCardsView> opponentHands;
|
||||||
private Map<String, SimpleCardsView> watchedHands;
|
private Map<String, SimpleCardsView> watchedHands;
|
||||||
private final CardsView stack = new CardsView();
|
private final CardsView stack = new CardsView();
|
||||||
|
@ -300,11 +303,11 @@ public class GameView implements Serializable {
|
||||||
return isPlayer;
|
return isPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<UUID> getCanPlayObjects() {
|
public Map<UUID, Integer> getCanPlayObjects() {
|
||||||
return canPlayObjects;
|
return canPlayObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCanPlayObjects(Set<UUID> canPlayObjects) {
|
public void setCanPlayObjects(Map<UUID, Integer> canPlayObjects) {
|
||||||
this.canPlayObjects = canPlayObjects;
|
this.canPlayObjects = canPlayObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ public class PlaneView implements CommandObjectView, Serializable {
|
||||||
protected List<String> rules;
|
protected List<String> rules;
|
||||||
|
|
||||||
protected boolean isPlayable = false;
|
protected boolean isPlayable = false;
|
||||||
|
protected int playableAmount = 0;
|
||||||
|
|
||||||
public PlaneView(Plane plane, Card sourceCard) {
|
public PlaneView(Plane plane, Card sourceCard) {
|
||||||
this.id = plane.getId();
|
this.id = plane.getId();
|
||||||
|
@ -67,6 +68,16 @@ public class PlaneView implements CommandObjectView, Serializable {
|
||||||
this.isPlayable = isPlayable;
|
this.isPlayable = isPlayable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPlayableAmount(int playableAmount) {
|
||||||
|
this.playableAmount = playableAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPlayableAmount() {
|
||||||
|
return playableAmount;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChoosable() {
|
public boolean isChoosable() {
|
||||||
// unsupported
|
// unsupported
|
||||||
|
@ -85,7 +96,7 @@ public class PlaneView implements CommandObjectView, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSelected(boolean selected) {
|
public void setSelected(boolean isSelected) {
|
||||||
// unsupported
|
// unsupported
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,15 @@ public interface SelectableObjectView {
|
||||||
|
|
||||||
void setPlayable(boolean isPlayable);
|
void setPlayable(boolean isPlayable);
|
||||||
|
|
||||||
|
void setPlayableAmount(int playableAmount);
|
||||||
|
|
||||||
|
int getPlayableAmount();
|
||||||
|
|
||||||
boolean isChoosable();
|
boolean isChoosable();
|
||||||
|
|
||||||
void setChoosable(boolean isChoosable);
|
void setChoosable(boolean isChoosable);
|
||||||
|
|
||||||
boolean isSelected();
|
boolean isSelected();
|
||||||
|
|
||||||
void setSelected(boolean selected);
|
void setSelected(boolean isSelected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
package mage.view;
|
package mage.view;
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
|
@ -8,10 +6,9 @@ import java.io.Serializable;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class SimpleCardView implements Serializable {
|
public class SimpleCardView implements Serializable, SelectableObjectView {
|
||||||
@Expose
|
@Expose
|
||||||
protected UUID id;
|
protected UUID id;
|
||||||
protected String expansionSetCode;
|
protected String expansionSetCode;
|
||||||
|
@ -21,9 +18,30 @@ public class SimpleCardView implements Serializable {
|
||||||
protected boolean usesVariousArt;
|
protected boolean usesVariousArt;
|
||||||
protected boolean gameObject;
|
protected boolean gameObject;
|
||||||
|
|
||||||
|
protected boolean isPlayable;
|
||||||
|
protected boolean isChoosable;
|
||||||
|
protected boolean isSelected;
|
||||||
|
protected int playableAmount; // playable abilities count on object
|
||||||
|
|
||||||
|
public SimpleCardView(final SimpleCardView view) {
|
||||||
|
this.id = view.id;
|
||||||
|
this.expansionSetCode = view.expansionSetCode;
|
||||||
|
this.tokenSetCode = view.tokenSetCode;
|
||||||
|
this.tokenDescriptor = view.tokenDescriptor;
|
||||||
|
this.cardNumber = view.cardNumber;
|
||||||
|
this.usesVariousArt = view.usesVariousArt;
|
||||||
|
this.gameObject = view.gameObject;
|
||||||
|
|
||||||
|
this.isPlayable = view.isPlayable;
|
||||||
|
this.isChoosable = view.isChoosable;
|
||||||
|
this.isSelected = view.isSelected;
|
||||||
|
this.playableAmount = view.playableAmount;
|
||||||
|
}
|
||||||
|
|
||||||
public SimpleCardView(UUID id, String expansionSetCode, String cardNumber, boolean usesVariousArt, String tokenSetCode, String tokenDescriptor) {
|
public SimpleCardView(UUID id, String expansionSetCode, String cardNumber, boolean usesVariousArt, String tokenSetCode, String tokenDescriptor) {
|
||||||
this(id, expansionSetCode, cardNumber, usesVariousArt, tokenSetCode, false, tokenDescriptor);
|
this(id, expansionSetCode, cardNumber, usesVariousArt, tokenSetCode, false, tokenDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleCardView(UUID id, String expansionSetCode, String cardNumber, boolean usesVariousArt, String tokenSetCode, boolean isGameObject, String tokenDescriptor) {
|
public SimpleCardView(UUID id, String expansionSetCode, String cardNumber, boolean usesVariousArt, String tokenSetCode, boolean isGameObject, String tokenDescriptor) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.expansionSetCode = expansionSetCode;
|
this.expansionSetCode = expansionSetCode;
|
||||||
|
@ -61,4 +79,44 @@ public class SimpleCardView implements Serializable {
|
||||||
public boolean isGameObject() {
|
public boolean isGameObject() {
|
||||||
return gameObject;
|
return gameObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPlayable() {
|
||||||
|
return isPlayable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPlayable(boolean isPlayable) {
|
||||||
|
this.isPlayable = isPlayable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPlayableAmount(int playableAmount) {
|
||||||
|
this.playableAmount = playableAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPlayableAmount() {
|
||||||
|
return playableAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isChoosable() {
|
||||||
|
return isChoosable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setChoosable(boolean isChoosable) {
|
||||||
|
this.isChoosable = isChoosable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSelected() {
|
||||||
|
return isSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSelected(boolean isSelected) {
|
||||||
|
this.isSelected = isSelected;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,7 @@ class WordOfCommandEffect extends OneShotEffect {
|
||||||
} else { // Word of Command allows the chosen card to be played "as if it had flash" so we need to invoke such effect to bypass the check
|
} else { // Word of Command allows the chosen card to be played "as if it had flash" so we need to invoke such effect to bypass the check
|
||||||
AsThoughEffectImpl effect2 = new WordOfCommandTestFlashEffect();
|
AsThoughEffectImpl effect2 = new WordOfCommandTestFlashEffect();
|
||||||
game.addEffect(effect2, source);
|
game.addEffect(effect2, source);
|
||||||
if (targetPlayer.getPlayableObjects(game, Zone.HAND).contains(card.getId())) {
|
if (targetPlayer.getPlayableObjects(game, Zone.HAND).containsKey(card.getId())) {
|
||||||
canPlay = true;
|
canPlay = true;
|
||||||
}
|
}
|
||||||
for (AsThoughEffect eff : game.getContinuousEffects().getApplicableAsThoughEffects(AsThoughEffectType.CAST_AS_INSTANT, game)) {
|
for (AsThoughEffect eff : game.getContinuousEffects().getApplicableAsThoughEffects(AsThoughEffectType.CAST_AS_INSTANT, game)) {
|
||||||
|
|
|
@ -2899,7 +2899,7 @@ public class TestPlayer implements Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> getPlayableObjects(Game game, Zone zone) {
|
public Map<UUID, Integer> getPlayableObjects(Game game, Zone zone) {
|
||||||
return computerPlayer.getPlayableObjects(game, zone);
|
return computerPlayer.getPlayableObjects(game, zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1048,7 +1048,7 @@ public class PlayerStub implements Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> getPlayableObjects(Game game, Zone zone) {
|
public Map<UUID, Integer> getPlayableObjects(Game game, Zone zone) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -637,7 +637,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
|
|
||||||
List<Ability> getPlayableOptions(Ability ability, Game game);
|
List<Ability> getPlayableOptions(Ability ability, Game game);
|
||||||
|
|
||||||
Set<UUID> getPlayableObjects(Game game, Zone zone);
|
Map<UUID, Integer> getPlayableObjects(Game game, Zone zone);
|
||||||
|
|
||||||
LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game);
|
LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package mage.players;
|
package mage.players;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import mage.ConditionalMana;
|
import mage.ConditionalMana;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
|
@ -68,6 +65,10 @@ import mage.util.GameLog;
|
||||||
import mage.util.RandomUtil;
|
import mage.util.RandomUtil;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public abstract class PlayerImpl implements Player, Serializable {
|
public abstract class PlayerImpl implements Player, Serializable {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(PlayerImpl.class);
|
private static final Logger logger = Logger.getLogger(PlayerImpl.class);
|
||||||
|
@ -3461,24 +3462,24 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
/**
|
/**
|
||||||
* Creates a list of card ids that are currently playable.<br>
|
* Creates a list of card ids that are currently playable.<br>
|
||||||
* Used to mark the playable cards in GameView
|
* Used to mark the playable cards in GameView
|
||||||
|
* Also contains number of playable abilities for that object (it's just info, server decides to show choose dialog or not)
|
||||||
*
|
*
|
||||||
* @param game
|
* @param game
|
||||||
* @return A Set of cardIds that are playable
|
* @return A Set of cardIds that are playable and amount of playable abilities
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> getPlayableObjects(Game game, Zone zone) {
|
public Map<UUID, Integer> getPlayableObjects(Game game, Zone zone) {
|
||||||
|
List<Ability> playableAbilities = getPlayable(game, true, zone, false); // do not hide duplicated abilities/cards
|
||||||
List<Ability> playableAbilities = getPlayable(game, true, zone, false); // do not hide duplicated abilities
|
Map<UUID, Integer> playableObjects = new HashMap<>();
|
||||||
Set<UUID> playableObjects = new HashSet<>();
|
|
||||||
for (Ability ability : playableAbilities) {
|
for (Ability ability : playableAbilities) {
|
||||||
if (ability.getSourceId() != null) {
|
if (ability.getSourceId() != null) {
|
||||||
playableObjects.add(ability.getSourceId());
|
playableObjects.put(ability.getSourceId(), playableObjects.getOrDefault(ability.getSourceId(), 0) + 1);
|
||||||
|
|
||||||
// main card must be marked playable in GUI
|
// main card must be marked playable in GUI
|
||||||
Card card = game.getCard(ability.getSourceId());
|
Card card = game.getCard(ability.getSourceId());
|
||||||
if (card != null && card.getMainCard().getId() != card.getId()) {
|
if (card != null && card.getMainCard().getId() != card.getId()) {
|
||||||
UUID mainCardId = card.getMainCard().getId();
|
UUID mainCardId = card.getMainCard().getId();
|
||||||
playableObjects.add(mainCardId);
|
playableObjects.put(mainCardId, playableObjects.getOrDefault(mainCardId, 0) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue