mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
Tokens and command objects reworked (part 1 of 2):
- fixed that copy effect doesn't restore original image after effect's end; - removed outdated availableImageSetCodes (all images auto-selected from tokens database now, related to #10139); - refactor command objects to use CommandObjectImpl; - refactor planes/emblems/etc objects to use MageObjectImpl, added copyable support; - refactor another game objects to remove some duplicated fields;
This commit is contained in:
parent
46f6593da8
commit
5f55c7c667
45 changed files with 517 additions and 477 deletions
|
|
@ -241,9 +241,8 @@ public class MageBook extends JComponent {
|
||||||
Constructor<?> cons = c.getConstructor();
|
Constructor<?> cons = c.getConstructor();
|
||||||
Object newToken = cons.newInstance();
|
Object newToken = cons.newInstance();
|
||||||
if (newToken instanceof Token) {
|
if (newToken instanceof Token) {
|
||||||
((Token) newToken).setOriginalExpansionSetCode(currentSet);
|
((Token) newToken).setExpansionSetCode(currentSet);
|
||||||
((Token) newToken).setExpansionSetCodeForImage(currentSet);
|
((Token) newToken).setImageNumber(token.getImageNumber());
|
||||||
((Token) newToken).setTokenType(token.getImageNumber()); // must be called after set code, so it keep the type
|
|
||||||
res.add(newToken);
|
res.add(newToken);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -262,7 +261,7 @@ public class MageBook extends JComponent {
|
||||||
Constructor<?> cons = c.getConstructor();
|
Constructor<?> cons = c.getConstructor();
|
||||||
Object newEmblem = cons.newInstance();
|
Object newEmblem = cons.newInstance();
|
||||||
if (newEmblem instanceof Emblem) {
|
if (newEmblem instanceof Emblem) {
|
||||||
((Emblem) newEmblem).setExpansionSetCodeForImage(currentSet);
|
((Emblem) newEmblem).setExpansionSetCode(currentSet);
|
||||||
res.add(newEmblem);
|
res.add(newEmblem);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -281,7 +280,7 @@ public class MageBook extends JComponent {
|
||||||
Constructor<?> cons = c.getConstructor();
|
Constructor<?> cons = c.getConstructor();
|
||||||
Object newPlane = cons.newInstance();
|
Object newPlane = cons.newInstance();
|
||||||
if (newPlane instanceof Plane) {
|
if (newPlane instanceof Plane) {
|
||||||
((Plane) newPlane).setExpansionSetCodeForImage(currentSet);
|
((Plane) newPlane).setExpansionSetCode(currentSet);
|
||||||
res.add(newPlane);
|
res.add(newPlane);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -300,7 +299,7 @@ public class MageBook extends JComponent {
|
||||||
Constructor<?> cons = c.getConstructor();
|
Constructor<?> cons = c.getConstructor();
|
||||||
Object newDungeon = cons.newInstance();
|
Object newDungeon = cons.newInstance();
|
||||||
if (newDungeon instanceof Dungeon) {
|
if (newDungeon instanceof Dungeon) {
|
||||||
((Dungeon) newDungeon).setExpansionSetCodeForImage(currentSet);
|
((Dungeon) newDungeon).setExpansionSetCode(currentSet);
|
||||||
res.add(newDungeon);
|
res.add(newDungeon);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -213,8 +213,7 @@ public class TestCardRenderDialog extends MageDialog {
|
||||||
|
|
||||||
private CardView createToken(Game game, UUID controllerId, Token token, String code, int damage, boolean tapped, boolean transformed) {
|
private CardView createToken(Game game, UUID controllerId, Token token, String code, int damage, boolean tapped, boolean transformed) {
|
||||||
Token sourceToken = token.copy();
|
Token sourceToken = token.copy();
|
||||||
sourceToken.setExpansionSetCodeForImage(code);
|
sourceToken.setExpansionSetCode(code);
|
||||||
sourceToken.setOriginalExpansionSetCode(code);
|
|
||||||
|
|
||||||
PermanentToken perm = new PermanentToken(sourceToken, controllerId, game);
|
PermanentToken perm = new PermanentToken(sourceToken, controllerId, game);
|
||||||
Set<Card> cardsList = new HashSet<>();
|
Set<Card> cardsList = new HashSet<>();
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ public class CardPanelRenderModeMTGO extends CardPanel {
|
||||||
sb.append(this.view.getLoyalty());
|
sb.append(this.view.getLoyalty());
|
||||||
sb.append(this.view.getDefense());
|
sb.append(this.view.getDefense());
|
||||||
sb.append(this.view.getColor().toString());
|
sb.append(this.view.getColor().toString());
|
||||||
sb.append(this.view.getType());
|
sb.append(this.view.getImageNumber());
|
||||||
sb.append(this.view.getExpansionSetCode());
|
sb.append(this.view.getExpansionSetCode());
|
||||||
for (CardType type : this.view.getCardTypes()) {
|
for (CardType type : this.view.getCardTypes()) {
|
||||||
sb.append((char) type.ordinal());
|
sb.append((char) type.ordinal());
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ public class ModernCardRenderer extends CardRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getTypeLineYFrac() {
|
private float getTypeLineYFrac() {
|
||||||
if (cardView.isToken() && cardView.getCardNumber() == null) {
|
if (cardView.isToken() && cardView.getCardNumber().isEmpty()) {
|
||||||
return TYPE_LINE_Y_FRAC_TOKEN;
|
return TYPE_LINE_Y_FRAC_TOKEN;
|
||||||
} else if (cardView.getFrameStyle().isFullArt()) {
|
} else if (cardView.getFrameStyle().isFullArt()) {
|
||||||
return TYPE_LINE_Y_FRAC_FULL_ART;
|
return TYPE_LINE_Y_FRAC_FULL_ART;
|
||||||
|
|
|
||||||
|
|
@ -344,7 +344,7 @@ public final class ImageCache {
|
||||||
private static String getKey(CardView card, String cardName, int imageSize) {
|
private static String getKey(CardView card, String cardName, int imageSize) {
|
||||||
return (card.isToken() ? cardName.replace(" Token", "") : cardName)
|
return (card.isToken() ? cardName.replace(" Token", "") : cardName)
|
||||||
+ '#' + card.getExpansionSetCode()
|
+ '#' + card.getExpansionSetCode()
|
||||||
+ '#' + card.getType()
|
+ '#' + card.getImageNumber()
|
||||||
+ '#' + card.getCardNumber()
|
+ '#' + card.getCardNumber()
|
||||||
+ '#' + imageSize
|
+ '#' + imageSize
|
||||||
+ (card.getUsesVariousArt() ? "#usesVariousArt" : "");
|
+ (card.getUsesVariousArt() ? "#usesVariousArt" : "");
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public class CardView extends SimpleCardView {
|
||||||
|
|
||||||
protected UUID parentId;
|
protected UUID parentId;
|
||||||
@Expose
|
@Expose
|
||||||
protected String name;
|
protected String name; // TODO: remove duplicated field name/displayName???
|
||||||
@Expose
|
@Expose
|
||||||
protected String displayName;
|
protected String displayName;
|
||||||
@Expose
|
@Expose
|
||||||
|
|
@ -88,7 +88,7 @@ public class CardView extends SimpleCardView {
|
||||||
protected boolean isToken;
|
protected boolean isToken;
|
||||||
|
|
||||||
protected CardView ability;
|
protected CardView ability;
|
||||||
protected int type;
|
protected int imageNumber;
|
||||||
|
|
||||||
protected boolean transformable; // can toggle one card side to another (transformable cards, modal double faces)
|
protected boolean transformable; // can toggle one card side to another (transformable cards, modal double faces)
|
||||||
protected CardView secondCardFace;
|
protected CardView secondCardFace;
|
||||||
|
|
@ -182,6 +182,10 @@ public class CardView extends SimpleCardView {
|
||||||
this.subTypes = new SubTypes(cardView.subTypes);
|
this.subTypes = new SubTypes(cardView.subTypes);
|
||||||
this.superTypes = cardView.superTypes;
|
this.superTypes = cardView.superTypes;
|
||||||
|
|
||||||
|
this.expansionSetCode = cardView.expansionSetCode;
|
||||||
|
this.cardNumber = cardView.cardNumber;
|
||||||
|
this.imageNumber = cardView.imageNumber;
|
||||||
|
|
||||||
this.color = cardView.color.copy();
|
this.color = cardView.color.copy();
|
||||||
this.frameColor = cardView.frameColor.copy();
|
this.frameColor = cardView.frameColor.copy();
|
||||||
this.frameStyle = cardView.frameStyle;
|
this.frameStyle = cardView.frameStyle;
|
||||||
|
|
@ -195,7 +199,6 @@ public class CardView extends SimpleCardView {
|
||||||
this.abilityType = cardView.abilityType;
|
this.abilityType = cardView.abilityType;
|
||||||
this.isToken = cardView.isToken;
|
this.isToken = cardView.isToken;
|
||||||
this.ability = cardView.ability; // reference, not copy
|
this.ability = cardView.ability; // reference, not copy
|
||||||
this.type = cardView.type;
|
|
||||||
|
|
||||||
this.transformable = cardView.transformable;
|
this.transformable = cardView.transformable;
|
||||||
this.secondCardFace = cardView.secondCardFace == null ? null : new CardView(cardView.secondCardFace);
|
this.secondCardFace = cardView.secondCardFace == null ? null : new CardView(cardView.secondCardFace);
|
||||||
|
|
@ -281,6 +284,7 @@ public class CardView extends SimpleCardView {
|
||||||
public CardView(Card card, Game game, boolean controlled, boolean showFaceDownCard, boolean storeZone) {
|
public CardView(Card card, Game game, boolean controlled, boolean showFaceDownCard, boolean storeZone) {
|
||||||
super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), game != null);
|
super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), game != null);
|
||||||
this.originalObject = card;
|
this.originalObject = card;
|
||||||
|
this.imageNumber = card.getImageNumber();
|
||||||
|
|
||||||
// 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
|
||||||
|
|
@ -305,6 +309,7 @@ public class CardView extends SimpleCardView {
|
||||||
if (!showFaceUp) {
|
if (!showFaceUp) {
|
||||||
this.fillEmpty(card, controlled);
|
this.fillEmpty(card, controlled);
|
||||||
if (card instanceof Spell) {
|
if (card instanceof Spell) {
|
||||||
|
// TODO: add face down image here???
|
||||||
// special handling for casting of Morph cards
|
// special handling for casting of Morph cards
|
||||||
if (controlled) {
|
if (controlled) {
|
||||||
this.name = card.getName();
|
this.name = card.getName();
|
||||||
|
|
@ -391,7 +396,7 @@ public class CardView extends SimpleCardView {
|
||||||
this.manaCostRightStr = "";
|
this.manaCostRightStr = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.name = card.getImageName();
|
this.name = card.getName();
|
||||||
this.displayName = card.getName();
|
this.displayName = card.getName();
|
||||||
this.displayFullName = fullCardName;
|
this.displayFullName = fullCardName;
|
||||||
this.rules = new ArrayList<>(card.getRules(game));
|
this.rules = new ArrayList<>(card.getRules(game));
|
||||||
|
|
@ -483,19 +488,7 @@ public class CardView extends SimpleCardView {
|
||||||
this.isToken = true;
|
this.isToken = true;
|
||||||
this.mageObjectType = MageObjectType.TOKEN;
|
this.mageObjectType = MageObjectType.TOKEN;
|
||||||
this.rarity = Rarity.COMMON;
|
this.rarity = Rarity.COMMON;
|
||||||
boolean originalCardNumberIsNull = ((PermanentToken) card).getToken().getOriginalCardNumber() == null;
|
|
||||||
if (!originalCardNumberIsNull && !"0".equals(((PermanentToken) card).getToken().getOriginalCardNumber())) {
|
|
||||||
// a token copied from permanent
|
|
||||||
this.expansionSetCode = ((PermanentToken) card).getToken().getOriginalExpansionSetCode();
|
|
||||||
this.cardNumber = ((PermanentToken) card).getToken().getOriginalCardNumber();
|
|
||||||
} else {
|
|
||||||
// a created token
|
|
||||||
this.expansionSetCode = card.getExpansionSetCode();
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// set code and card number for token copies to get the image
|
|
||||||
this.rules = new ArrayList<>(card.getRules(game));
|
this.rules = new ArrayList<>(card.getRules(game));
|
||||||
this.type = ((PermanentToken) card).getToken().getTokenType();
|
|
||||||
} else {
|
} else {
|
||||||
this.rarity = card.getRarity();
|
this.rarity = card.getRarity();
|
||||||
this.isToken = false;
|
this.isToken = false;
|
||||||
|
|
@ -612,9 +605,10 @@ public class CardView extends SimpleCardView {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardView(MageObject object, Game game) {
|
public CardView(MageObject object, Game game) {
|
||||||
super(object.getId(), "", "0", false, true);
|
super(object.getId(), object.getExpansionSetCode(), object.getCardNumber(), false, true);
|
||||||
this.originalObject = object;
|
this.originalObject = object;
|
||||||
|
|
||||||
|
this.imageNumber = object.getImageNumber();
|
||||||
this.name = object.getName();
|
this.name = object.getName();
|
||||||
this.displayName = object.getName();
|
this.displayName = object.getName();
|
||||||
this.displayFullName = object.getName();
|
this.displayFullName = object.getName();
|
||||||
|
|
@ -641,9 +635,7 @@ public class CardView extends SimpleCardView {
|
||||||
this.mageObjectType = MageObjectType.TOKEN;
|
this.mageObjectType = MageObjectType.TOKEN;
|
||||||
PermanentToken permanentToken = (PermanentToken) object;
|
PermanentToken permanentToken = (PermanentToken) object;
|
||||||
this.rarity = Rarity.COMMON;
|
this.rarity = Rarity.COMMON;
|
||||||
this.expansionSetCode = permanentToken.getExpansionSetCode();
|
|
||||||
this.rules = new ArrayList<>(permanentToken.getRules(game));
|
this.rules = new ArrayList<>(permanentToken.getRules(game));
|
||||||
this.type = permanentToken.getToken().getTokenType();
|
|
||||||
} else if (object instanceof Emblem) {
|
} else if (object instanceof Emblem) {
|
||||||
this.mageObjectType = MageObjectType.EMBLEM;
|
this.mageObjectType = MageObjectType.EMBLEM;
|
||||||
Emblem emblem = (Emblem) object;
|
Emblem emblem = (Emblem) object;
|
||||||
|
|
@ -675,9 +667,6 @@ public class CardView extends SimpleCardView {
|
||||||
this.rarity = Rarity.SPECIAL;
|
this.rarity = Rarity.SPECIAL;
|
||||||
this.rules = new ArrayList<>();
|
this.rules = new ArrayList<>();
|
||||||
this.rules.add(stackAbility.getRule());
|
this.rules.add(stackAbility.getRule());
|
||||||
if (stackAbility.getZone() == Zone.COMMAND) {
|
|
||||||
this.expansionSetCode = stackAbility.getExpansionSetCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Frame color
|
// Frame color
|
||||||
this.frameColor = object.getFrameColor(game).copy();
|
this.frameColor = object.getFrameColor(game).copy();
|
||||||
|
|
@ -706,6 +695,8 @@ public class CardView extends SimpleCardView {
|
||||||
// emblem images are always with common (black) symbol
|
// emblem images are always with common (black) symbol
|
||||||
this.frameStyle = FrameStyle.M15_NORMAL;
|
this.frameStyle = FrameStyle.M15_NORMAL;
|
||||||
this.expansionSetCode = emblem.getExpansionSetCode();
|
this.expansionSetCode = emblem.getExpansionSetCode();
|
||||||
|
this.cardNumber = "";
|
||||||
|
this.imageNumber = 0;
|
||||||
this.rarity = Rarity.COMMON;
|
this.rarity = Rarity.COMMON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -722,6 +713,8 @@ public class CardView extends SimpleCardView {
|
||||||
// emblem images are always with common (black) symbol
|
// emblem images are always with common (black) symbol
|
||||||
this.frameStyle = FrameStyle.M15_NORMAL;
|
this.frameStyle = FrameStyle.M15_NORMAL;
|
||||||
this.expansionSetCode = dungeon.getExpansionSetCode();
|
this.expansionSetCode = dungeon.getExpansionSetCode();
|
||||||
|
this.cardNumber = "";
|
||||||
|
this.imageNumber = 0;
|
||||||
this.rarity = Rarity.COMMON;
|
this.rarity = Rarity.COMMON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -739,6 +732,8 @@ public class CardView extends SimpleCardView {
|
||||||
this.rotate = true;
|
this.rotate = true;
|
||||||
this.frameStyle = FrameStyle.M15_NORMAL;
|
this.frameStyle = FrameStyle.M15_NORMAL;
|
||||||
this.expansionSetCode = plane.getExpansionSetCode();
|
this.expansionSetCode = plane.getExpansionSetCode();
|
||||||
|
this.cardNumber = "";
|
||||||
|
this.imageNumber = 0;
|
||||||
this.rarity = Rarity.COMMON;
|
this.rarity = Rarity.COMMON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -754,7 +749,10 @@ public class CardView extends SimpleCardView {
|
||||||
this.rules = new ArrayList<>();
|
this.rules = new ArrayList<>();
|
||||||
this.rules.add(stackAbility.getRule(designation.getName()));
|
this.rules.add(stackAbility.getRule(designation.getName()));
|
||||||
this.frameStyle = FrameStyle.M15_NORMAL;
|
this.frameStyle = FrameStyle.M15_NORMAL;
|
||||||
this.expansionSetCode = designation.getExpansionSetCodeForImage();
|
this.cardNumber = designation.getCardNumber();
|
||||||
|
this.expansionSetCode = designation.getExpansionSetCode();
|
||||||
|
this.cardNumber = "";
|
||||||
|
this.imageNumber = 0;
|
||||||
this.rarity = Rarity.COMMON;
|
this.rarity = Rarity.COMMON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -793,6 +791,7 @@ public class CardView extends SimpleCardView {
|
||||||
this.rarity = Rarity.COMMON;
|
this.rarity = Rarity.COMMON;
|
||||||
this.expansionSetCode = "";
|
this.expansionSetCode = "";
|
||||||
this.cardNumber = "0";
|
this.cardNumber = "0";
|
||||||
|
this.imageNumber = 0;
|
||||||
} else {
|
} else {
|
||||||
this.rarity = card.getRarity();
|
this.rarity = card.getRarity();
|
||||||
}
|
}
|
||||||
|
|
@ -819,7 +818,6 @@ public class CardView extends SimpleCardView {
|
||||||
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.expansionSetCode = token.getOriginalExpansionSetCode();
|
|
||||||
this.name = token.getName();
|
this.name = token.getName();
|
||||||
this.displayName = token.getName();
|
this.displayName = token.getName();
|
||||||
this.displayFullName = token.getName();
|
this.displayFullName = token.getName();
|
||||||
|
|
@ -839,7 +837,11 @@ public class CardView extends SimpleCardView {
|
||||||
this.manaCostLeftStr = String.join("", token.getManaCostSymbols());
|
this.manaCostLeftStr = String.join("", token.getManaCostSymbols());
|
||||||
this.manaCostRightStr = "";
|
this.manaCostRightStr = "";
|
||||||
this.rarity = Rarity.SPECIAL;
|
this.rarity = Rarity.SPECIAL;
|
||||||
this.type = token.getTokenType();
|
|
||||||
|
// source object is a token, so no card number
|
||||||
|
this.expansionSetCode = token.getExpansionSetCode();
|
||||||
|
this.cardNumber = token.getCardNumber();
|
||||||
|
this.imageNumber = token.getImageNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void addTargets(Targets targets, Effects effects, Ability source, Game game) {
|
protected final void addTargets(Targets targets, Effects effects, Ability source, Game game) {
|
||||||
|
|
@ -995,10 +997,6 @@ public class CardView extends SimpleCardView {
|
||||||
return expansionSetCode;
|
return expansionSetCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExpansionSetCode(String expansionSetCode) {
|
|
||||||
this.expansionSetCode = expansionSetCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|
@ -1135,8 +1133,8 @@ public class CardView extends SimpleCardView {
|
||||||
return bandedCards;
|
return bandedCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getType() {
|
public int getImageNumber() {
|
||||||
return type;
|
return imageNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MageObjectType getMageObjectType() {
|
public MageObjectType getMageObjectType() {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ public class DungeonView implements CommandObjectView, Serializable {
|
||||||
public DungeonView(Dungeon dungeon) {
|
public DungeonView(Dungeon dungeon) {
|
||||||
this.id = dungeon.getId();
|
this.id = dungeon.getId();
|
||||||
this.name = dungeon.getName();
|
this.name = dungeon.getName();
|
||||||
this.expansionSetCode = dungeon.getExpansionSetCodeForImage();
|
this.expansionSetCode = dungeon.getExpansionSetCode();
|
||||||
this.rules = dungeon.getRules();
|
this.rules = dungeon.getRules();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,21 +19,10 @@ public class EmblemView implements CommandObjectView, Serializable {
|
||||||
protected List<String> rules;
|
protected List<String> rules;
|
||||||
protected PlayableObjectStats playableStats = new PlayableObjectStats();
|
protected PlayableObjectStats playableStats = new PlayableObjectStats();
|
||||||
|
|
||||||
public EmblemView(Emblem emblem, Card sourceCard) {
|
|
||||||
this.id = emblem.getId();
|
|
||||||
this.name = "Emblem " + sourceCard.getName();
|
|
||||||
if (emblem.getExpansionSetCodeForImage() == null) {
|
|
||||||
this.expansionSetCode = sourceCard.getExpansionSetCode();
|
|
||||||
} else {
|
|
||||||
this.expansionSetCode = emblem.getExpansionSetCodeForImage();
|
|
||||||
}
|
|
||||||
this.rules = emblem.getAbilities().getRules(sourceCard.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmblemView(Emblem emblem) {
|
public EmblemView(Emblem emblem) {
|
||||||
this.id = emblem.getId();
|
this.id = emblem.getId();
|
||||||
this.name = emblem.getName();
|
this.name = emblem.getName();
|
||||||
this.expansionSetCode = emblem.getExpansionSetCodeForImage();
|
this.expansionSetCode = emblem.getExpansionSetCode();
|
||||||
this.rules = emblem.getAbilities().getRules(emblem.getName());
|
this.rules = emblem.getAbilities().getRules(emblem.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,21 +19,10 @@ public class PlaneView implements CommandObjectView, Serializable {
|
||||||
protected List<String> rules;
|
protected List<String> rules;
|
||||||
protected PlayableObjectStats playableStats = new PlayableObjectStats();
|
protected PlayableObjectStats playableStats = new PlayableObjectStats();
|
||||||
|
|
||||||
public PlaneView(Plane plane, Card sourceCard) {
|
|
||||||
this.id = plane.getId();
|
|
||||||
this.name = "Plane " + sourceCard.getName();
|
|
||||||
if (plane.getExpansionSetCodeForImage() == null) {
|
|
||||||
this.expansionSetCode = sourceCard.getExpansionSetCode();
|
|
||||||
} else {
|
|
||||||
this.expansionSetCode = plane.getExpansionSetCodeForImage();
|
|
||||||
}
|
|
||||||
this.rules = plane.getAbilities().getRules(sourceCard.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaneView(Plane plane) {
|
public PlaneView(Plane plane) {
|
||||||
this.id = plane.getId();
|
this.id = plane.getId();
|
||||||
this.name = plane.getName();
|
this.name = plane.getName();
|
||||||
this.expansionSetCode = plane.getExpansionSetCodeForImage();
|
this.expansionSetCode = plane.getExpansionSetCode();
|
||||||
this.rules = plane.getAbilities().getRules(plane.getName());
|
this.rules = plane.getAbilities().getRules(plane.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,12 @@ import java.io.Serializable;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* GUI: basic class for all card/object related views
|
||||||
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class SimpleCardView implements Serializable, SelectableObjectView {
|
public class SimpleCardView implements Serializable, SelectableObjectView {
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
protected UUID id;
|
protected UUID id;
|
||||||
protected String expansionSetCode;
|
protected String expansionSetCode;
|
||||||
|
|
|
||||||
|
|
@ -686,8 +686,7 @@ public final class SystemUtil {
|
||||||
Planes planeType = Planes.fromClassName(planeClassName);
|
Planes planeType = Planes.fromClassName(planeClassName);
|
||||||
Plane plane = Plane.createPlane(planeType);
|
Plane plane = Plane.createPlane(planeType);
|
||||||
if (plane != null) {
|
if (plane != null) {
|
||||||
plane.setControllerId(player.getId());
|
game.addPlane(plane, player.getId());
|
||||||
game.addPlane(plane, null, player.getId());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package org.mage.test.serverside;
|
package org.mage.test.serverside;
|
||||||
|
|
||||||
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
|
@ -9,6 +10,7 @@ import mage.cards.repository.TokenRepository;
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.permanent.PermanentToken;
|
import mage.game.permanent.PermanentToken;
|
||||||
|
import mage.game.permanent.token.HumanToken;
|
||||||
import mage.game.permanent.token.SoldierToken;
|
import mage.game.permanent.token.SoldierToken;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.game.permanent.token.TokenImpl;
|
import mage.game.permanent.token.TokenImpl;
|
||||||
|
|
@ -24,6 +26,7 @@ import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
@ -148,7 +151,7 @@ public class TokenImagesTest extends CardTestPlayerBase {
|
||||||
Assert.assertNotNull("must have set code", card.getExpansionSetCode());
|
Assert.assertNotNull("must have set code", card.getExpansionSetCode());
|
||||||
Assert.assertEquals("must have same set codes in all fields",
|
Assert.assertEquals("must have same set codes in all fields",
|
||||||
card.getExpansionSetCode(),
|
card.getExpansionSetCode(),
|
||||||
((PermanentToken) card).getToken().getOriginalExpansionSetCode()
|
((PermanentToken) card).getToken().getExpansionSetCode()
|
||||||
);
|
);
|
||||||
String realCode = card.getExpansionSetCode();
|
String realCode = card.getExpansionSetCode();
|
||||||
realServerStats.computeIfAbsent(realCode, code -> new ArrayList<>());
|
realServerStats.computeIfAbsent(realCode, code -> new ArrayList<>());
|
||||||
|
|
@ -225,7 +228,7 @@ public class TokenImagesTest extends CardTestPlayerBase {
|
||||||
// token as card like Embalm ability must have card number, so it will link to card's image instead token's image
|
// token as card like Embalm ability must have card number, so it will link to card's image instead token's image
|
||||||
boolean hasCardNumbers = !realList.isEmpty() && realList
|
boolean hasCardNumbers = !realList.isEmpty() && realList
|
||||||
.stream()
|
.stream()
|
||||||
.mapToInt(card -> card.getCardNumber() == null ? 0 : CardUtil.parseCardNumberAsInt(card.getCardNumber()))
|
.mapToInt(card -> card.getCardNumber().isEmpty() ? 0 : CardUtil.parseCardNumberAsInt(card.getCardNumber()))
|
||||||
.allMatch(x -> x > 0);
|
.allMatch(x -> x > 0);
|
||||||
if (mustStoreAsCard != hasCardNumbers) {
|
if (mustStoreAsCard != hasCardNumbers) {
|
||||||
isFine = false;
|
isFine = false;
|
||||||
|
|
@ -257,13 +260,14 @@ public class TokenImagesTest extends CardTestPlayerBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assert_TokenTypes(String tokenName, int needTokenTypes) {
|
private void assert_TokenImageNumber(String tokenName, List<Integer> needUniqueImages) {
|
||||||
Set<Integer> serverStats = currentGame.getBattlefield().getAllPermanents()
|
Set<Integer> serverStats = currentGame.getBattlefield().getAllPermanents()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(card -> card.getName().equals(tokenName))
|
.filter(card -> card.getName().equals(tokenName))
|
||||||
|
.filter(card -> card instanceof PermanentToken)
|
||||||
.sorted(Comparator.comparing(Card::getExpansionSetCode))
|
.sorted(Comparator.comparing(Card::getExpansionSetCode))
|
||||||
.map(card -> (PermanentToken) card)
|
.map(card -> (PermanentToken) card)
|
||||||
.map(perm -> perm.getToken().getTokenType())
|
.map(perm -> perm.getToken().getImageNumber())
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
GameView gameView = new GameView(currentGame.getState(), currentGame, playerA.getId(), null);
|
GameView gameView = new GameView(currentGame.getState(), currentGame, playerA.getId(), null);
|
||||||
|
|
@ -277,13 +281,15 @@ public class TokenImagesTest extends CardTestPlayerBase {
|
||||||
.stream()
|
.stream()
|
||||||
.filter(card -> card.getName().equals(tokenName))
|
.filter(card -> card.getName().equals(tokenName))
|
||||||
.sorted(Comparator.comparing(CardView::getExpansionSetCode))
|
.sorted(Comparator.comparing(CardView::getExpansionSetCode))
|
||||||
.map(CardView::getType)
|
.map(CardView::getImageNumber)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
// server and client sides must have same data
|
// server and client sides must have same data
|
||||||
Assert.assertEquals(serverStats.size(), clientStats.size());
|
String imagesNeed = needUniqueImages.stream().sorted().map(Object::toString).collect(Collectors.joining(", "));
|
||||||
Assert.assertEquals(needTokenTypes, serverStats.size());
|
String imagesServer = serverStats.stream().sorted().map(Object::toString).collect(Collectors.joining(", "));
|
||||||
Assert.assertEquals(needTokenTypes, clientStats.size());
|
String imagesClient = clientStats.stream().sorted().map(Object::toString).collect(Collectors.joining(", "));
|
||||||
|
Assert.assertEquals(imagesNeed, imagesServer);
|
||||||
|
Assert.assertEquals(imagesNeed, imagesClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -310,7 +316,7 @@ public class TokenImagesTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
// x2 tokens
|
// x2 tokens
|
||||||
assert_MemorialToGlory(20, "40K=40");
|
assert_MemorialToGlory(20, "40K=40");
|
||||||
assert_TokenTypes("Soldier Token", 3); // 40K set contains 3 diffrent soldiers
|
assert_TokenImageNumber("Soldier Token", Arrays.asList(1, 2, 3)); // 40K set contains 3 diffrent soldiers
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -355,12 +361,26 @@ public class TokenImagesTest extends CardTestPlayerBase {
|
||||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "create ten");
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "create ten");
|
||||||
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
|
||||||
|
// workaround to find a real image number (tokens get random image on put to battlefield)
|
||||||
|
AtomicInteger realImageNumber = new AtomicInteger(0);
|
||||||
|
runCode("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||||
|
PermanentToken token = game.getBattlefield().getAllPermanents()
|
||||||
|
.stream()
|
||||||
|
.filter(p -> p instanceof PermanentToken)
|
||||||
|
.map(p -> (PermanentToken) p)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
Assert.assertNotNull(token);
|
||||||
|
Assert.assertTrue(token.getImageNumber() >= 1 && token.getImageNumber() <= 3);
|
||||||
|
realImageNumber.set(token.getImageNumber());
|
||||||
|
});
|
||||||
|
|
||||||
setStrictChooseMode(true);
|
setStrictChooseMode(true);
|
||||||
setStopAt(1, PhaseStep.END_TURN);
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
execute();
|
execute();
|
||||||
|
|
||||||
assertPermanentCount(playerA, 1 + 10); // 1 test card + 10 tokens
|
assertPermanentCount(playerA, 1 + 10); // 1 test card + 10 tokens
|
||||||
assert_TokenTypes("Soldier Token", 1); // one ability's call must generate tokens with same image
|
assert_TokenImageNumber("Soldier Token", Arrays.asList(realImageNumber.get())); // one ability's call must generate tokens with same image
|
||||||
assert_Inner("test", 0, 0, 1,
|
assert_Inner("test", 0, 0, 1,
|
||||||
"Soldier Token", 10, false, "40K=10");
|
"Soldier Token", 10, false, "40K=10");
|
||||||
}
|
}
|
||||||
|
|
@ -430,6 +450,108 @@ public class TokenImagesTest extends CardTestPlayerBase {
|
||||||
"Construct Token", 2, false, "MED=2");
|
"Construct Token", 2, false, "MED=2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_TokenExists_CopyMustGetSameImageNumber() {
|
||||||
|
Ability ability = new SimpleActivatedAbility(
|
||||||
|
Zone.ALL,
|
||||||
|
new CreateTokenEffect(new HumanToken(), 10),
|
||||||
|
new ManaCostsImpl<>("")
|
||||||
|
);
|
||||||
|
addCustomCardWithAbility("MOC-test", playerA, ability); // MOC contains only 1 token with image number 2
|
||||||
|
//
|
||||||
|
// You may have Vesuvan Doppelganger enter the battlefield as a copy of any creature on the battlefield
|
||||||
|
addCard(Zone.HAND, playerA, "Vesuvan Doppelganger", 1); // {3}{U}{U}
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 5);
|
||||||
|
|
||||||
|
// create tokens
|
||||||
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "create ten");
|
||||||
|
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
checkPermanentCount("prepare", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Human Token", 10);
|
||||||
|
// copy token
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Vesuvan Doppelganger");
|
||||||
|
setChoice(playerA, true);
|
||||||
|
setChoice(playerA, "Human Token");
|
||||||
|
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
checkPermanentCount("after copy", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Human Token", 10 + 1);
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assert_TokenImageNumber("Human Token", Arrays.asList(2)); // one ability's call must generate tokens with same image
|
||||||
|
assert_Inner("test", 0, 0, 1,
|
||||||
|
"Human Token", 10, false, "MOC=10");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_TokenExists_CopyEffectMustRestoreOldImageAfterEnd() {
|
||||||
|
// check a copy effect for:
|
||||||
|
// - a: card
|
||||||
|
// - b: token
|
||||||
|
// - c: token for card
|
||||||
|
|
||||||
|
// {3}{U}{U}
|
||||||
|
// Echoing Equation
|
||||||
|
// Choose target creature you control. Each other creature you control becomes a copy of it until end of turn, except those creatures aren’t legendary if the chosen creature is legendary.
|
||||||
|
addCard(Zone.HAND, playerA, "STX-Augmenter Pugilist", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 5);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "ICE-Balduvian Bears", 1);
|
||||||
|
//
|
||||||
|
// a: card
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "NEC-Silver Myr", 1);
|
||||||
|
//
|
||||||
|
// b: token
|
||||||
|
prepareCards_TheHive("10E=1");
|
||||||
|
//
|
||||||
|
// - c: token for card
|
||||||
|
// {2}{U}
|
||||||
|
// Choose target artifact creature you control. For each creature chosen this way, create a token that's a copy of it.
|
||||||
|
addCard(Zone.HAND, playerA, "BRC-March of Progress", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
|
||||||
|
|
||||||
|
// prepare b: token
|
||||||
|
activate_TheHive(1);
|
||||||
|
|
||||||
|
// prepare c: token for card
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "March of Progress");
|
||||||
|
addTarget(playerA, "Silver Myr");
|
||||||
|
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
|
||||||
|
// check prepared data
|
||||||
|
checkPermanentCount("prepare", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silver Myr", 2); // card + token
|
||||||
|
checkPermanentCount("prepare", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wasp", 1);
|
||||||
|
|
||||||
|
// copy bear
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Echoing Equation");
|
||||||
|
addTarget(playerA, "Balduvian Bears");
|
||||||
|
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
// must get 1 original card + 3 copies (1 from card, 1 from copy of card, 1 from token)
|
||||||
|
checkPermanentCount("after copy start", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Balduvian Bears", 4);
|
||||||
|
runCode("after copy start", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||||
|
Set<String> usedSetCodes = game.getBattlefield().getAllPermanents()
|
||||||
|
.stream()
|
||||||
|
.filter(MageObject::isCopy)
|
||||||
|
.map(Card::getExpansionSetCode)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Assert.assertEquals(1, usedSetCodes.size());
|
||||||
|
Assert.assertEquals("ICE", usedSetCodes.stream().findFirst().orElse(null));
|
||||||
|
});
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(3, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
// end of copy - must get original images
|
||||||
|
assertPermanentCount(playerA, "Balduvian Bears", 1);
|
||||||
|
assertPermanentCount(playerA, "Silver Myr", 2); // card + token
|
||||||
|
assertTokenCount(playerA, "Silver Myr", 1);
|
||||||
|
assertPermanentCount(playerA, "Wasp", 1);
|
||||||
|
assert_Inner("Silver Myr", 0, 0, 2,
|
||||||
|
"Silver Myr", 1, true, "NEC=1");
|
||||||
|
assert_Inner("", 0, 0, 0,
|
||||||
|
"Wasp", 1, false, "10E=1");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
// TODO: implement auto-generate creature token images from public tokens (by name, type, color, PT, abilities)
|
// TODO: implement auto-generate creature token images from public tokens (by name, type, color, PT, abilities)
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,6 @@ public class DeckBuilderTest {
|
||||||
|
|
||||||
public RandomArtifactCreature(UUID ownerId, int cardNumber, String name) {
|
public RandomArtifactCreature(UUID ownerId, int cardNumber, String name) {
|
||||||
super(ownerId, new CardSetInfo(name, "MRD", String.valueOf(cardNumber), Rarity.COMMON), new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{1}");
|
super(ownerId, new CardSetInfo(name, "MRD", String.valueOf(cardNumber), Rarity.COMMON), new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{1}");
|
||||||
this.expansionSetCode = "MRD";
|
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1337,14 +1337,13 @@ public class VerifyCardDataTest {
|
||||||
|
|
||||||
// CHECK: named tokens must not have Token in the name
|
// CHECK: named tokens must not have Token in the name
|
||||||
if (token.getDescription().contains("named") && token.getName().contains("Token")) {
|
if (token.getDescription().contains("named") && token.getName().contains("Token")) {
|
||||||
if (token.getDescription().contains("card named")) {
|
|
||||||
// ignore ability text like Return a card named Deathpact Angel from
|
// ignore ability text like Return a card named Deathpact Angel from
|
||||||
continue;
|
if (!token.getDescription().contains("card named")) {
|
||||||
}
|
|
||||||
errorsList.add("Error: named token must not have Token in the name: "
|
errorsList.add("Error: named token must not have Token in the name: "
|
||||||
+ tokenClass.getName() + " - " + token.getName() + " - " + token.getDescription());
|
+ tokenClass.getName() + " - " + token.getName() + " - " + token.getDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// CHECK: wrong set codes in tok-data
|
// CHECK: wrong set codes in tok-data
|
||||||
tokDataTokensBySetIndex.forEach((setCode, setTokens) -> {
|
tokDataTokensBySetIndex.forEach((setCode, setTokens) -> {
|
||||||
|
|
@ -1462,10 +1461,6 @@ public class VerifyCardDataTest {
|
||||||
if (errorsList.size() > 0) {
|
if (errorsList.size() > 0) {
|
||||||
Assert.fail("Found token errors: " + errorsList.size());
|
Assert.fail("Found token errors: " + errorsList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: all token must have correct availableImageSetCodes (all sets with that token)
|
|
||||||
// Some sets have original card, but don't have token card at all. So you must use scryfall tokens list above to find
|
|
||||||
// all token's sets and compare with xmage
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,18 @@ import java.util.Set;
|
||||||
|
|
||||||
public interface MageObject extends MageItem, Serializable, Copyable<MageObject> {
|
public interface MageObject extends MageItem, Serializable, Copyable<MageObject> {
|
||||||
|
|
||||||
|
String getExpansionSetCode();
|
||||||
|
void setExpansionSetCode(String expansionSetCode);
|
||||||
|
|
||||||
|
String getCardNumber();
|
||||||
|
void setCardNumber(String cardNumber);
|
||||||
|
|
||||||
|
Integer getImageNumber();
|
||||||
|
void setImageNumber(Integer imageNumber);
|
||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
String getIdName();
|
String getIdName();
|
||||||
|
|
||||||
String getLogName();
|
String getLogName();
|
||||||
|
|
||||||
String getImageName();
|
|
||||||
|
|
||||||
void setName(String name);
|
void setName(String name);
|
||||||
|
|
||||||
default List<CardType> getCardType() {
|
default List<CardType> getCardType() {
|
||||||
|
|
|
||||||
|
|
@ -29,18 +29,26 @@ public abstract class MageObjectImpl implements MageObject {
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
protected ManaCosts<ManaCost> manaCost;
|
protected ManaCosts<ManaCost> manaCost;
|
||||||
|
|
||||||
protected ObjectColor color;
|
protected ObjectColor color;
|
||||||
protected ObjectColor frameColor;
|
protected ObjectColor frameColor;
|
||||||
protected FrameStyle frameStyle;
|
protected FrameStyle frameStyle;
|
||||||
|
|
||||||
|
private String expansionSetCode = "";
|
||||||
|
private String cardNumber = "";
|
||||||
|
private int imageNumber = 0;
|
||||||
|
|
||||||
protected List<CardType> cardType = new ArrayList<>();
|
protected List<CardType> cardType = new ArrayList<>();
|
||||||
protected SubTypes subtype = new SubTypes();
|
protected SubTypes subtype = new SubTypes();
|
||||||
protected Set<SuperType> supertype = EnumSet.noneOf(SuperType.class);
|
protected Set<SuperType> supertype = EnumSet.noneOf(SuperType.class);
|
||||||
protected Abilities<Ability> abilities;
|
protected Abilities<Ability> abilities;
|
||||||
|
|
||||||
protected String text;
|
protected String text;
|
||||||
protected MageInt power;
|
protected MageInt power;
|
||||||
protected MageInt toughness;
|
protected MageInt toughness;
|
||||||
protected int startingLoyalty = -1; // -2 means X, -1 means none, 0 and up is normal
|
protected int startingLoyalty = -1; // -2 means X, -1 means none, 0 and up is normal
|
||||||
protected int startingDefense = -1; // -2 means X, -1 means none, 0 and up is normal
|
protected int startingDefense = -1; // -2 means X, -1 means none, 0 and up is normal
|
||||||
|
|
||||||
protected boolean copy;
|
protected boolean copy;
|
||||||
protected MageObject copyFrom; // copied card INFO (used to call original adjusters)
|
protected MageObject copyFrom; // copied card INFO (used to call original adjusters)
|
||||||
|
|
||||||
|
|
@ -67,6 +75,9 @@ public abstract class MageObjectImpl implements MageObject {
|
||||||
color = object.color.copy();
|
color = object.color.copy();
|
||||||
frameColor = object.frameColor.copy();
|
frameColor = object.frameColor.copy();
|
||||||
frameStyle = object.frameStyle;
|
frameStyle = object.frameStyle;
|
||||||
|
expansionSetCode = object.expansionSetCode;
|
||||||
|
cardNumber = object.cardNumber;
|
||||||
|
imageNumber = object.imageNumber;
|
||||||
power = object.power.copy();
|
power = object.power.copy();
|
||||||
toughness = object.toughness.copy();
|
toughness = object.toughness.copy();
|
||||||
startingLoyalty = object.startingLoyalty;
|
startingLoyalty = object.startingLoyalty;
|
||||||
|
|
@ -99,11 +110,6 @@ public abstract class MageObjectImpl implements MageObject {
|
||||||
return GameLog.getColoredObjectIdName(this);
|
return GameLog.getColoredObjectIdName(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getImageName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
@ -233,6 +239,36 @@ public abstract class MageObjectImpl implements MageObject {
|
||||||
return frameStyle;
|
return frameStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExpansionSetCode() {
|
||||||
|
return expansionSetCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setExpansionSetCode(String expansionSetCode) {
|
||||||
|
this.expansionSetCode = expansionSetCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCardNumber() {
|
||||||
|
return cardNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCardNumber(String cardNumber) {
|
||||||
|
this.cardNumber = cardNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getImageNumber() {
|
||||||
|
return imageNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setImageNumber(Integer imageNumber) {
|
||||||
|
this.imageNumber = imageNumber;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ManaCosts<ManaCost> getManaCost() {
|
public ManaCosts<ManaCost> getManaCost() {
|
||||||
return manaCost;
|
return manaCost;
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public interface Ability extends Controllable, Serializable {
|
||||||
* @see Game#addTriggeredAbility(TriggeredAbility, GameEvent)
|
* @see Game#addTriggeredAbility(TriggeredAbility, GameEvent)
|
||||||
* @see mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
|
* @see mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
|
||||||
*/
|
*/
|
||||||
void newOriginalId();
|
void newOriginalId(); // TODO: delete newOriginalId???
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link AbilityType} of this ability.
|
* Gets the {@link AbilityType} of this ability.
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
private static final List<Ability> emptyAbilities = new ArrayList<>();
|
private static final List<Ability> emptyAbilities = new ArrayList<>();
|
||||||
|
|
||||||
protected UUID id;
|
protected UUID id;
|
||||||
protected UUID originalId;
|
protected UUID originalId; // TODO: delete originalId???
|
||||||
protected AbilityType abilityType;
|
protected AbilityType abilityType;
|
||||||
protected UUID controllerId;
|
protected UUID controllerId;
|
||||||
protected UUID sourceId;
|
protected UUID sourceId;
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,7 @@ public class RollPlanarDieEffect extends OneShotEffect {
|
||||||
try {
|
try {
|
||||||
if (plane != null && !planesVisited.contains(plane.getName())) {
|
if (plane != null && !planesVisited.contains(plane.getName())) {
|
||||||
foundNextPlane = true;
|
foundNextPlane = true;
|
||||||
plane.setControllerId(controller.getId());
|
game.addPlane(plane, controller.getId());
|
||||||
game.addPlane(plane, null, controller.getId());
|
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect;
|
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect;
|
||||||
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect.FaceDownType;
|
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect.FaceDownType;
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
@ -157,9 +156,6 @@ public class MorphAbility extends AlternativeSourceCostsImpl {
|
||||||
targetObject.getManaCost().clear();
|
targetObject.getManaCost().clear();
|
||||||
|
|
||||||
Token emptyImage = new EmptyToken();
|
Token emptyImage = new EmptyToken();
|
||||||
emptyImage.setOriginalExpansionSetCode("");
|
|
||||||
emptyImage.setExpansionSetCodeForImage("");
|
|
||||||
emptyImage.setOriginalCardNumber("");
|
|
||||||
|
|
||||||
// TODO: add morph image here?
|
// TODO: add morph image here?
|
||||||
if (targetObject instanceof Permanent) {
|
if (targetObject instanceof Permanent) {
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,6 @@ public class AdventureCardSpellImpl extends CardImpl implements AdventureCardSpe
|
||||||
return adventureCardParent.getOwnerId();
|
return adventureCardParent.getOwnerId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getImageName() {
|
|
||||||
return adventureCardParent.getImageName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getExpansionSetCode() {
|
public String getExpansionSetCode() {
|
||||||
return adventureCardParent.getExpansionSetCode();
|
return adventureCardParent.getExpansionSetCode();
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,6 @@ public interface Card extends MageObject {
|
||||||
|
|
||||||
UUID getOwnerId();
|
UUID getOwnerId();
|
||||||
|
|
||||||
String getCardNumber();
|
|
||||||
|
|
||||||
Rarity getRarity(); // null for tokens
|
Rarity getRarity(); // null for tokens
|
||||||
|
|
||||||
void setOwnerId(UUID ownerId);
|
void setOwnerId(UUID ownerId);
|
||||||
|
|
@ -48,7 +46,6 @@ public interface Card extends MageObject {
|
||||||
|
|
||||||
List<String> getRules(Game game); // gets card rules + in game modifications
|
List<String> getRules(Game game); // gets card rules + in game modifications
|
||||||
|
|
||||||
String getExpansionSetCode();
|
|
||||||
void checkForCountersToAdd(Permanent permanent, Ability source, Game game);
|
void checkForCountersToAdd(Permanent permanent, Ability source, Game game);
|
||||||
|
|
||||||
void setFaceDown(boolean value, Game game);
|
void setFaceDown(boolean value, Game game);
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
private static final Logger logger = Logger.getLogger(CardImpl.class);
|
private static final Logger logger = Logger.getLogger(CardImpl.class);
|
||||||
|
|
||||||
protected UUID ownerId;
|
protected UUID ownerId;
|
||||||
protected String cardNumber;
|
|
||||||
protected String expansionSetCode;
|
|
||||||
protected Rarity rarity;
|
protected Rarity rarity;
|
||||||
protected Class<? extends Card> secondSideCardClazz;
|
protected Class<? extends Card> secondSideCardClazz;
|
||||||
protected Class<? extends Card> meldsWithClazz;
|
protected Class<? extends Card> meldsWithClazz;
|
||||||
|
|
@ -59,12 +57,12 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
public CardImpl(UUID ownerId, CardSetInfo setInfo, CardType[] cardTypes, String costs) {
|
public CardImpl(UUID ownerId, CardSetInfo setInfo, CardType[] cardTypes, String costs) {
|
||||||
this(ownerId, setInfo, cardTypes, costs, SpellAbilityType.BASE);
|
this(ownerId, setInfo, cardTypes, costs, SpellAbilityType.BASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardImpl(UUID ownerId, CardSetInfo setInfo, CardType[] cardTypes, String costs, SpellAbilityType spellAbilityType) {
|
public CardImpl(UUID ownerId, CardSetInfo setInfo, CardType[] cardTypes, String costs, SpellAbilityType spellAbilityType) {
|
||||||
this(ownerId, setInfo.getName());
|
this(ownerId, setInfo.getName());
|
||||||
|
|
||||||
this.rarity = setInfo.getRarity();
|
this.rarity = setInfo.getRarity();
|
||||||
this.cardNumber = setInfo.getCardNumber();
|
this.setExpansionSetCode(setInfo.getExpansionSetCode());
|
||||||
this.expansionSetCode = setInfo.getExpansionSetCode();
|
this.setCardNumber(setInfo.getCardNumber());
|
||||||
this.cardType.addAll(Arrays.asList(cardTypes));
|
this.cardType.addAll(Arrays.asList(cardTypes));
|
||||||
this.manaCost.load(costs);
|
this.manaCost.load(costs);
|
||||||
setDefaultColor();
|
setDefaultColor();
|
||||||
|
|
@ -104,6 +102,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CardImpl(UUID ownerId, String name) {
|
protected CardImpl(UUID ownerId, String name) {
|
||||||
|
super();
|
||||||
this.ownerId = ownerId;
|
this.ownerId = ownerId;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
@ -117,8 +116,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
public CardImpl(final CardImpl card) {
|
public CardImpl(final CardImpl card) {
|
||||||
super(card);
|
super(card);
|
||||||
ownerId = card.ownerId;
|
ownerId = card.ownerId;
|
||||||
cardNumber = card.cardNumber;
|
|
||||||
expansionSetCode = card.expansionSetCode;
|
|
||||||
rarity = card.rarity;
|
rarity = card.rarity;
|
||||||
|
|
||||||
secondSideCardClazz = card.secondSideCardClazz;
|
secondSideCardClazz = card.secondSideCardClazz;
|
||||||
|
|
@ -199,11 +196,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
return ownerId;
|
return ownerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCardNumber() {
|
|
||||||
return cardNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Rarity getRarity() {
|
public Rarity getRarity() {
|
||||||
return rarity;
|
return rarity;
|
||||||
|
|
@ -369,11 +361,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
abilities.setControllerId(ownerId);
|
abilities.setControllerId(ownerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getExpansionSetCode() {
|
|
||||||
return expansionSetCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Mana> getMana() {
|
public List<Mana> getMana() {
|
||||||
List<Mana> mana = new ArrayList<>();
|
List<Mana> mana = new ArrayList<>();
|
||||||
|
|
@ -634,11 +621,11 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
// must be non strict search in any sets, not one set
|
// must be non strict search in any sets, not one set
|
||||||
// example: if set contains only one card side
|
// example: if set contains only one card side
|
||||||
// method used in cards database creating, so can't use repository here
|
// method used in cards database creating, so can't use repository here
|
||||||
ExpansionSet.SetCardInfo info = Sets.findCardByClass(cardClazz, expansionSetCode, cardNumber);
|
ExpansionSet.SetCardInfo info = Sets.findCardByClass(cardClazz, this.getExpansionSetCode(), this.getCardNumber());
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return createCard(cardClazz, new CardSetInfo(info.getName(), expansionSetCode, info.getCardNumber(), info.getRarity(), info.getGraphicInfo()));
|
return createCard(cardClazz, new CardSetInfo(info.getName(), this.getExpansionSetCode(), info.getCardNumber(), info.getRarity(), info.getGraphicInfo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,6 @@ public class ModalDoubleFacesCardHalfImpl extends CardImpl implements ModalDoubl
|
||||||
return parentCard.getOwnerId();
|
return parentCard.getOwnerId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getImageName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getExpansionSetCode() {
|
public String getExpansionSetCode() {
|
||||||
// TODO: own set code?
|
// TODO: own set code?
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
||||||
if (instance.containsKey(preferredSetCode)) {
|
if (instance.containsKey(preferredSetCode)) {
|
||||||
info = instance.get(preferredSetCode).findCardInfoByClass(clazz)
|
info = instance.get(preferredSetCode).findCardInfoByClass(clazz)
|
||||||
.stream()
|
.stream()
|
||||||
.filter(card -> preferredCardNumber == null || card.getCardNumber().equals(preferredCardNumber))
|
.filter(card -> preferredCardNumber.isEmpty() || card.getCardNumber().equals(preferredCardNumber))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
@ -220,7 +220,7 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
||||||
for (Map.Entry<String, ExpansionSet> entry : instance.entrySet()) {
|
for (Map.Entry<String, ExpansionSet> entry : instance.entrySet()) {
|
||||||
info = entry.getValue().findCardInfoByClass(clazz)
|
info = entry.getValue().findCardInfoByClass(clazz)
|
||||||
.stream()
|
.stream()
|
||||||
.filter(card -> preferredCardNumber == null || card.getCardNumber().equals(preferredCardNumber))
|
.filter(card -> preferredCardNumber.isEmpty() || card.getCardNumber().equals(preferredCardNumber))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,6 @@ public class SplitCardHalfImpl extends CardImpl implements SplitCardHalf {
|
||||||
return splitCardParent.getOwnerId();
|
return splitCardParent.getOwnerId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getImageName() {
|
|
||||||
return splitCardParent.getImageName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getExpansionSetCode() {
|
public String getExpansionSetCode() {
|
||||||
return splitCardParent.getExpansionSetCode();
|
return splitCardParent.getExpansionSetCode();
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ public class MockCard extends CardImpl {
|
||||||
|
|
||||||
public MockCard(CardInfo card) {
|
public MockCard(CardInfo card) {
|
||||||
super(null, card.getName());
|
super(null, card.getName());
|
||||||
this.cardNumber = card.getCardNumber();
|
this.setExpansionSetCode(card.getSetCode());
|
||||||
this.expansionSetCode = card.getSetCode();
|
this.setCardNumber(card.getCardNumber());
|
||||||
this.power = mageIntFromString(card.getPower());
|
this.power = mageIntFromString(card.getPower());
|
||||||
this.toughness = mageIntFromString(card.getToughness());
|
this.toughness = mageIntFromString(card.getToughness());
|
||||||
this.rarity = card.getRarity();
|
this.rarity = card.getRarity();
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ public class MockSplitCard extends SplitCard {
|
||||||
join(card.getManaCosts(CardInfo.ManaCostSide.LEFT)),
|
join(card.getManaCosts(CardInfo.ManaCostSide.LEFT)),
|
||||||
join(card.getManaCosts(CardInfo.ManaCostSide.RIGHT)),
|
join(card.getManaCosts(CardInfo.ManaCostSide.RIGHT)),
|
||||||
getSpellAbilityType(card));
|
getSpellAbilityType(card));
|
||||||
this.expansionSetCode = card.getSetCode();
|
|
||||||
this.power = mageIntFromString(card.getPower());
|
this.power = mageIntFromString(card.getPower());
|
||||||
this.toughness = mageIntFromString(card.getToughness());
|
this.toughness = mageIntFromString(card.getToughness());
|
||||||
this.cardType = card.getTypes();
|
this.cardType = card.getTypes();
|
||||||
|
|
|
||||||
|
|
@ -349,7 +349,7 @@ public enum CardRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardInfo findPreferredCoreExpansionCard(String name) {
|
public CardInfo findPreferredCoreExpansionCard(String name) {
|
||||||
return findPreferredCoreExpansionCard(name, null);
|
return findPreferredCoreExpansionCard(name, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardInfo findPreferredCoreExpansionCard(String name, String preferredSetCode) {
|
public CardInfo findPreferredCoreExpansionCard(String name, String preferredSetCode) {
|
||||||
|
|
@ -368,7 +368,7 @@ public enum CardRepository {
|
||||||
ExpansionInfo set = ExpansionRepository.instance.getSetByCode(cardinfo.getSetCode());
|
ExpansionInfo set = ExpansionRepository.instance.getSetByCode(cardinfo.getSetCode());
|
||||||
if (set != null) {
|
if (set != null) {
|
||||||
|
|
||||||
if ((preferredSetCode != null) && (preferredSetCode.equals(set.getCode()))) {
|
if (preferredSetCode.equals(set.getCode())) {
|
||||||
return cardinfo;
|
return cardinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package mage.cards.repository;
|
package mage.cards.repository;
|
||||||
|
|
||||||
|
import mage.util.RandomUtil;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
|
@ -275,4 +276,31 @@ public enum TokenRepository {
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to find random image info by related set code
|
||||||
|
*
|
||||||
|
* @param className full class name of the token or other object
|
||||||
|
* @param setCode primary set code for possible image
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public TokenInfo generateTokenInfoBySetCode(String className, String setCode) {
|
||||||
|
// search by set code
|
||||||
|
List<TokenInfo> possibleInfo = TokenRepository.instance.getByClassName(className)
|
||||||
|
.stream()
|
||||||
|
.filter(info -> info.getSetCode().equals(setCode))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// search by random set
|
||||||
|
if (possibleInfo.isEmpty()) {
|
||||||
|
possibleInfo = new ArrayList<>(TokenRepository.instance.getByClassName(className));
|
||||||
|
}
|
||||||
|
|
||||||
|
// also weill return diff image number for tokens
|
||||||
|
if (possibleInfo.size() > 0) {
|
||||||
|
return RandomUtil.randomFromCollection(possibleInfo);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -398,7 +398,7 @@ public interface Game extends MageItem, Serializable, Copyable<Game> {
|
||||||
|
|
||||||
void addEmblem(Emblem emblem, MageObject sourceObject, UUID toPlayerId);
|
void addEmblem(Emblem emblem, MageObject sourceObject, UUID toPlayerId);
|
||||||
|
|
||||||
boolean addPlane(Plane plane, MageObject sourceObject, UUID toPlayerId);
|
boolean addPlane(Plane plane, UUID toPlayerId);
|
||||||
|
|
||||||
void addCommander(Commander commander);
|
void addCommander(Commander commander);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1307,7 +1307,7 @@ public abstract class GameImpl implements Game {
|
||||||
if (gameOptions.planeChase) {
|
if (gameOptions.planeChase) {
|
||||||
Plane plane = Plane.createRandomPlane();
|
Plane plane = Plane.createRandomPlane();
|
||||||
plane.setControllerId(startingPlayerId);
|
plane.setControllerId(startingPlayerId);
|
||||||
addPlane(plane, null, startingPlayerId);
|
addPlane(plane, startingPlayerId);
|
||||||
state.setPlaneChase(this, gameOptions.planeChase);
|
state.setPlaneChase(this, gameOptions.planeChase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1850,18 +1850,18 @@ public abstract class GameImpl implements Game {
|
||||||
for (Ability ability : newEmblem.getAbilities()) {
|
for (Ability ability : newEmblem.getAbilities()) {
|
||||||
ability.setSourceId(newEmblem.getId());
|
ability.setSourceId(newEmblem.getId());
|
||||||
}
|
}
|
||||||
state.addCommandObject(newEmblem);
|
|
||||||
|
state.addCommandObject(newEmblem); // TODO: generate image for emblem here?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plane
|
* @param plane
|
||||||
* @param sourceObject
|
|
||||||
* @param toPlayerId controller and owner of the plane (may only be one
|
* @param toPlayerId controller and owner of the plane (may only be one
|
||||||
* per game..)
|
* per game..)
|
||||||
* @return boolean - whether the plane was added successfully or not
|
* @return boolean - whether the plane was added successfully or not
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean addPlane(Plane plane, MageObject sourceObject, UUID toPlayerId) {
|
public boolean addPlane(Plane plane, UUID toPlayerId) {
|
||||||
// Implementing planechase as if it were 901.15. Single Planar Deck Option
|
// Implementing planechase as if it were 901.15. Single Planar Deck Option
|
||||||
// Here, can enforce the world plane restriction (the Grand Melee format may have some impact on this implementation)
|
// Here, can enforce the world plane restriction (the Grand Melee format may have some impact on this implementation)
|
||||||
|
|
||||||
|
|
@ -1872,7 +1872,7 @@ public abstract class GameImpl implements Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Plane newPlane = plane.copy();
|
Plane newPlane = plane.copy();
|
||||||
newPlane.setSourceObject(sourceObject);
|
newPlane.setSourceObject();
|
||||||
newPlane.setControllerId(toPlayerId);
|
newPlane.setControllerId(toPlayerId);
|
||||||
newPlane.assignNewId();
|
newPlane.assignNewId();
|
||||||
newPlane.getAbilities().newId();
|
newPlane.getAbilities().newId();
|
||||||
|
|
@ -3160,7 +3160,7 @@ public abstract class GameImpl implements Game {
|
||||||
addedAgain = true;
|
addedAgain = true;
|
||||||
Plane plane = Plane.createRandomPlane();
|
Plane plane = Plane.createRandomPlane();
|
||||||
plane.setControllerId(aplayer.getId());
|
plane.setControllerId(aplayer.getId());
|
||||||
addPlane(plane, null, aplayer.getId());
|
addPlane(plane, aplayer.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,4 @@ public interface CommandObject extends MageObject, Controllable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
CommandObject copy();
|
CommandObject copy();
|
||||||
|
|
||||||
String getExpansionSetCodeForImage();
|
|
||||||
|
|
||||||
void setExpansionSetCodeForImage(String expansionSetCodeForImage);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
92
Mage/src/main/java/mage/game/command/CommandObjectImpl.java
Normal file
92
Mage/src/main/java/mage/game/command/CommandObjectImpl.java
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
package mage.game.command;
|
||||||
|
|
||||||
|
import mage.game.permanent.token.TokenImpl;
|
||||||
|
import mage.util.GameLog;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author JayDi85
|
||||||
|
*/
|
||||||
|
public abstract class CommandObjectImpl implements CommandObject {
|
||||||
|
|
||||||
|
private UUID id;
|
||||||
|
private String name = "";
|
||||||
|
|
||||||
|
private String expansionSetCode;
|
||||||
|
private String cardNumber;
|
||||||
|
private int imageNumber;
|
||||||
|
|
||||||
|
public CommandObjectImpl(String name) {
|
||||||
|
this.id = UUID.randomUUID();
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CommandObjectImpl(final CommandObjectImpl object) {
|
||||||
|
this.id = object.id;
|
||||||
|
this.name = object.name;
|
||||||
|
this.expansionSetCode = object.expansionSetCode;
|
||||||
|
this.cardNumber = object.cardNumber;
|
||||||
|
this.imageNumber = object.imageNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExpansionSetCode() {
|
||||||
|
return expansionSetCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setExpansionSetCode(String expansionSetCode) {
|
||||||
|
this.expansionSetCode = expansionSetCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCardNumber() {
|
||||||
|
return cardNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCardNumber(String cardNumber) {
|
||||||
|
this.cardNumber = cardNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getImageNumber() {
|
||||||
|
return imageNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setImageNumber(Integer imageNumber) {
|
||||||
|
this.imageNumber = imageNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void assignNewId() {
|
||||||
|
this.id = UUID.randomUUID();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdName() {
|
||||||
|
return getName() + " [" + getId().toString().substring(0, 3) + ']';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLogName() {
|
||||||
|
return GameLog.getColoredObjectIdName(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Commander implements CommandObject {
|
public class Commander extends CommandObjectImpl {
|
||||||
|
|
||||||
private final Card sourceObject;
|
private final Card sourceObject;
|
||||||
private boolean copy;
|
private boolean copy;
|
||||||
|
|
@ -31,6 +31,7 @@ public class Commander implements CommandObject {
|
||||||
private final Abilities<Ability> abilities = new AbilitiesImpl<>();
|
private final Abilities<Ability> abilities = new AbilitiesImpl<>();
|
||||||
|
|
||||||
public Commander(Card card) {
|
public Commander(Card card) {
|
||||||
|
super(card.getName());
|
||||||
this.sourceObject = card;
|
this.sourceObject = card;
|
||||||
|
|
||||||
// All abilities must be added to the game before usage. It adding by addCard and addCommandObject calls
|
// All abilities must be added to the game before usage. It adding by addCard and addCommandObject calls
|
||||||
|
|
@ -106,6 +107,7 @@ public class Commander implements CommandObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Commander(final Commander commander) {
|
private Commander(final Commander commander) {
|
||||||
|
super(commander);
|
||||||
this.sourceObject = commander.sourceObject.copy();
|
this.sourceObject = commander.sourceObject.copy();
|
||||||
this.copy = commander.copy;
|
this.copy = commander.copy;
|
||||||
this.copyFrom = (commander.copyFrom != null ? commander.copyFrom.copy() : null);
|
this.copyFrom = (commander.copyFrom != null ? commander.copyFrom.copy() : null);
|
||||||
|
|
@ -127,10 +129,6 @@ public class Commander implements CommandObject {
|
||||||
return sourceObject.getOwnerId();
|
return sourceObject.getOwnerId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void assignNewId() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandObject copy() {
|
public CommandObject copy() {
|
||||||
return new Commander(this);
|
return new Commander(this);
|
||||||
|
|
@ -162,15 +160,6 @@ public class Commander implements CommandObject {
|
||||||
return sourceObject.getName() + " [" + sourceObject.getId().toString().substring(0, 3) + ']';
|
return sourceObject.getName() + " [" + sourceObject.getId().toString().substring(0, 3) + ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLogName() {
|
|
||||||
return GameLog.getColoredObjectIdName(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setName(String name) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CardType> getCardType(Game game) {
|
public List<CardType> getCardType(Game game) {
|
||||||
return sourceObject.getCardType(game);
|
return sourceObject.getCardType(game);
|
||||||
|
|
@ -289,21 +278,6 @@ public class Commander implements CommandObject {
|
||||||
return sourceObject.getId();
|
return sourceObject.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getImageName() {
|
|
||||||
return sourceObject.getImageName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getExpansionSetCodeForImage() {
|
|
||||||
return sourceObject.getExpansionSetCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setExpansionSetCodeForImage(String expansionSetCodeForImage) {
|
|
||||||
throw new IllegalStateException("Can't change a set code of the commander, source card already has it");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getZoneChangeCounter(Game game) {
|
public int getZoneChangeCounter(Game game) {
|
||||||
return sourceObject.getZoneChangeCounter(game);
|
return sourceObject.getZoneChangeCounter(game);
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import java.util.*;
|
||||||
/**
|
/**
|
||||||
* @author TheElk801
|
* @author TheElk801
|
||||||
*/
|
*/
|
||||||
public class Dungeon implements CommandObject {
|
public class Dungeon extends CommandObjectImpl {
|
||||||
|
|
||||||
private static final Set<String> dungeonNames = new HashSet<>();
|
private static final Set<String> dungeonNames = new HashSet<>();
|
||||||
|
|
||||||
|
|
@ -49,31 +49,24 @@ public class Dungeon implements CommandObject {
|
||||||
private static final ObjectColor emptyColor = new ObjectColor();
|
private static final ObjectColor emptyColor = new ObjectColor();
|
||||||
private static final ManaCosts<ManaCost> emptyCost = new ManaCostsImpl<>();
|
private static final ManaCosts<ManaCost> emptyCost = new ManaCostsImpl<>();
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private UUID id;
|
|
||||||
private UUID controllerId;
|
private UUID controllerId;
|
||||||
private boolean copy;
|
private boolean copy;
|
||||||
private MageObject copyFrom; // copied card INFO (used to call original adjusters)
|
private MageObject copyFrom; // copied card INFO (used to call original adjusters)
|
||||||
private FrameStyle frameStyle;
|
private FrameStyle frameStyle;
|
||||||
private final Abilities<Ability> abilites = new AbilitiesImpl<>();
|
private final Abilities<Ability> abilites = new AbilitiesImpl<>();
|
||||||
private String expansionSetCodeForImage;
|
|
||||||
private final List<DungeonRoom> dungeonRooms = new ArrayList<>();
|
private final List<DungeonRoom> dungeonRooms = new ArrayList<>();
|
||||||
private DungeonRoom currentRoom = null;
|
private DungeonRoom currentRoom = null;
|
||||||
|
|
||||||
public Dungeon(String name, String expansionSetCodeForImage) {
|
public Dungeon(String name) {
|
||||||
this.id = UUID.randomUUID();
|
super(name);
|
||||||
this.name = name;
|
|
||||||
this.expansionSetCodeForImage = expansionSetCodeForImage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dungeon(final Dungeon dungeon) {
|
public Dungeon(final Dungeon dungeon) {
|
||||||
this.id = dungeon.id;
|
super(dungeon);
|
||||||
this.name = dungeon.name;
|
|
||||||
this.frameStyle = dungeon.frameStyle;
|
this.frameStyle = dungeon.frameStyle;
|
||||||
this.controllerId = dungeon.controllerId;
|
this.controllerId = dungeon.controllerId;
|
||||||
this.copy = dungeon.copy;
|
this.copy = dungeon.copy;
|
||||||
this.copyFrom = (dungeon.copyFrom != null ? dungeon.copyFrom : null);
|
this.copyFrom = (dungeon.copyFrom != null ? dungeon.copyFrom : null);
|
||||||
this.expansionSetCodeForImage = dungeon.expansionSetCodeForImage;
|
|
||||||
this.copyRooms(dungeon);
|
this.copyRooms(dungeon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,7 +84,7 @@ public class Dungeon implements CommandObject {
|
||||||
|
|
||||||
public void addRoom(DungeonRoom room) {
|
public void addRoom(DungeonRoom room) {
|
||||||
this.dungeonRooms.add(room);
|
this.dungeonRooms.add(room);
|
||||||
room.getRoomTriggeredAbility().setSourceId(id);
|
room.getRoomTriggeredAbility().setSourceId(this.getId());
|
||||||
this.abilites.add(room.getRoomTriggeredAbility());
|
this.abilites.add(room.getRoomTriggeredAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,11 +166,6 @@ public class Dungeon implements CommandObject {
|
||||||
return frameStyle;
|
return frameStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void assignNewId() {
|
|
||||||
this.id = UUID.randomUUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MageObject getSourceObject() {
|
public MageObject getSourceObject() {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -214,30 +202,6 @@ public class Dungeon implements CommandObject {
|
||||||
return this.copyFrom;
|
return this.copyFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getIdName() {
|
|
||||||
return getName() + " [" + getId().toString().substring(0, 3) + ']';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLogName() {
|
|
||||||
return GameLog.getColoredObjectIdName(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getImageName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setName(String name) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CardType> getCardType(Game game) {
|
public List<CardType> getCardType(Game game) {
|
||||||
return emptyList;
|
return emptyList;
|
||||||
|
|
@ -326,26 +290,11 @@ public class Dungeon implements CommandObject {
|
||||||
public void setStartingDefense(int startingDefense) {
|
public void setStartingDefense(int startingDefense) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dungeon copy() {
|
public Dungeon copy() {
|
||||||
return new Dungeon(this);
|
return new Dungeon(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getExpansionSetCodeForImage() {
|
|
||||||
return expansionSetCodeForImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setExpansionSetCodeForImage(String expansionSetCodeForImage) {
|
|
||||||
this.expansionSetCodeForImage = expansionSetCodeForImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getZoneChangeCounter(Game game) {
|
public int getZoneChangeCounter(Game game) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,14 @@ import mage.abilities.effects.ContinuousEffect;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.FrameStyle;
|
import mage.cards.FrameStyle;
|
||||||
|
import mage.cards.repository.TokenInfo;
|
||||||
|
import mage.cards.repository.TokenRepository;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.constants.SuperType;
|
import mage.constants.SuperType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
|
import mage.game.permanent.token.TokenImpl;
|
||||||
import mage.util.GameLog;
|
import mage.util.GameLog;
|
||||||
import mage.util.RandomUtil;
|
import mage.util.RandomUtil;
|
||||||
import mage.util.SubTypes;
|
import mage.util.SubTypes;
|
||||||
|
|
@ -27,40 +30,31 @@ import java.util.*;
|
||||||
/**
|
/**
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
*/
|
*/
|
||||||
public class Emblem implements CommandObject {
|
public abstract class Emblem extends CommandObjectImpl {
|
||||||
|
|
||||||
private static final List<CardType> emptyList = Collections.unmodifiableList(new ArrayList<>());
|
private static final List<CardType> emptyList = Collections.unmodifiableList(new ArrayList<>());
|
||||||
private static final ObjectColor emptyColor = new ObjectColor();
|
private static final ObjectColor emptyColor = new ObjectColor();
|
||||||
private static final ManaCosts emptyCost = new ManaCostsImpl<>();
|
private static final ManaCosts emptyCost = new ManaCostsImpl<>();
|
||||||
|
|
||||||
private String name = "";
|
|
||||||
private UUID id;
|
|
||||||
private UUID controllerId;
|
private UUID controllerId;
|
||||||
private MageObject sourceObject;
|
private MageObject sourceObject;
|
||||||
private boolean copy;
|
private boolean copy;
|
||||||
private MageObject copyFrom; // copied card INFO (used to call original adjusters)
|
private MageObject copyFrom; // copied card INFO (used to call original adjusters)
|
||||||
private FrameStyle frameStyle;
|
private FrameStyle frameStyle;
|
||||||
private Abilities<Ability> abilites = new AbilitiesImpl<>();
|
private Abilities<Ability> abilites = new AbilitiesImpl<>();
|
||||||
private String expansionSetCodeForImage = "";
|
|
||||||
|
|
||||||
// list of set codes emblem images are available for
|
public Emblem(String name) {
|
||||||
protected List<String> availableImageSetCodes = new ArrayList<>();
|
super(name);
|
||||||
|
|
||||||
public Emblem() {
|
|
||||||
this.id = UUID.randomUUID();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Emblem(final Emblem emblem) {
|
public Emblem(final Emblem emblem) {
|
||||||
this.id = emblem.id;
|
super(emblem);
|
||||||
this.name = emblem.name;
|
|
||||||
this.frameStyle = emblem.frameStyle;
|
this.frameStyle = emblem.frameStyle;
|
||||||
this.controllerId = emblem.controllerId;
|
this.controllerId = emblem.controllerId;
|
||||||
this.sourceObject = emblem.sourceObject;
|
this.sourceObject = emblem.sourceObject;
|
||||||
this.copy = emblem.copy;
|
this.copy = emblem.copy;
|
||||||
this.copyFrom = (emblem.copyFrom != null ? emblem.copyFrom : null);
|
this.copyFrom = (emblem.copyFrom != null ? emblem.copyFrom : null);
|
||||||
this.abilites = emblem.abilites.copy();
|
this.abilites = emblem.abilites.copy();
|
||||||
this.expansionSetCodeForImage = emblem.expansionSetCodeForImage;
|
|
||||||
this.availableImageSetCodes = emblem.availableImageSetCodes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -68,25 +62,18 @@ public class Emblem implements CommandObject {
|
||||||
return frameStyle;
|
return frameStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void assignNewId() {
|
|
||||||
this.id = UUID.randomUUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSourceObject(MageObject sourceObject) {
|
public void setSourceObject(MageObject sourceObject) {
|
||||||
this.sourceObject = sourceObject;
|
this.sourceObject = sourceObject;
|
||||||
if (sourceObject instanceof Card) {
|
|
||||||
if (name.isEmpty()) {
|
// choose set code due source
|
||||||
name = sourceObject.getSubtype().toString();
|
TokenInfo foundInfo = TokenRepository.instance.generateTokenInfoBySetCode(this.getClass().getName(), sourceObject.getExpansionSetCode());
|
||||||
}
|
if (foundInfo != null) {
|
||||||
if (expansionSetCodeForImage.isEmpty()) {
|
this.setExpansionSetCode(foundInfo.getSetCode());
|
||||||
expansionSetCodeForImage = ((Card) sourceObject).getExpansionSetCode();
|
this.setCardNumber("");
|
||||||
}
|
this.setImageNumber(foundInfo.getImageNumber());
|
||||||
if (!availableImageSetCodes.isEmpty()) {
|
} else {
|
||||||
if (expansionSetCodeForImage.equals("") || !availableImageSetCodes.contains(expansionSetCodeForImage)) {
|
// how-to fix: add emblem to the tokens-database
|
||||||
expansionSetCodeForImage = availableImageSetCodes.get(RandomUtil.nextInt(availableImageSetCodes.size()));
|
throw new IllegalArgumentException("Wrong code usage: can't find token info for the emblem: " + this.getClass().getName());
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,6 +100,9 @@ public class Emblem implements CommandObject {
|
||||||
this.abilites.setControllerId(controllerId);
|
this.abilites.setControllerId(controllerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
abstract public Emblem copy();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCopy(boolean isCopy, MageObject copyFrom) {
|
public void setCopy(boolean isCopy, MageObject copyFrom) {
|
||||||
this.copy = isCopy;
|
this.copy = isCopy;
|
||||||
|
|
@ -129,31 +119,6 @@ public class Emblem implements CommandObject {
|
||||||
return this.copyFrom;
|
return this.copyFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getIdName() {
|
|
||||||
return getName() + " [" + getId().toString().substring(0, 3) + ']';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLogName() {
|
|
||||||
return GameLog.getColoredObjectIdName(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getImageName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CardType> getCardType(Game game) {
|
public List<CardType> getCardType(Game game) {
|
||||||
return emptyList;
|
return emptyList;
|
||||||
|
|
@ -242,26 +207,6 @@ public class Emblem implements CommandObject {
|
||||||
public void setStartingDefense(int startingDefense) {
|
public void setStartingDefense(int startingDefense) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Emblem copy() {
|
|
||||||
return new Emblem(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getExpansionSetCodeForImage() {
|
|
||||||
return expansionSetCodeForImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setExpansionSetCodeForImage(String expansionSetCodeForImage) {
|
|
||||||
this.expansionSetCodeForImage = expansionSetCodeForImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getZoneChangeCounter(Game game) {
|
public int getZoneChangeCounter(Game game) {
|
||||||
return 1; // Emblems can't move zones until now so return always 1
|
return 1; // Emblems can't move zones until now so return always 1
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ import mage.abilities.effects.ContinuousEffect;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.FrameStyle;
|
import mage.cards.FrameStyle;
|
||||||
|
import mage.cards.repository.TokenInfo;
|
||||||
|
import mage.cards.repository.TokenRepository;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Planes;
|
import mage.constants.Planes;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
|
|
@ -29,29 +31,28 @@ import java.util.*;
|
||||||
/**
|
/**
|
||||||
* @author spjspj
|
* @author spjspj
|
||||||
*/
|
*/
|
||||||
public class Plane implements CommandObject {
|
public abstract class Plane extends CommandObjectImpl {
|
||||||
|
|
||||||
private static final List<CardType> emptyList = Collections.unmodifiableList(new ArrayList<>());
|
private static final List<CardType> emptyList = Collections.unmodifiableList(new ArrayList<>());
|
||||||
private static final ObjectColor emptyColor = new ObjectColor();
|
private static final ObjectColor emptyColor = new ObjectColor();
|
||||||
private static final ManaCosts emptyCost = new ManaCostsImpl<>();
|
private static final ManaCosts emptyCost = new ManaCostsImpl<>();
|
||||||
|
|
||||||
private Planes planeType = null;
|
private Planes planeType = null;
|
||||||
private UUID id;
|
|
||||||
private UUID controllerId;
|
private UUID controllerId;
|
||||||
private MageObject sourceObject;
|
private MageObject sourceObject;
|
||||||
private boolean copy;
|
private boolean copy;
|
||||||
private MageObject copyFrom; // copied card INFO (used to call original adjusters)
|
private MageObject copyFrom; // copied card INFO (used to call original adjusters)
|
||||||
private FrameStyle frameStyle;
|
private FrameStyle frameStyle;
|
||||||
private Abilities<Ability> abilites = new AbilitiesImpl<>();
|
private Abilities<Ability> abilites = new AbilitiesImpl<>();
|
||||||
private String expansionSetCodeForImage = "";
|
|
||||||
|
|
||||||
public Plane() {
|
public Plane() {
|
||||||
this.id = UUID.randomUUID();
|
super("");
|
||||||
this.frameStyle = FrameStyle.M15_NORMAL;
|
this.frameStyle = FrameStyle.M15_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Plane(final Plane plane) {
|
public Plane(final Plane plane) {
|
||||||
this.id = plane.id;
|
super(plane);
|
||||||
this.planeType = plane.planeType;
|
this.planeType = plane.planeType;
|
||||||
this.frameStyle = plane.frameStyle;
|
this.frameStyle = plane.frameStyle;
|
||||||
this.controllerId = plane.controllerId;
|
this.controllerId = plane.controllerId;
|
||||||
|
|
@ -59,7 +60,6 @@ public class Plane implements CommandObject {
|
||||||
this.copy = plane.copy;
|
this.copy = plane.copy;
|
||||||
this.copyFrom = (plane.copyFrom != null ? plane.copyFrom.copy() : null);
|
this.copyFrom = (plane.copyFrom != null ? plane.copyFrom.copy() : null);
|
||||||
this.abilites = plane.abilites.copy();
|
this.abilites = plane.abilites.copy();
|
||||||
this.expansionSetCodeForImage = plane.expansionSetCodeForImage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -67,17 +67,18 @@ public class Plane implements CommandObject {
|
||||||
return frameStyle;
|
return frameStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setSourceObject() {
|
||||||
public void assignNewId() {
|
this.sourceObject = null;
|
||||||
this.id = UUID.randomUUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSourceObject(MageObject sourceObject) {
|
// choose set code due source
|
||||||
this.sourceObject = sourceObject;
|
TokenInfo foundInfo = TokenRepository.instance.generateTokenInfoBySetCode(this.getClass().getName(), null);
|
||||||
if (sourceObject instanceof Card) {
|
if (foundInfo != null) {
|
||||||
if (expansionSetCodeForImage.isEmpty()) {
|
this.setExpansionSetCode(foundInfo.getSetCode());
|
||||||
expansionSetCodeForImage = ((Card) sourceObject).getExpansionSetCode();
|
this.setCardNumber("");
|
||||||
}
|
this.setImageNumber(foundInfo.getImageNumber());
|
||||||
|
} else {
|
||||||
|
// how-to fix: add plane to the tokens-database
|
||||||
|
throw new IllegalArgumentException("Wrong code usage: can't find token info for the plane: " + this.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,6 +105,9 @@ public class Plane implements CommandObject {
|
||||||
this.abilites.setControllerId(controllerId);
|
this.abilites.setControllerId(controllerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
abstract public Plane copy();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCopy(boolean isCopy, MageObject copyFrom) {
|
public void setCopy(boolean isCopy, MageObject copyFrom) {
|
||||||
this.copy = isCopy;
|
this.copy = isCopy;
|
||||||
|
|
@ -125,21 +129,6 @@ public class Plane implements CommandObject {
|
||||||
return planeType != null ? planeType.getFullName() : "";
|
return planeType != null ? planeType.getFullName() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getIdName() {
|
|
||||||
return getName() + " [" + getId().toString().substring(0, 3) + ']';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLogName() {
|
|
||||||
return GameLog.getColoredObjectIdName(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getImageName() {
|
|
||||||
return planeType != null ? planeType.getFullName() : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
throw new UnsupportedOperationException("Planes don't use setName, use setPlaneType instead");
|
throw new UnsupportedOperationException("Planes don't use setName, use setPlaneType instead");
|
||||||
|
|
@ -241,29 +230,9 @@ public class Plane implements CommandObject {
|
||||||
public void setStartingDefense(int startingDefense) {
|
public void setStartingDefense(int startingDefense) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plane copy() {
|
|
||||||
return new Plane(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getExpansionSetCodeForImage() {
|
|
||||||
return expansionSetCodeForImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setExpansionSetCodeForImage(String expansionSetCodeForImage) {
|
|
||||||
this.expansionSetCodeForImage = expansionSetCodeForImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getZoneChangeCounter(Game game) {
|
public int getZoneChangeCounter(Game game) {
|
||||||
return 1; // Emblems can't move zones until now so return always 1
|
return 1; // Planes can't move zones until now so return always 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -311,6 +280,7 @@ public class Plane implements CommandObject {
|
||||||
Constructor<?> cons = c.getConstructor();
|
Constructor<?> cons = c.getConstructor();
|
||||||
Object plane = cons.newInstance();
|
Object plane = cons.newInstance();
|
||||||
if (plane instanceof Plane) {
|
if (plane instanceof Plane) {
|
||||||
|
// TODO: generate image for plane here?
|
||||||
return (Plane) plane;
|
return (Plane) plane;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
|
||||||
|
|
@ -126,9 +126,10 @@ public class PermanentCard extends PermanentImpl {
|
||||||
this.subtype.copyFrom(card.getSubtype());
|
this.subtype.copyFrom(card.getSubtype());
|
||||||
this.supertype.clear();
|
this.supertype.clear();
|
||||||
this.supertype.addAll(card.getSuperType());
|
this.supertype.addAll(card.getSuperType());
|
||||||
this.expansionSetCode = card.getExpansionSetCode();
|
|
||||||
|
this.setExpansionSetCode(card.getExpansionSetCode());
|
||||||
|
this.setCardNumber(card.getCardNumber());
|
||||||
this.rarity = card.getRarity();
|
this.rarity = card.getRarity();
|
||||||
this.cardNumber = card.getCardNumber();
|
|
||||||
this.usesVariousArt = card.getUsesVariousArt();
|
this.usesVariousArt = card.getUsesVariousArt();
|
||||||
|
|
||||||
if (card.getSecondCardFace() != null) {
|
if (card.getSecondCardFace() != null) {
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = threadLocalBuilder.get();
|
StringBuilder sb = threadLocalBuilder.get();
|
||||||
sb.append(this.getName()).append('-').append(this.expansionSetCode);
|
sb.append(this.getName()).append('-').append(this.getExpansionSetCode());
|
||||||
if (copy) {
|
if (copy) {
|
||||||
sb.append(" [Copy]");
|
sb.append(" [Copy]");
|
||||||
}
|
}
|
||||||
|
|
@ -1184,7 +1184,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
@Override
|
@Override
|
||||||
public boolean entersBattlefield(Ability source, Game game, Zone fromZone, boolean fireEvent) {
|
public boolean entersBattlefield(Ability source, Game game, Zone fromZone, boolean fireEvent) {
|
||||||
controlledFromStartOfControllerTurn = false;
|
controlledFromStartOfControllerTurn = false;
|
||||||
if (this.isFaceDown(game)) { // ?? add morphed/manifested here ??
|
if (this.isFaceDown(game)) { // ?? add morphed/manifested here ???
|
||||||
// remove some attributes here, because first apply effects comes later otherwise abilities (e.g. color related) will unintended trigger
|
// remove some attributes here, because first apply effects comes later otherwise abilities (e.g. color related) will unintended trigger
|
||||||
MorphAbility.setPermanentToFaceDownCreature(this, this, game);
|
MorphAbility.setPermanentToFaceDownCreature(this, this, game);
|
||||||
}
|
}
|
||||||
|
|
@ -1782,16 +1782,6 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
morphed = value;
|
morphed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCardNumber(String cardNumber) {
|
|
||||||
this.cardNumber = cardNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setExpansionSetCode(String expansionSetCode) {
|
|
||||||
this.expansionSetCode = expansionSetCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRarity(Rarity rarity) {
|
public void setRarity(Rarity rarity) {
|
||||||
this.rarity = rarity;
|
this.rarity = rarity;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import mage.constants.EmptyNames;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
@ -73,6 +74,11 @@ public class PermanentToken extends PermanentImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s - %s", getExpansionSetCode(), getName());
|
||||||
|
}
|
||||||
|
|
||||||
private void copyFromToken(Token token, Game game, boolean reset) {
|
private void copyFromToken(Token token, Game game, boolean reset) {
|
||||||
// modify all attributes permanently (without game usage)
|
// modify all attributes permanently (without game usage)
|
||||||
this.name = token.getName();
|
this.name = token.getName();
|
||||||
|
|
@ -105,6 +111,8 @@ public class PermanentToken extends PermanentImpl {
|
||||||
if (this.abilities.containsClass(ChangelingAbility.class)) {
|
if (this.abilities.containsClass(ChangelingAbility.class)) {
|
||||||
this.subtype.setIsAllCreatureTypes(true);
|
this.subtype.setIsAllCreatureTypes(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CardUtil.copySetAndCardNumber(this, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -144,24 +152,4 @@ public class PermanentToken extends PermanentImpl {
|
||||||
public MageObject getOtherFace() {
|
public MageObject getOtherFace() {
|
||||||
return this.transformed ? token : this.token.getBackFace();
|
return this.transformed ? token : this.token.getBackFace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCardNumber() {
|
|
||||||
return token.getOriginalCardNumber();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCardNumber(String cardNumber) {
|
|
||||||
throw new IllegalArgumentException("Wrong code usage: you can't change a token's card number");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getExpansionSetCode() {
|
|
||||||
return token.getOriginalExpansionSetCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setExpansionSetCode(String expansionSetCode) {
|
|
||||||
throw new IllegalArgumentException("Wrong code usage: you can't change a token's set code, use CardUtils.copySetAndCardNumber instead");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -202,6 +202,36 @@ public class Spell extends StackObjectImpl implements Card {
|
||||||
return GameLog.replaceNameByColoredName(card, getSpellAbility().toString());
|
return GameLog.replaceNameByColoredName(card, getSpellAbility().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExpansionSetCode() {
|
||||||
|
return card.getExpansionSetCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setExpansionSetCode(String expansionSetCode) {
|
||||||
|
throw new IllegalStateException("Wrong code usage: you can't change set code for the spell");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCardNumber() {
|
||||||
|
return card.getCardNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCardNumber(String cardNumber) {
|
||||||
|
throw new IllegalStateException("Wrong code usage: you can't change card number for the spell");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getImageNumber() {
|
||||||
|
return card.getImageNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setImageNumber(Integer imageNumber) {
|
||||||
|
throw new IllegalStateException("Wrong code usage: you can't change image number for the spell");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean resolve(Game game) {
|
public boolean resolve(Game game) {
|
||||||
boolean result;
|
boolean result;
|
||||||
|
|
@ -481,11 +511,6 @@ public class Spell extends StackObjectImpl implements Card {
|
||||||
return GameLog.getColoredObjectIdName(card);
|
return GameLog.getColoredObjectIdName(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getImageName() {
|
|
||||||
return card.getImageName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
}
|
}
|
||||||
|
|
@ -704,11 +729,6 @@ public class Spell extends StackObjectImpl implements Card {
|
||||||
return card.getRules(game);
|
return card.getRules(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getExpansionSetCode() {
|
|
||||||
return card.getExpansionSetCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFaceDown(boolean value, Game game) {
|
public void setFaceDown(boolean value, Game game) {
|
||||||
faceDown = value;
|
faceDown = value;
|
||||||
|
|
@ -875,11 +895,6 @@ public class Spell extends StackObjectImpl implements Card {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCardNumber() {
|
|
||||||
return card.getCardNumber();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getUsesVariousArt() {
|
public boolean getUsesVariousArt() {
|
||||||
return card.getUsesVariousArt();
|
return card.getUsesVariousArt();
|
||||||
|
|
|
||||||
|
|
@ -52,23 +52,23 @@ public class StackAbility extends StackObjectImpl implements Ability {
|
||||||
private boolean copy;
|
private boolean copy;
|
||||||
private MageObject copyFrom; // copied card INFO (used to call original adjusters)
|
private MageObject copyFrom; // copied card INFO (used to call original adjusters)
|
||||||
private String name;
|
private String name;
|
||||||
private String expansionSetCode;
|
|
||||||
private TargetAdjuster targetAdjuster = null;
|
private TargetAdjuster targetAdjuster = null;
|
||||||
private CostAdjuster costAdjuster = null;
|
private CostAdjuster costAdjuster = null;
|
||||||
|
|
||||||
public StackAbility(Ability ability, UUID controllerId) {
|
public StackAbility(Ability ability, UUID controllerId) {
|
||||||
|
super();
|
||||||
this.ability = ability;
|
this.ability = ability;
|
||||||
this.controllerId = controllerId;
|
this.controllerId = controllerId;
|
||||||
this.name = "stack ability (" + ability.getRule() + ')';
|
this.name = "stack ability (" + ability.getRule() + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
public StackAbility(final StackAbility stackAbility) {
|
public StackAbility(final StackAbility stackAbility) {
|
||||||
|
super();
|
||||||
this.ability = stackAbility.ability.copy();
|
this.ability = stackAbility.ability.copy();
|
||||||
this.controllerId = stackAbility.controllerId;
|
this.controllerId = stackAbility.controllerId;
|
||||||
this.copy = stackAbility.copy;
|
this.copy = stackAbility.copy;
|
||||||
this.copyFrom = (stackAbility.copyFrom != null ? stackAbility.copyFrom.copy() : null);
|
this.copyFrom = (stackAbility.copyFrom != null ? stackAbility.copyFrom.copy() : null);
|
||||||
this.name = stackAbility.name;
|
this.name = stackAbility.name;
|
||||||
this.expansionSetCode = stackAbility.expansionSetCode;
|
|
||||||
this.targetAdjuster = stackAbility.targetAdjuster;
|
this.targetAdjuster = stackAbility.targetAdjuster;
|
||||||
this.targetChanged = stackAbility.targetChanged;
|
this.targetChanged = stackAbility.targetChanged;
|
||||||
this.costAdjuster = stackAbility.costAdjuster;
|
this.costAdjuster = stackAbility.costAdjuster;
|
||||||
|
|
@ -128,6 +128,36 @@ public class StackAbility extends StackObjectImpl implements Ability {
|
||||||
return this.copyFrom;
|
return this.copyFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExpansionSetCode() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setExpansionSetCode(String expansionSetCode) {
|
||||||
|
throw new IllegalStateException("Wrong code usage: you can't change set code for the stack ability");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCardNumber() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCardNumber(String cardNumber) {
|
||||||
|
throw new IllegalStateException("Wrong code usage: you can't change card number for the stack ability");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getImageNumber() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setImageNumber(Integer imageNumber) {
|
||||||
|
throw new IllegalStateException("Wrong code usage: you can't change image number for the stack ability");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
|
|
@ -144,12 +174,8 @@ public class StackAbility extends StackObjectImpl implements Ability {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getImageName() {
|
public void setName(String name) {
|
||||||
return name;
|
this.name = name;
|
||||||
}
|
|
||||||
|
|
||||||
public String getExpansionSetCode() {
|
|
||||||
return expansionSetCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -384,15 +410,6 @@ public class StackAbility extends StackObjectImpl implements Ability {
|
||||||
return new StackAbility(this);
|
return new StackAbility(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExpansionSetCode(String expansionSetCode) {
|
|
||||||
this.expansionSetCode = expansionSetCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkIfClause(Game game) {
|
public boolean checkIfClause(Game game) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -1786,61 +1786,40 @@ public final class CardUtil {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy image related data from one object to another (card number, set code, token type)
|
* Copy image related data from one object to another (set code, card number, image number)
|
||||||
* Use it in copy/transform effects
|
* Use it in copy/transform effects
|
||||||
*/
|
*/
|
||||||
public static void copySetAndCardNumber(MageObject targetObject, MageObject copyFromObject) {
|
public static void copySetAndCardNumber(MageObject targetObject, MageObject copyFromObject) {
|
||||||
String needSetCode;
|
String needSetCode;
|
||||||
String needCardNumber;
|
String needCardNumber;
|
||||||
int needTokenType;
|
int needImageNumber;
|
||||||
if (copyFromObject instanceof CommandObject) {
|
needSetCode = copyFromObject.getExpansionSetCode();
|
||||||
needSetCode = ((CommandObject) copyFromObject).getExpansionSetCodeForImage();
|
needCardNumber = copyFromObject.getCardNumber();
|
||||||
needCardNumber = "0";
|
needImageNumber = copyFromObject.getImageNumber();
|
||||||
needTokenType = 0;
|
|
||||||
} else if (copyFromObject instanceof PermanentCard) {
|
|
||||||
needSetCode = ((PermanentCard) copyFromObject).getExpansionSetCode();
|
|
||||||
needCardNumber = ((PermanentCard) copyFromObject).getCardNumber();
|
|
||||||
needTokenType = 0;
|
|
||||||
} else if (copyFromObject instanceof PermanentToken) {
|
|
||||||
needSetCode = ((PermanentToken) copyFromObject).getToken().getOriginalExpansionSetCode();
|
|
||||||
needCardNumber = ((PermanentToken) copyFromObject).getToken().getOriginalCardNumber();
|
|
||||||
needTokenType = ((PermanentToken) copyFromObject).getToken().getTokenType();
|
|
||||||
} else if (copyFromObject instanceof Card) {
|
|
||||||
needSetCode = ((Card) copyFromObject).getExpansionSetCode();
|
|
||||||
needCardNumber = ((Card) copyFromObject).getCardNumber();
|
|
||||||
needTokenType = 0;
|
|
||||||
} else if (copyFromObject instanceof Token) {
|
|
||||||
needSetCode = ((Token) copyFromObject).getOriginalExpansionSetCode();
|
|
||||||
needCardNumber = ((Token) copyFromObject).getOriginalCardNumber();
|
|
||||||
needTokenType = ((Token) copyFromObject).getTokenType();
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("Unsupported copyFromObject class: " + copyFromObject.getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetObject instanceof Permanent) {
|
if (targetObject instanceof Permanent) {
|
||||||
copySetAndCardNumber((Permanent) targetObject, needSetCode, needCardNumber, needTokenType);
|
copySetAndCardNumber((Permanent) targetObject, needSetCode, needCardNumber, needImageNumber);
|
||||||
} else if (targetObject instanceof Token) {
|
} else if (targetObject instanceof Token) {
|
||||||
copySetAndCardNumber((Token) targetObject, needSetCode, needCardNumber, needTokenType);
|
copySetAndCardNumber((Token) targetObject, needSetCode, needCardNumber, needImageNumber);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Unsupported target object class: " + targetObject.getClass().getSimpleName());
|
throw new IllegalStateException("Unsupported target object class: " + targetObject.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copySetAndCardNumber(Permanent targetPermanent, String newSetCode, String newCardNumber, Integer newTokenType) {
|
private static void copySetAndCardNumber(Permanent targetPermanent, String newSetCode, String newCardNumber, Integer newImageNumber) {
|
||||||
if (targetPermanent instanceof PermanentToken) {
|
if (targetPermanent instanceof PermanentCard
|
||||||
copySetAndCardNumber(((PermanentToken) targetPermanent).getToken(), newSetCode, newCardNumber, newTokenType);
|
|| targetPermanent instanceof PermanentToken) {
|
||||||
} else if (targetPermanent instanceof PermanentCard) {
|
|
||||||
targetPermanent.setExpansionSetCode(newSetCode);
|
targetPermanent.setExpansionSetCode(newSetCode);
|
||||||
targetPermanent.setCardNumber(newCardNumber);
|
targetPermanent.setCardNumber(newCardNumber);
|
||||||
|
targetPermanent.setImageNumber(newImageNumber);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Wrong code usage: un-supported target permanent type: " + targetPermanent.getClass().getSimpleName());
|
throw new IllegalArgumentException("Wrong code usage: un-supported target permanent type: " + targetPermanent.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copySetAndCardNumber(Token targetToken, String newSetCode, String newCardNumber, Integer newTokenType) {
|
private static void copySetAndCardNumber(Token targetToken, String newSetCode, String newCardNumber, Integer newImageNumber) {
|
||||||
targetToken.setOriginalExpansionSetCode(newSetCode);
|
targetToken.setExpansionSetCode(newSetCode);
|
||||||
targetToken.setExpansionSetCodeForImage(newSetCode);
|
targetToken.setCardNumber(newCardNumber);
|
||||||
targetToken.setOriginalCardNumber(newCardNumber);
|
targetToken.setImageNumber(newImageNumber);
|
||||||
targetToken.setTokenType(newTokenType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
# Contains all possible emblems, planes, dungeons and tokens
|
# Contains all possible emblems, planes, dungeons and tokens
|
||||||
# All objects must have an image (private tokens don't have image,
|
# All objects must have an image (private tokens don't have image,
|
||||||
# so can be ignored)
|
# so can be ignored, use TokenCreature instead)
|
||||||
|
# One class for same images (if you have 2/2 and */* then must use different classes)
|
||||||
|
|
||||||
# Use verify test to check it: test_checkMissingTokenData
|
# Use verify test to check it: test_checkMissingTokenData
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue