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:
Oleg Agafonov 2023-05-08 02:15:07 +04:00
parent 46f6593da8
commit 5f55c7c667
45 changed files with 517 additions and 477 deletions

View file

@ -23,7 +23,7 @@ import java.util.List;
import java.util.Set;
import java.util.UUID;
public class Commander implements CommandObject {
public class Commander extends CommandObjectImpl {
private final Card sourceObject;
private boolean copy;
@ -31,6 +31,7 @@ public class Commander implements CommandObject {
private final Abilities<Ability> abilities = new AbilitiesImpl<>();
public Commander(Card card) {
super(card.getName());
this.sourceObject = card;
// 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) {
super(commander);
this.sourceObject = commander.sourceObject.copy();
this.copy = commander.copy;
this.copyFrom = (commander.copyFrom != null ? commander.copyFrom.copy() : null);
@ -127,10 +129,6 @@ public class Commander implements CommandObject {
return sourceObject.getOwnerId();
}
@Override
public void assignNewId() {
}
@Override
public CommandObject copy() {
return new Commander(this);
@ -162,15 +160,6 @@ public class Commander implements CommandObject {
return sourceObject.getName() + " [" + sourceObject.getId().toString().substring(0, 3) + ']';
}
@Override
public String getLogName() {
return GameLog.getColoredObjectIdName(this);
}
@Override
public void setName(String name) {
}
@Override
public List<CardType> getCardType(Game game) {
return sourceObject.getCardType(game);
@ -289,21 +278,6 @@ public class Commander implements CommandObject {
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
public int getZoneChangeCounter(Game game) {
return sourceObject.getZoneChangeCounter(game);