Refactoring: replace custom creature tokens with basic class (4 cards)

This commit is contained in:
Oleg Agafonov 2018-05-10 14:03:44 +04:00
parent 256dc94c80
commit 591de4d468
13 changed files with 83 additions and 105 deletions

View file

@ -52,14 +52,14 @@ import java.util.Set;
public class BecomesCreatureAllEffect extends ContinuousEffectImpl {
protected Token token;
protected String type;
protected String theyAreStillType;
private final FilterPermanent filter;
private boolean loseColor = true;
public BecomesCreatureAllEffect(Token token, String type, FilterPermanent filter, Duration duration, boolean loseColor) {
public BecomesCreatureAllEffect(Token token, String theyAreStillType, FilterPermanent filter, Duration duration, boolean loseColor) {
super(duration, Outcome.BecomeCreature);
this.token = token;
this.type = type;
this.theyAreStillType = theyAreStillType;
this.filter = filter;
this.loseColor = loseColor;
}
@ -67,7 +67,7 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl {
public BecomesCreatureAllEffect(final BecomesCreatureAllEffect effect) {
super(effect);
this.token = effect.token.copy();
this.type = effect.type;
this.theyAreStillType = effect.theyAreStillType;
this.filter = effect.filter.copy();
this.loseColor = effect.loseColor;
}
@ -110,7 +110,7 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl {
}
}
}
if (type == null) {
if (theyAreStillType == null) {
permanent.getSubtype(game).clear();
}
if (!token.getSubtype(game).isEmpty()) {
@ -183,8 +183,8 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl {
sb.append(" become ");
}
sb.append(token.getDescription());
if (type != null && !type.isEmpty()) {
sb.append(". They're still ").append(type);
if (theyAreStillType != null && !theyAreStillType.isEmpty()) {
sb.append(". They're still ").append(theyAreStillType);
}
return sb.toString();
}

View file

@ -1,6 +1,8 @@
package mage.game.permanent.token.custom;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.game.permanent.token.TokenImpl;
@ -39,6 +41,31 @@ public class CreatureToken extends TokenImpl {
}
}
public CreatureToken withAbility(Ability ability) {
this.addAbility(ability);
return this;
}
public CreatureToken withColor(String extraColors) {
ObjectColor extraColorsList = new ObjectColor(extraColors);
this.getColor(null).addColor(extraColorsList);
return this;
}
public CreatureToken withType(CardType extraType) {
if (!this.cardType.contains(extraType)) {
this.cardType.add(extraType);
}
return this;
}
public CreatureToken withSubType(SubType extraSubType) {
if (!this.subtype.contains(extraSubType)) {
this.subtype.add(extraSubType);
}
return this;
}
public CreatureToken(final CreatureToken token) {
super(token);
}