1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-03-17 17:00:08 -09:00

Refactored more subtypes usages to enum

This commit is contained in:
Evan Kranzler 2017-09-08 09:31:06 -04:00
parent c33fe6a7e5
commit 80b61ccbd6
6 changed files with 50 additions and 56 deletions

View file

@ -51,7 +51,7 @@ import mage.target.common.TargetLandPermanent;
public class ConvincingMirage extends CardImpl {
public ConvincingMirage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}");
this.subtype.add(SubType.AURA);
// Enchant land
@ -95,8 +95,7 @@ class ConvincingMirageContinousEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
// TODO fix to use SubType enum
String choice = (String) game.getState().getValue(source.getSourceId().toString() + ChooseBasicLandTypeEffect.VALUE_KEY);
SubType choice = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + ChooseBasicLandTypeEffect.VALUE_KEY));
if (enchantment != null && enchantment.getAttachedTo() != null && choice != null) {
Permanent land = game.getPermanent(enchantment.getAttachedTo());
if (land != null) {
@ -110,19 +109,19 @@ class ConvincingMirageContinousEffect extends ContinuousEffectImpl {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
land.getAbilities().clear();
if (choice.equals("Forest")) {
if (choice.equals(SubType.FOREST)) {
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Plains")) {
if (choice.equals(SubType.PLAINS)) {
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Mountain")) {
if (choice.equals(SubType.MOUNTAIN)) {
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Island")) {
if (choice.equals(SubType.ISLAND)) {
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Swamp")) {
if (choice.equals(SubType.SWAMP)) {
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
}
}

View file

@ -135,8 +135,7 @@ class ElsewhereFlaskContinuousEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
// TODO fix to use SubType enum
String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_ElsewhereFlask");
SubType choice = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + "_ElsewhereFlask"));
if (choice != null) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
Permanent land = it.next().getPermanent(game);
@ -151,19 +150,19 @@ class ElsewhereFlaskContinuousEffect extends ContinuousEffectImpl {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
land.getAbilities().clear();
if (choice.equals("Forest")) {
if (choice.equals(SubType.FOREST)) {
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Plains")) {
if (choice.equals(SubType.PLAINS)) {
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Mountain")) {
if (choice.equals(SubType.MOUNTAIN)) {
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Island")) {
if (choice.equals(SubType.ISLAND)) {
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Swamp")) {
if (choice.equals(SubType.SWAMP)) {
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
}
}

View file

@ -61,7 +61,7 @@ import mage.target.common.TargetLandPermanent;
public class PhantasmalTerrain extends CardImpl {
public PhantasmalTerrain(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}{U}");
this.subtype.add(SubType.AURA);
// Enchant land
@ -105,9 +105,8 @@ class PhantasmalTerrainContinuousEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
// TODO fix to use SubType enum
Permanent enchantment = game.getPermanent(source.getSourceId());
String choice = (String) game.getState().getValue(source.getSourceId().toString() + ChooseBasicLandTypeEffect.VALUE_KEY);
SubType choice = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + ChooseBasicLandTypeEffect.VALUE_KEY));
if (enchantment != null && enchantment.getAttachedTo() != null && choice != null) {
Permanent land = game.getPermanent(enchantment.getAttachedTo());
if (land != null) {
@ -121,19 +120,19 @@ class PhantasmalTerrainContinuousEffect extends ContinuousEffectImpl {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
land.getAbilities().clear();
if (choice.equals("Forest")) {
if (choice.equals(SubType.FOREST)) {
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Plains")) {
if (choice.equals(SubType.PLAINS)) {
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Mountain")) {
if (choice.equals(SubType.MOUNTAIN)) {
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Island")) {
if (choice.equals(SubType.ISLAND)) {
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Swamp")) {
if (choice.equals(SubType.SWAMP)) {
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
}
}

View file

@ -61,7 +61,7 @@ import mage.players.Player;
public class Realmwright extends CardImpl {
public Realmwright(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}");
this.subtype.add(SubType.VEDALKEN);
this.subtype.add(SubType.WIZARD);
@ -103,10 +103,9 @@ class RealmwrightEffect2 extends ContinuousEffectImpl {
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
// TODO fix to use SubType enum
Player you = game.getPlayer(source.getControllerId());
List<Permanent> lands = game.getBattlefield().getAllActivePermanents(new FilterControlledLandPermanent(), source.getControllerId(), game);
String choice = (String) game.getState().getValue(source.getSourceId().toString() + ChooseBasicLandTypeEffect.VALUE_KEY);
SubType choice = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + ChooseBasicLandTypeEffect.VALUE_KEY));
if (you != null && choice != null) {
for (Permanent land : lands) {
if (land != null) {
@ -119,7 +118,7 @@ class RealmwrightEffect2 extends ContinuousEffectImpl {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
boolean addAbility = true;
if (choice.equals("Forest")) {
if (choice.equals(SubType.FOREST)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof GreenManaAbility) {
addAbility = false;
@ -130,7 +129,7 @@ class RealmwrightEffect2 extends ContinuousEffectImpl {
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
}
}
if (choice.equals("Plains")) {
if (choice.equals(SubType.PLAINS)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof WhiteManaAbility) {
addAbility = false;
@ -141,7 +140,7 @@ class RealmwrightEffect2 extends ContinuousEffectImpl {
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
}
}
if (choice.equals("Mountain")) {
if (choice.equals(SubType.MOUNTAIN)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof RedManaAbility) {
addAbility = false;
@ -152,7 +151,7 @@ class RealmwrightEffect2 extends ContinuousEffectImpl {
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
}
}
if (choice.equals("Island")) {
if (choice.equals(SubType.ISLAND)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof BlueManaAbility) {
addAbility = false;
@ -163,7 +162,7 @@ class RealmwrightEffect2 extends ContinuousEffectImpl {
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
}
}
if (choice.equals("Swamp")) {
if (choice.equals(SubType.SWAMP)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof BlackManaAbility) {
addAbility = false;

View file

@ -145,8 +145,7 @@ class TerraformerContinuousEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
// TODO fix to use SubType enum
String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_Terraformer");
SubType choice = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + "_Terraformer"));
if (choice != null) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
Permanent land = it.next().getPermanent(game);
@ -161,19 +160,19 @@ class TerraformerContinuousEffect extends ContinuousEffectImpl {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
land.getAbilities().clear();
if (choice.equals("Forest")) {
if (choice.equals(SubType.FOREST)) {
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Plains")) {
if (choice.equals(SubType.PLAINS)) {
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Mountain")) {
if (choice.equals(SubType.MOUNTAIN)) {
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Island")) {
if (choice.equals(SubType.ISLAND)) {
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Swamp")) {
if (choice.equals(SubType.SWAMP)) {
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
}
}

View file

@ -93,7 +93,7 @@ public class VisionCharm extends CardImpl {
class VisionCharmEffect extends ContinuousEffectImpl {
private String targetLandType;
private String targetBasicLandType;
private SubType targetBasicLandType;
public VisionCharmEffect() {
super(Duration.EndOfTurn, Outcome.Neutral);
@ -121,7 +121,7 @@ class VisionCharmEffect extends ContinuousEffectImpl {
targetLandType = choice.getChoice();
choice = new ChoiceBasicLandType();
controller.choose(outcome, choice, game);
targetBasicLandType = choice.getChoice();
targetBasicLandType = SubType.byDescription(choice.getChoice());
if (targetLandType == null || targetBasicLandType == null) {
this.discard();
return;
@ -153,22 +153,20 @@ class VisionCharmEffect extends ContinuousEffectImpl {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
land.getAbilities().clear();
switch (targetBasicLandType) {
case "Swamp":
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
break;
case "Mountain":
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
break;
case "Forest":
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
break;
case "Island":
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
break;
case "Plains":
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
break;
if (targetBasicLandType.equals(SubType.FOREST)) {
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
}
if (targetBasicLandType.equals(SubType.PLAINS)) {
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
}
if (targetBasicLandType.equals(SubType.MOUNTAIN)) {
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
}
if (targetBasicLandType.equals(SubType.ISLAND)) {
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
}
if (targetBasicLandType.equals(SubType.SWAMP)) {
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
}
}
}
@ -176,6 +174,7 @@ class VisionCharmEffect extends ContinuousEffectImpl {
it.remove();
}
}
return true;
}