Refactor cards and token images code (#10139):

- removed outdated token store format (example: BIRD.W.BIRD.CREATURE.1.1.full.jpg)
 - removed duplicated cache images code;
 - removed duplicated set code fields;
 - removed outdated auto-generated thumb files (also all *.thumb.zip files will be deleted on startup);
This commit is contained in:
Oleg Agafonov 2023-03-24 06:44:11 +04:00
parent d93e533c75
commit 66d0ef4b35
25 changed files with 333 additions and 634 deletions

View file

@ -273,7 +273,7 @@ public class CardView extends SimpleCardView {
* @param storeZone if true the card zone will be set in the zone attribute.
*/
public CardView(Card card, Game game, boolean controlled, boolean showFaceDownCard, boolean storeZone) {
super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode(), game != null, card.getTokenDescriptor());
super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), game != null);
this.originalCard = card;
// no information available for face down cards as long it's not a controlled face down morph card
@ -487,7 +487,6 @@ public class CardView extends SimpleCardView {
} else {
// a created token
this.expansionSetCode = card.getExpansionSetCode();
this.tokenDescriptor = card.getTokenDescriptor();
}
//
// set code and card number for token copies to get the image
@ -600,7 +599,7 @@ public class CardView extends SimpleCardView {
}
public CardView(MageObject object, Game game) {
super(object.getId(), "", "0", false, "", true, "");
super(object.getId(), "", "0", false, true);
this.originalCard = null;
this.name = object.getName();
@ -674,7 +673,7 @@ public class CardView extends SimpleCardView {
}
protected CardView() {
super(null, "", "0", false, "", true, "");
super(null, "", "0", false, true);
}
public CardView(EmblemView emblem) {
@ -739,7 +738,7 @@ public class CardView extends SimpleCardView {
}
public CardView(boolean empty) {
super(null, "", "0", false, "", "");
super(null, "", "0", false);
if (!empty) {
throw new IllegalArgumentException("Not supported.");
}
@ -793,9 +792,10 @@ public class CardView extends SimpleCardView {
}
CardView(Token token, Game game) {
super(token.getId(), "", "0", false, "", "");
super(token.getId(), "", "0", false);
this.isToken = true;
this.id = token.getId();
this.expansionSetCode = token.getOriginalExpansionSetCode();
this.name = token.getName();
this.displayName = token.getName();
this.displayFullName = token.getName();
@ -814,8 +814,6 @@ public class CardView extends SimpleCardView {
this.manaCostRightStr = "";
this.rarity = Rarity.SPECIAL;
this.type = token.getTokenType();
this.tokenDescriptor = token.getTokenDescriptor();
this.tokenSetCode = token.getOriginalExpansionSetCode();
}
protected final void addTargets(Targets targets, Effects effects, Ability source, Game game) {

View file

@ -20,7 +20,7 @@ public class LookedAtView implements Serializable {
public LookedAtView(String name, Cards cards, Game game) {
this.name = name;
for (Card card: cards.getCards(game)) {
this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode(), card.getTokenDescriptor()));
this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt()));
}
}

View file

@ -54,8 +54,7 @@ public class PermanentView extends CardView {
if (isToken()) {
original = new CardView(((PermanentToken) permanent).getToken().copy(), (Game) null);
original.expansionSetCode = permanent.getExpansionSetCode();
tokenSetCode = original.getTokenSetCode();
tokenDescriptor = original.getTokenDescriptor();
expansionSetCode = permanent.getExpansionSetCode();
} else {
if (card != null) {
// original may not be face down

View file

@ -13,8 +13,6 @@ public class SimpleCardView implements Serializable, SelectableObjectView {
@Expose
protected UUID id;
protected String expansionSetCode;
protected String tokenSetCode;
protected String tokenDescriptor;
protected String cardNumber;
protected boolean usesVariousArt;
protected boolean gameObject;
@ -26,28 +24,23 @@ public class SimpleCardView implements Serializable, SelectableObjectView {
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.isChoosable = view.isChoosable;
this.isSelected = view.isSelected;
this.playableStats = view.playableStats.copy();
}
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) {
this(id, expansionSetCode, cardNumber, usesVariousArt, false);
}
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, boolean isGameObject) {
this.id = id;
this.expansionSetCode = expansionSetCode;
this.tokenDescriptor = tokenDescriptor;
this.cardNumber = cardNumber;
this.usesVariousArt = usesVariousArt;
this.tokenSetCode = tokenSetCode;
this.gameObject = isGameObject;
}
@ -67,14 +60,6 @@ public class SimpleCardView implements Serializable, SelectableObjectView {
return usesVariousArt;
}
public String getTokenSetCode() {
return tokenSetCode;
}
public String getTokenDescriptor() {
return tokenDescriptor;
}
public boolean isGameObject() {
return gameObject;
}

View file

@ -18,8 +18,7 @@ public class SimpleCardsView extends LinkedHashMap<UUID, SimpleCardView> {
public SimpleCardsView(Collection<Card> cards, boolean isGameObject) {
for (Card card: cards) {
this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode(), isGameObject,
card.getTokenDescriptor()));
this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), isGameObject));
}
}