mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
spjspj - Implement new method for image generation of tokens.
This commit is contained in:
parent
ac5f2ca6cc
commit
0f043d480d
15 changed files with 154 additions and 52 deletions
|
|
@ -65,6 +65,8 @@ public interface Card extends MageObject {
|
|||
String getExpansionSetCode();
|
||||
|
||||
String getTokenSetCode();
|
||||
|
||||
String getTokenDescriptor();
|
||||
|
||||
void checkForCountersToAdd(Permanent permanent, Game game);
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
protected String cardNumber;
|
||||
public String expansionSetCode;
|
||||
protected String tokenSetCode;
|
||||
protected String tokenDescriptor;
|
||||
protected Rarity rarity;
|
||||
protected boolean canTransform;
|
||||
protected Card secondSideCard;
|
||||
|
|
@ -316,6 +317,11 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
public String getTokenSetCode() {
|
||||
return tokenSetCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTokenDescriptor() {
|
||||
return tokenDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getMana() {
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ public class PermanentToken extends PermanentImpl {
|
|||
this.toughness.modifyBaseValue(token.getToughness().getBaseValueModified());
|
||||
this.supertype = token.getSupertype();
|
||||
this.subtype = token.getSubtype();
|
||||
this.tokenDescriptor = token.getTokenDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ public class Token extends MageObjectImpl {
|
|||
private int tokenType;
|
||||
private String originalCardNumber;
|
||||
private String originalExpansionSetCode;
|
||||
private String tokenDescriptor;
|
||||
private boolean expansionSetCodeChecked;
|
||||
private Card copySourceCard; // the card the Token is a copy from
|
||||
|
||||
|
|
@ -113,6 +114,26 @@ public class Token extends MageObjectImpl {
|
|||
this.copySourceCard = token.copySourceCard; // will never be changed
|
||||
this.availableImageSetCodes = token.availableImageSetCodes;
|
||||
}
|
||||
|
||||
private void setTokenDescriptor() {
|
||||
this.tokenDescriptor = tokenDescriptor();
|
||||
}
|
||||
|
||||
public String getTokenDescriptor() {
|
||||
this.tokenDescriptor = tokenDescriptor();
|
||||
return tokenDescriptor;
|
||||
}
|
||||
|
||||
private String tokenDescriptor() {
|
||||
String name = this.name.replaceAll("[^a-zA-Z0-9]", "");
|
||||
String color = this.color.toString().replaceAll("[^a-zA-Z0-9]", "");
|
||||
String subtype = this.subtype.toString().replaceAll("[^a-zA-Z0-9]", "");
|
||||
String cardType = this.cardType.toString().replaceAll("[^a-zA-Z0-9]", "");
|
||||
String originalset = this.getOriginalExpansionSetCode();
|
||||
String descriptor = name + "." + color + "." + subtype + "." + cardType + "." + this.power + "." + this.toughness ;
|
||||
descriptor = descriptor.toUpperCase();
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
|
|
@ -241,13 +262,14 @@ public class Token extends MageObjectImpl {
|
|||
public void setOriginalCardNumber(String originalCardNumber) {
|
||||
this.originalCardNumber = originalCardNumber;
|
||||
}
|
||||
|
||||
public String getOriginalExpansionSetCode() {
|
||||
|
||||
public String getOriginalExpansionSetCode() {
|
||||
return originalExpansionSetCode;
|
||||
}
|
||||
|
||||
public void setOriginalExpansionSetCode(String originalExpansionSetCode) {
|
||||
this.originalExpansionSetCode = originalExpansionSetCode;
|
||||
setTokenDescriptor();
|
||||
}
|
||||
|
||||
public Card getCopySourceCard() {
|
||||
|
|
@ -264,15 +286,20 @@ public class Token extends MageObjectImpl {
|
|||
if (availableImageSetCodes.size() > 0) {
|
||||
if (availableImageSetCodes.contains(code)) {
|
||||
setOriginalExpansionSetCode(code);
|
||||
} else // we should not set random set if appropriate set is already used
|
||||
if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()
|
||||
|| !availableImageSetCodes.contains(getOriginalExpansionSetCode())) {
|
||||
setOriginalExpansionSetCode(availableImageSetCodes.get(new Random().nextInt(availableImageSetCodes.size())));
|
||||
} else {
|
||||
// we should not set random set if appropriate set is already used
|
||||
if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()
|
||||
|| !availableImageSetCodes.contains(getOriginalExpansionSetCode())) {
|
||||
setOriginalExpansionSetCode(availableImageSetCodes.get(new Random().nextInt(availableImageSetCodes.size())));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()) {
|
||||
setOriginalExpansionSetCode(code);
|
||||
}
|
||||
} else if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()) {
|
||||
setOriginalExpansionSetCode(code);
|
||||
}
|
||||
}
|
||||
setTokenDescriptor();
|
||||
}
|
||||
|
||||
public boolean updateExpansionSetCode(String setCode) {
|
||||
if (setCode == null || setCode.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -572,6 +572,11 @@ public class Spell extends StackObjImpl implements Card {
|
|||
public String getTokenSetCode() {
|
||||
return card.getTokenSetCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTokenDescriptor() {
|
||||
return card.getTokenDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFaceDown(boolean value, Game game) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue