private void addToken(Token token, BigCard bigCard, UUID gameId, Rectangle rectangle) { if (cardDimension == null) { cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight); } PermanentToken newToken = new PermanentToken(token, null, token.getOriginalExpansionSetCode(), null); newToken.removeSummoningSickness(); PermanentView theToken = new PermanentView(newToken, null, null, null); theToken.setInViewerOnly(true); final MageCard cardImg = Plugins.instance.getMagePermanent(theToken, bigCard, cardDimension, gameId, true); cardImg.setBounds(rectangle); jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10); cardImg.update(theToken); cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight); }
@Override public void reset(Game game) { copyFromToken(token, game, true); super.reset(game); // Because the P/T objects have there own base value for reset we have to take it from there instead of from the basic token object this.power.resetToBaseValue(); this.toughness.resetToBaseValue(); }
this.mageObjectType = MageObjectType.TOKEN; this.rarity = Rarity.COMMON; boolean originalCardNumberIsNull = ((PermanentToken) card).getToken().getOriginalCardNumber() == null; if (!originalCardNumberIsNull && !"0".equals(((PermanentToken) card).getToken().getOriginalCardNumber())) { this.expansionSetCode = ((PermanentToken) card).getToken().getOriginalExpansionSetCode(); this.cardNumber = ((PermanentToken) card).getToken().getOriginalCardNumber(); } else { this.expansionSetCode = ((PermanentToken) card).getExpansionSetCode(); this.tokenDescriptor = ((PermanentToken) card).getTokenDescriptor(); this.rules = ((PermanentToken) card).getRules(game); this.type = ((PermanentToken) card).getToken().getTokenType(); } else { this.rarity = card.getRarity();
MageObject object = game.getObject(sourceId); if (object instanceof PermanentToken) { setCode = ((PermanentToken) object).getExpansionSetCode(); PermanentToken newToken = new PermanentToken(this, event.getPlayerId(), setCode, game); // use event.getPlayerId() because it can be replaced by replacement effect game.getState().addCard(newToken); permanents.add(newToken); game.getPermanentsEntering().put(newToken.getId(), newToken); newToken.setTapped(tapped);
PermanentToken permanentToken = (PermanentToken) object; this.rarity = Rarity.COMMON; this.expansionSetCode = permanentToken.getExpansionSetCode(); this.rules = permanentToken.getRules(); this.type = permanentToken.getToken().getTokenType(); } else if (object instanceof Emblem) { this.mageObjectType = MageObjectType.EMBLEM;
@Override public PermanentToken copy() { return new PermanentToken(this); }
private void copyFromToken(Token token, Game game, boolean reset) { this.name = token.getName(); this.abilities.clear(); if (reset) { this.abilities.addAll(token.getAbilities()); } else { // first time -> create ContinuousEffects only once for (Ability ability : token.getAbilities()) { this.addAbility(ability, game); } } this.abilities.setControllerId(this.controllerId); this.manaCost.clear(); for (ManaCost cost : token.getManaCost()) { this.getManaCost().add(cost.copy()); } this.cardType.clear(); this.cardType.addAll(token.getCardType()); this.color = token.getColor(game).copy(); this.frameColor = token.getFrameColor(game); this.frameStyle = token.getFrameStyle(); this.supertype.clear(); this.supertype.addAll(token.getSuperType()); this.subtype.clear(); this.subtype.addAll(token.getSubtype(game)); this.isAllCreatureTypes = token.isAllCreatureTypes(); this.tokenDescriptor = token.getTokenDescriptor(); }
if (object instanceof PermanentToken) { PermanentToken token = (PermanentToken) object; stack.put(stackObject.getId(), new StackAbilityView(game, (StackAbility) stackObject, token.getName(), new CardView(token))); checkPaid(stackObject.getId(), (StackAbility) stackObject); } else if (object instanceof Emblem) {
public PermanentToken(Token token, UUID controllerId, String expansionSetCode, Game game) { super(controllerId, controllerId, token.getName()); this.expansionSetCode = expansionSetCode; this.token = token.copy(); this.token.getAbilities().newOriginalId(); // neccessary if token has ability like DevourAbility() this.token.getAbilities().setSourceId(objectId); this.power.modifyBaseValue(token.getPower().getBaseValueModified()); this.toughness.modifyBaseValue(token.getToughness().getBaseValueModified()); this.copyFromToken(this.token, game, false); // needed to have at this time (e.g. for subtypes for entersTheBattlefield replacement effects) }
@Override public boolean apply(Game game, Permanent permanent, Ability source, UUID copyToObjectId) { for (Permanent entering : game.getPermanentsEntering().values()) { if (entering.getId().equals(copyToObjectId) && entering instanceof PermanentToken) { UUID originalCardId = ((PermanentToken) entering).getToken().getCopySourceCard().getId(); EmbalmedThisTurnWatcher watcher = game.getState().getWatcher(EmbalmedThisTurnWatcher.class); if (watcher != null) { for (MageObjectReference mor : watcher.getEmbalmedThisTurnCards()) { if (mor.getSourceId().equals(originalCardId) && game.getState().getZoneChangeCounter(originalCardId) == mor.getZoneChangeCounter()) { permanent.getManaCost().clear(); if (!permanent.hasSubtype(SubType.ZOMBIE, game)) { permanent.getSubtype(game).add(SubType.ZOMBIE); } permanent.getColor(game).setColor(ObjectColor.WHITE); } } } } } return true; }
original = new CardView(((PermanentToken) permanent).getToken()); original.expansionSetCode = permanent.getExpansionSetCode(); tokenSetCode = original.getTokenSetCode();