mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
Move updateExpansionSetCode from CreateTokenEffect.apply to Token.putOntoBattlefield
This commit is contained in:
parent
e23fc13db0
commit
9b29cd042f
3 changed files with 15 additions and 17 deletions
|
@ -50,7 +50,6 @@ public class CreateTokenEffect extends OneShotEffect {
|
|||
private boolean attacking;
|
||||
private UUID lastAddedTokenId;
|
||||
private ArrayList<UUID> lastAddedTokenIds = new ArrayList<>();
|
||||
private boolean expansionSetCodeChecked;
|
||||
|
||||
public CreateTokenEffect(Token token) {
|
||||
this(token, new StaticValue(1));
|
||||
|
@ -74,7 +73,6 @@ public class CreateTokenEffect extends OneShotEffect {
|
|||
this.amount = amount.copy();
|
||||
this.tapped = tapped;
|
||||
this.attacking = attacking;
|
||||
this.expansionSetCodeChecked = false;
|
||||
setText();
|
||||
}
|
||||
|
||||
|
@ -86,7 +84,6 @@ public class CreateTokenEffect extends OneShotEffect {
|
|||
this.attacking = effect.attacking;
|
||||
this.lastAddedTokenId = effect.lastAddedTokenId;
|
||||
this.lastAddedTokenIds.addAll(effect.lastAddedTokenIds);
|
||||
this.expansionSetCodeChecked = effect.expansionSetCodeChecked;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,9 +93,6 @@ public class CreateTokenEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (!expansionSetCodeChecked) {
|
||||
expansionSetCodeChecked = Token.updateExpansionSetCode(game, source, token);
|
||||
}
|
||||
int value = amount.calculate(game, source, this);
|
||||
token.putOntoBattlefield(value, game, source.getSourceId(), source.getControllerId(), tapped, attacking);
|
||||
this.lastAddedTokenId = token.getLastAddedToken();
|
||||
|
|
|
@ -19,7 +19,6 @@ public class CreateTokenTargetEffect extends OneShotEffect {
|
|||
private DynamicValue amount;
|
||||
private boolean tapped;
|
||||
private boolean attacking;
|
||||
private boolean expansionSetCodeChecked;
|
||||
|
||||
public CreateTokenTargetEffect(Token token) {
|
||||
this(token, new StaticValue(1));
|
||||
|
@ -39,7 +38,6 @@ public class CreateTokenTargetEffect extends OneShotEffect {
|
|||
this.amount = amount.copy();
|
||||
this.tapped = tapped;
|
||||
this.attacking = attacking;
|
||||
this.expansionSetCodeChecked = false;
|
||||
}
|
||||
|
||||
public CreateTokenTargetEffect(final CreateTokenTargetEffect effect) {
|
||||
|
@ -48,7 +46,6 @@ public class CreateTokenTargetEffect extends OneShotEffect {
|
|||
this.token = effect.token.copy();
|
||||
this.tapped = effect.tapped;
|
||||
this.attacking = effect.attacking;
|
||||
this.expansionSetCodeChecked = effect.expansionSetCodeChecked;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,9 +55,6 @@ public class CreateTokenTargetEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (!expansionSetCodeChecked) {
|
||||
expansionSetCodeChecked = Token.updateExpansionSetCode(game, source, token);
|
||||
}
|
||||
int value = amount.calculate(game, source, this);
|
||||
if (value > 0) {
|
||||
return token.putOntoBattlefield(value, game, source.getSourceId(), targetPointer.getFirst(game, source), tapped, attacking);
|
||||
|
|
|
@ -55,6 +55,7 @@ public class Token extends MageObjectImpl {
|
|||
private int tokenType;
|
||||
private int originalCardNumber;
|
||||
private String originalExpansionSetCode;
|
||||
private boolean expansionSetCodeChecked;
|
||||
private Card copySourceCard; // the card the Token is a copy from
|
||||
|
||||
// list of set codes tokene images are available for
|
||||
|
@ -91,6 +92,7 @@ public class Token extends MageObjectImpl {
|
|||
if (abilities != null) {
|
||||
this.abilities = abilities.copy();
|
||||
}
|
||||
this.expansionSetCodeChecked = false;
|
||||
}
|
||||
|
||||
public Token(final Token token) {
|
||||
|
@ -101,6 +103,7 @@ public class Token extends MageObjectImpl {
|
|||
this.lastAddedTokenIds.addAll(token.lastAddedTokenIds);
|
||||
this.originalCardNumber = token.originalCardNumber;
|
||||
this.originalExpansionSetCode = token.originalExpansionSetCode;
|
||||
this.expansionSetCodeChecked = token.expansionSetCodeChecked;
|
||||
this.copySourceCard = token.copySourceCard; // will never be changed
|
||||
this.availableImageSetCodes = token.availableImageSetCodes;
|
||||
}
|
||||
|
@ -143,8 +146,15 @@ public class Token extends MageObjectImpl {
|
|||
return false;
|
||||
}
|
||||
lastAddedTokenIds.clear();
|
||||
// TODO: Check this setCode handling because it makes no sense if token put into play with e.g. "Feldon of the third Path"
|
||||
|
||||
// moved here from CreateTokenEffect because not all cards that create tokens use CreateTokenEffect
|
||||
// they use putOntoBattlefield directly
|
||||
Card source = game.getCard(sourceId);
|
||||
if (!expansionSetCodeChecked) {
|
||||
expansionSetCodeChecked = this.updateExpansionSetCode(source);
|
||||
}
|
||||
|
||||
// TODO: Check this setCode handling because it makes no sense if token put into play with e.g. "Feldon of the third Path"
|
||||
String setCode;
|
||||
if (this.getOriginalExpansionSetCode() != null && !this.getOriginalExpansionSetCode().isEmpty()) {
|
||||
setCode = this.getOriginalExpansionSetCode();
|
||||
|
@ -248,11 +258,11 @@ public class Token extends MageObjectImpl {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean updateExpansionSetCode(Game game, Ability source, Token token) {
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (sourceObject instanceof Card) {
|
||||
token.setExpansionSetCodeForImage(((Card) sourceObject).getExpansionSetCode());
|
||||
public boolean updateExpansionSetCode(Card source) {
|
||||
if (source == null) {
|
||||
return false;
|
||||
}
|
||||
this.setExpansionSetCodeForImage(source.getExpansionSetCode());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue