* UI: added playable card marks in look-at windows;

This commit is contained in:
Oleg Agafonov 2019-12-18 22:44:42 +04:00
parent ff1299cca9
commit cde9957f54
15 changed files with 200 additions and 122 deletions

View file

@ -32,7 +32,7 @@ import java.util.stream.Collectors;
/**
* @author BetaSteward_at_googlemail.com
*/
public class CardView extends SimpleCardView implements SelectableObjectView {
public class CardView extends SimpleCardView {
private static final long serialVersionUID = 1L;
@ -104,9 +104,6 @@ public class CardView extends SimpleCardView implements SelectableObjectView {
protected boolean rotate;
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 canBlock;
protected boolean inViewerOnly;
@ -117,9 +114,13 @@ public class CardView extends SimpleCardView implements SelectableObjectView {
this(card, null, false);
}
public CardView(Card card, UUID cardId) {
public CardView(Card card, SimpleCardView simpleCardView) {
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) {
@ -128,10 +129,12 @@ public class CardView extends SimpleCardView implements SelectableObjectView {
}
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;
// generetate new ID
this.id = UUID.randomUUID();
this.parentId = cardView.parentId;
this.name = cardView.name;
this.displayName = cardView.displayName;
@ -198,9 +201,6 @@ public class CardView extends SimpleCardView implements SelectableObjectView {
this.rotate = cardView.rotate;
this.hideInfo = cardView.hideInfo;
this.isPlayable = cardView.isPlayable;
this.isChoosable = cardView.isChoosable;
this.selected = cardView.selected;
this.canAttack = cardView.canAttack;
this.canBlock = cardView.canBlock;
this.inViewerOnly = cardView.inViewerOnly;
@ -468,8 +468,6 @@ public class CardView extends SimpleCardView implements SelectableObjectView {
// Get starting loyalty
this.startingLoyalty = "" + card.getStartingLoyalty();
}
public CardView(MageObject object) {
@ -964,30 +962,6 @@ public class CardView extends SimpleCardView implements SelectableObjectView {
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() {
return canAttack;
}

View file

@ -17,6 +17,7 @@ public class EmblemView implements CommandObjectView, Serializable {
protected String expansionSetCode;
protected List<String> rules;
protected boolean isPlayable = false;
protected int playableAmount = 0;
public EmblemView(Emblem emblem, Card sourceCard) {
this.id = emblem.getId();
@ -67,6 +68,16 @@ public class EmblemView implements CommandObjectView, Serializable {
this.isPlayable = isPlayable;
}
@Override
public void setPlayableAmount(int playableAmount) {
this.playableAmount = playableAmount;
}
@Override
public int getPlayableAmount() {
return playableAmount;
}
@Override
public boolean isChoosable() {
// unsupported
@ -85,7 +96,7 @@ public class EmblemView implements CommandObjectView, Serializable {
}
@Override
public void setSelected(boolean selected) {
public void setSelected(boolean isSelected) {
// unsupported
}
}

View file

@ -26,7 +26,10 @@ import mage.watchers.common.CastSpellLastTurnWatcher;
import org.apache.log4j.Logger;
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
@ -39,7 +42,7 @@ public class GameView implements Serializable {
private final int priorityTime;
private final List<PlayerView> players = new ArrayList<>();
private CardsView hand;
private Set<UUID> canPlayObjects;
private Map<UUID, Integer> canPlayObjects;
private Map<String, SimpleCardsView> opponentHands;
private Map<String, SimpleCardsView> watchedHands;
private final CardsView stack = new CardsView();
@ -300,11 +303,11 @@ public class GameView implements Serializable {
return isPlayer;
}
public Set<UUID> getCanPlayObjects() {
public Map<UUID, Integer> getCanPlayObjects() {
return canPlayObjects;
}
public void setCanPlayObjects(Set<UUID> canPlayObjects) {
public void setCanPlayObjects(Map<UUID, Integer> canPlayObjects) {
this.canPlayObjects = canPlayObjects;
}

View file

@ -18,6 +18,7 @@ public class PlaneView implements CommandObjectView, Serializable {
protected List<String> rules;
protected boolean isPlayable = false;
protected int playableAmount = 0;
public PlaneView(Plane plane, Card sourceCard) {
this.id = plane.getId();
@ -67,6 +68,16 @@ public class PlaneView implements CommandObjectView, Serializable {
this.isPlayable = isPlayable;
}
@Override
public void setPlayableAmount(int playableAmount) {
this.playableAmount = playableAmount;
}
@Override
public int getPlayableAmount() {
return playableAmount;
}
@Override
public boolean isChoosable() {
// unsupported
@ -85,7 +96,7 @@ public class PlaneView implements CommandObjectView, Serializable {
}
@Override
public void setSelected(boolean selected) {
public void setSelected(boolean isSelected) {
// unsupported
}
}

View file

@ -9,11 +9,15 @@ public interface SelectableObjectView {
void setPlayable(boolean isPlayable);
void setPlayableAmount(int playableAmount);
int getPlayableAmount();
boolean isChoosable();
void setChoosable(boolean isChoosable);
boolean isSelected();
void setSelected(boolean selected);
void setSelected(boolean isSelected);
}

View file

@ -1,5 +1,3 @@
package mage.view;
import com.google.gson.annotations.Expose;
@ -8,10 +6,9 @@ import java.io.Serializable;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class SimpleCardView implements Serializable {
public class SimpleCardView implements Serializable, SelectableObjectView {
@Expose
protected UUID id;
protected String expansionSetCode;
@ -21,9 +18,30 @@ public class SimpleCardView implements Serializable {
protected boolean usesVariousArt;
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) {
this(id, expansionSetCode, cardNumber, usesVariousArt, tokenSetCode, false, tokenDescriptor);
}
public SimpleCardView(UUID id, String expansionSetCode, String cardNumber, boolean usesVariousArt, String tokenSetCode, boolean isGameObject, String tokenDescriptor) {
this.id = id;
this.expansionSetCode = expansionSetCode;
@ -53,12 +71,52 @@ public class SimpleCardView implements Serializable {
public String getTokenSetCode() {
return tokenSetCode;
}
public String getTokenDescriptor() {
return tokenDescriptor;
}
public boolean isGameObject() {
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;
}
}