fix subtype in game state

This commit is contained in:
igoudt 2017-08-06 22:11:17 +02:00
parent 7ac35808bf
commit 5d99bacf73
20 changed files with 86 additions and 89 deletions

View file

@ -75,7 +75,7 @@ public class ChooseCreatureTypeEffect extends OneShotEffect {
if (!game.isSimulation()) {
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
}
game.getState().setValue(mageObject.getId() + "_type", typeChoice.getChoice());
game.getState().setValue(mageObject.getId() + "_type", SubType.byDescription(typeChoice.getChoice()));
if (mageObject instanceof Permanent) {
((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game);
}

View file

@ -53,7 +53,7 @@ public class ChooseLandTypeEffect extends OneShotEffect {
if (!game.isSimulation()) {
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
}
game.getState().setValue(mageObject.getId() + "_type", typeChoice.getChoice());
game.getState().setValue(mageObject.getId() + "_type", SubType.byDescription(typeChoice.getChoice()));
if (mageObject instanceof Permanent) {
((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game);
}

View file

@ -48,9 +48,9 @@ public class BoostAllOfChosenSubtypeEffect extends BoostAllEffect {
@Override
protected void setRuntimeData(Ability source, Game game) {
String s = (String) game.getState().getValue(source.getSourceId() + "_type");
if (subtype != null) {
subtype = SubType.byDescription(s);
SubType s = (SubType) game.getState().getValue(source.getSourceId() + "_type");
if (s != null) {
subtype = s;
} else {
discard();
}

View file

@ -44,8 +44,8 @@ public class GainAbilityAllOfChosenSubtypeEffect extends GainAbilityAllEffect {
@Override
protected void setRuntimeData(Ability source, Game game) {
String s = (String) game.getState().getValue(source.getSourceId() + "_type");
subtype = SubType.byDescription(s);
subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
}
}

View file

@ -32,9 +32,9 @@ public class SpellsCostReductionAllOfChosenSubtypeEffect extends SpellsCostReduc
@Override
protected boolean selectedByRuntimeData(Card card, Ability source, Game game) {
String subtype = (String) game.getState().getValue(source.getSourceId() + "_type");
SubType subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
if (subtype != null) {
return card.hasSubtype(SubType.byDescription(subtype), game);
return card.hasSubtype(subtype, game);
}
return false;
}

View file

@ -31,6 +31,7 @@ import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -57,7 +58,7 @@ public class EnterAttributeAddChosenSubtypeEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentEntering(source.getSourceId());
String subtype = (String) game.getState().getValue(source.getSourceId() + "_type");
SubType subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
if (permanent != null && subtype != null) {
MageObject mageObject = permanent.getBasicMageObject(game);
if (!mageObject.getSubtype(null).contains(subtype)) {

View file

@ -308,29 +308,22 @@ public abstract class ExpansionSet implements Serializable {
private void addSpecial(List<Card> booster) {
int specialCards = 0;
List<CardInfo> specialBonus = getSpecialBonus();
if (specialBonus != null) {
specialCards += specialBonus.size();
}
specialCards += specialBonus.size();
List<CardInfo> specialMythic = getSpecialMythic();
if (specialMythic != null) {
specialCards += specialMythic.size();
}
specialCards += specialMythic.size();
List<CardInfo> specialRare = getSpecialRare();
if (specialRare != null) {
specialCards += specialRare.size();
}
specialCards += specialRare.size();
List<CardInfo> specialUncommon = getSpecialUncommon();
if (specialUncommon != null) {
specialCards += specialUncommon.size();
}
specialCards += specialUncommon.size();
List<CardInfo> specialCommon = getSpecialCommon();
if (specialCommon != null) {
specialCards += specialCommon.size();
}
specialCards += specialCommon.size();
if (specialCards > 0) {
for (int i = 0; i < numBoosterSpecial; i++) {
if (RandomUtil.nextInt(15) < 10) {
if (specialCommon != null && !specialCommon.isEmpty()) {
if (!specialCommon.isEmpty()) {
addToBooster(booster, specialCommon);
} else {
i--;
@ -338,7 +331,7 @@ public abstract class ExpansionSet implements Serializable {
continue;
}
if (RandomUtil.nextInt(4) < 3) {
if (specialUncommon != null && !specialUncommon.isEmpty()) {
if (!specialUncommon.isEmpty()) {
addToBooster(booster, specialUncommon);
} else {
i--;
@ -346,15 +339,15 @@ public abstract class ExpansionSet implements Serializable {
continue;
}
if (RandomUtil.nextInt(8) < 7) {
if (specialRare != null && !specialRare.isEmpty()) {
if (!specialRare.isEmpty()) {
addToBooster(booster, specialRare);
} else {
i--;
}
continue;
}
if (specialMythic != null && !specialMythic.isEmpty()) {
if (specialBonus != null && !specialBonus.isEmpty()) {
if (!specialMythic.isEmpty()) {
if (!specialBonus.isEmpty()) {
if (RandomUtil.nextInt(3) < 2) {
addToBooster(booster, specialMythic);
continue;
@ -366,7 +359,7 @@ public abstract class ExpansionSet implements Serializable {
} else {
i--;
}
if (specialBonus != null && !specialBonus.isEmpty()) {
if (!specialBonus.isEmpty()) {
addToBooster(booster, specialBonus);
}
}
@ -407,27 +400,27 @@ public abstract class ExpansionSet implements Serializable {
}
public List<CardInfo> getSpecialCommon() {
return null;
return new ArrayList<>();
}
public List<CardInfo> getSpecialUncommon() {
return null;
return new ArrayList<>();
}
public List<CardInfo> getSpecialRare() {
return null;
return new ArrayList<>();
}
public List<CardInfo> getSpecialMythic() {
return null;
return new ArrayList<>();
}
public List<CardInfo> getSpecialBonus() {
return null;
return new ArrayList<>();
}
public List<CardInfo> getSpecialLand() {
return null;
return new ArrayList<>();
}
public boolean isCustomSet() {

View file

@ -48,8 +48,8 @@ public class ChosenSubtypePredicate implements Predicate<MageObject> {
@Override
public boolean apply(MageObject input, Game game) {
String subtype = (String) game.getState().getValue(cardID + "_type");
return input.hasSubtype(SubType.byDescription(subtype), game);
SubType subtype = (SubType) game.getState().getValue(cardID + "_type");
return input.hasSubtype(subtype, game);
}
@Override

View file

@ -30,6 +30,7 @@ package mage.game.permanent.token;
import mage.constants.CardType;
import mage.MageInt;
import mage.ObjectColor;
import mage.constants.SubType;
/**
*
@ -40,8 +41,8 @@ public class RiptideReplicatorToken extends Token {
public RiptideReplicatorToken() {
this(null, null, 1);
}
public RiptideReplicatorToken(ObjectColor color, String type, int x) {
super(type, "X/X creature token of the chosen color and type");
public RiptideReplicatorToken(ObjectColor color, SubType type, int x) {
super(type.getDescription(), "X/X creature token of the chosen color and type");
cardType.add(CardType.CREATURE);
if (color != null) {
this.color.setColor(color);

View file

@ -30,6 +30,7 @@ package mage.game.permanent.token;
import mage.constants.CardType;
import mage.MageInt;
import mage.ObjectColor;
import mage.constants.SubType;
/**
*
@ -40,8 +41,8 @@ public class VolrathsLaboratoryToken extends Token {
public VolrathsLaboratoryToken() {
this(null, null);
}
public VolrathsLaboratoryToken(ObjectColor color, String type) {
super(type, "2/2 creature token of the chosen color and type");
public VolrathsLaboratoryToken(ObjectColor color, SubType type) {
super(type.getDescription(), "2/2 creature token of the chosen color and type");
cardType.add(CardType.CREATURE);
if (color != null) {
this.color.setColor(color);