Merge fix

This commit is contained in:
Oleg Agafonov 2023-04-13 17:06:22 +04:00
parent d17df585c5
commit 01caeed298
4 changed files with 35 additions and 11 deletions

View file

@ -448,7 +448,7 @@ public class MageBook extends JComponent {
if (cardDimension == null) { if (cardDimension == null) {
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight()); cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
} }
PermanentToken newToken = new PermanentToken(token, null, token.getOriginalExpansionSetCode(), null); PermanentToken newToken = new PermanentToken(token, null, null);
newToken.removeSummoningSickness(); newToken.removeSummoningSickness();
PermanentView theToken = new PermanentView(newToken, null, null, null); PermanentView theToken = new PermanentView(newToken, null, null, null);
theToken.setInViewerOnly(true); theToken.setInViewerOnly(true);

View file

@ -7,6 +7,7 @@ import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.Card; import mage.cards.Card;
import mage.constants.*; import mage.constants.*;
import mage.game.Game; import mage.game.Game;
import mage.game.command.CommandObject;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard; import mage.game.permanent.PermanentCard;
import mage.game.permanent.PermanentToken; import mage.game.permanent.PermanentToken;
@ -142,13 +143,38 @@ public class CopyEffect extends ContinuousEffectImpl {
} }
// to get the image of the copied permanent copy number und expansionCode // to get the image of the copied permanent copy number und expansionCode
if (copyFromObject instanceof PermanentCard) { String needSetCode;
permanent.setCardNumber(((PermanentCard) copyFromObject).getCard().getCardNumber()); String needCardNumber;
permanent.setExpansionSetCode(((PermanentCard) copyFromObject).getCard().getExpansionSetCode()); int needTokenType;
} else if (copyFromObject instanceof PermanentToken || copyFromObject instanceof Card) { if (copyFromObject instanceof CommandObject) {
permanent.setCardNumber(((Card) copyFromObject).getCardNumber()); needSetCode = ((CommandObject) copyFromObject).getExpansionSetCodeForImage();
permanent.setExpansionSetCode(((Card) copyFromObject).getExpansionSetCode()); needCardNumber = "0";
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 {
throw new IllegalStateException("Unsupported copyFromObject class: " + copyFromObject.getClass().getSimpleName());
} }
if (permanent instanceof PermanentToken) {
((PermanentToken) permanent).getToken().setOriginalExpansionSetCode(needSetCode);
((PermanentToken) permanent).getToken().setExpansionSetCodeForImage(needSetCode);
((PermanentToken) permanent).getToken().setTokenType(needTokenType);
} else {
permanent.setExpansionSetCode(needSetCode);
permanent.setCardNumber(needCardNumber);
}
return true; return true;
} }

View file

@ -20,9 +20,8 @@ public class PermanentToken extends PermanentImpl {
protected Token token; protected Token token;
public PermanentToken(Token token, UUID controllerId, String expansionSetCode, Game game) { public PermanentToken(Token token, UUID controllerId, Game game) {
super(controllerId, controllerId, token.getName()); super(controllerId, controllerId, token.getName());
this.expansionSetCode = expansionSetCode;
this.token = token.copy(); this.token = token.copy();
this.token.getAbilities().newOriginalId(); // neccessary if token has ability like DevourAbility() this.token.getAbilities().newOriginalId(); // neccessary if token has ability like DevourAbility()
this.token.getAbilities().setSourceId(objectId); this.token.getAbilities().setSourceId(objectId);
@ -40,7 +39,6 @@ public class PermanentToken extends PermanentImpl {
public PermanentToken(final PermanentToken permanent) { public PermanentToken(final PermanentToken permanent) {
super(permanent); super(permanent);
this.token = permanent.token.copy(); this.token = permanent.token.copy();
this.expansionSetCode = permanent.expansionSetCode;
} }
@Override @Override

View file

@ -252,7 +252,7 @@ public abstract class TokenImpl extends MageObjectImpl implements Token {
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
// TODO: add random setTokenType here? // TODO: add random setTokenType here?
// use event.getPlayerId() as controller because it can be replaced by replacement effect // use event.getPlayerId() as controller because it can be replaced by replacement effect
PermanentToken newPermanent = new PermanentToken(token, event.getPlayerId(), setCode, game); PermanentToken newPermanent = new PermanentToken(token, event.getPlayerId(), game);
game.getState().addCard(newPermanent); game.getState().addCard(newPermanent);
needTokens.add(newPermanent); needTokens.add(newPermanent);
game.getPermanentsEntering().put(newPermanent.getId(), newPermanent); game.getPermanentsEntering().put(newPermanent.getId(), newPermanent);