mirror of
https://github.com/magefree/mage.git
synced 2025-12-30 07:22:03 -08:00
Tokens improved:
- added auto-generated token names for CreatureToken; - added verify tests for token names; - removed outdated ElementalCreatureToken; - fixed wrong indefinite article in some tokens; - fixed miss Token in some token names (related to #10139);
This commit is contained in:
parent
e2d2d1f08e
commit
6ed702a7b3
13 changed files with 190 additions and 69 deletions
|
|
@ -15,7 +15,7 @@ public final class NestingDragonToken extends TokenImpl {
|
|||
|
||||
public NestingDragonToken() {
|
||||
super(
|
||||
"Dragon Egg",
|
||||
"Dragon Egg Token",
|
||||
"0/2 red Dragon Egg creature token with defender and "
|
||||
+ "\""
|
||||
+ "When this creature dies, "
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public final class OviyaPashiriSageLifecrafterToken extends TokenImpl {
|
|||
}
|
||||
|
||||
public OviyaPashiriSageLifecrafterToken(int number) {
|
||||
super("Construct Token", "an X/X colorless Construct artifact creature token, where X is the number of creatures you control");
|
||||
super("Construct Token", "X/X colorless Construct artifact creature token, where X is the number of creatures you control");
|
||||
cardType.add(CardType.ARTIFACT);
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add(SubType.CONSTRUCT);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import mage.constants.SubType;
|
|||
public class RatRogueToken extends TokenImpl {
|
||||
|
||||
public RatRogueToken() {
|
||||
super("Rat Rogue", "1/1 black Rat Rogue creature token");
|
||||
super("Rat Rogue Token", "1/1 black Rat Rogue creature token");
|
||||
cardType.add(CardType.CREATURE);
|
||||
color.setBlack(true);
|
||||
subtype.add(SubType.RAT);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import mage.MageInt;
|
|||
public final class SubterraneanTremorsLizardToken extends TokenImpl {
|
||||
|
||||
public SubterraneanTremorsLizardToken() {
|
||||
super("Lizard Token", "an 8/8 red Lizard creature token");
|
||||
super("Lizard Token", "8/8 red Lizard creature token");
|
||||
cardType.add(CardType.CREATURE);
|
||||
color.setRed(true);
|
||||
subtype.add(SubType.LIZARD);
|
||||
|
|
|
|||
|
|
@ -5,13 +5,15 @@ import mage.ObjectColor;
|
|||
import mage.abilities.Ability;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.permanent.token.Token;
|
||||
import mage.game.permanent.token.TokenImpl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Token builder for token effects
|
||||
*
|
||||
* <p>
|
||||
* Use it for custom tokens (tokens without public class and image)
|
||||
*
|
||||
* @author JayDi85
|
||||
|
|
@ -27,7 +29,7 @@ public final class CreatureToken extends TokenImpl {
|
|||
}
|
||||
|
||||
public CreatureToken(int power, int toughness, String description) {
|
||||
this(power, toughness, description, null);
|
||||
this(power, toughness, description, (SubType[]) null);
|
||||
}
|
||||
|
||||
public CreatureToken(int power, int toughness, String description, SubType... extraSubTypes) {
|
||||
|
|
@ -41,6 +43,11 @@ public final class CreatureToken extends TokenImpl {
|
|||
}
|
||||
}
|
||||
|
||||
public CreatureToken withName(String name) {
|
||||
this.setName(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CreatureToken withAbility(Ability ability) {
|
||||
this.addAbility(ability);
|
||||
return this;
|
||||
|
|
@ -73,4 +80,24 @@ public final class CreatureToken extends TokenImpl {
|
|||
public CreatureToken copy() {
|
||||
return new CreatureToken(this);
|
||||
}
|
||||
|
||||
private static String AutoGenerateTokenName(Token token) {
|
||||
// 111.4. A spell or ability that creates a token sets both its name and its subtype(s).
|
||||
// If the spell or ability doesn’t specify the name of the token,
|
||||
// its name is the same as its subtype(s) plus the word “Token.”
|
||||
// Once a token is on the battlefield, changing its name doesn’t change its subtype(s), and vice versa.
|
||||
return token.getSubtype()
|
||||
.stream()
|
||||
.map(SubType::getDescription)
|
||||
.collect(Collectors.joining(" ")) + " Token";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
String name = super.getName();
|
||||
if (name.isEmpty()) {
|
||||
name = AutoGenerateTokenName(this);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
package mage.game.permanent.token.custom;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.ObjectColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.permanent.token.TokenImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JayDi85
|
||||
*/
|
||||
public final class ElementalCreatureToken extends TokenImpl {
|
||||
|
||||
public ElementalCreatureToken() {
|
||||
this(0, 0);
|
||||
}
|
||||
|
||||
public ElementalCreatureToken(int power, int toughness) {
|
||||
this(power, toughness, String.format("%d/%d Elemental creature", power, toughness));
|
||||
}
|
||||
|
||||
public ElementalCreatureToken(int power, int toughness, String description) {
|
||||
this(power, toughness, description, (ObjectColor) null);
|
||||
}
|
||||
|
||||
public ElementalCreatureToken(int power, int toughness, String description, ObjectColor color) {
|
||||
super("", description);
|
||||
this.cardType.add(CardType.CREATURE);
|
||||
this.subtype.add(SubType.ELEMENTAL);
|
||||
|
||||
this.power = new MageInt(power);
|
||||
this.toughness = new MageInt(toughness);
|
||||
|
||||
if (color != null) {
|
||||
this.color.addColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
public ElementalCreatureToken(final ElementalCreatureToken token) {
|
||||
super(token);
|
||||
}
|
||||
|
||||
public ElementalCreatureToken copy() {
|
||||
return new ElementalCreatureToken(this);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue