Merge pull request #17 from magefree/master

merge
This commit is contained in:
theelk801 2017-08-08 17:44:15 -04:00 committed by GitHub
commit 8b36b16b09
28 changed files with 152 additions and 94 deletions

View file

@ -32,7 +32,6 @@ import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -43,9 +42,9 @@ import mage.game.permanent.Permanent;
public class AddCardSubtypeAllEffect extends ContinuousEffectImpl {
private static FilterPermanent filter;
private static String addedSubtype;
private static SubType addedSubtype;
public AddCardSubtypeAllEffect(FilterPermanent _filter, String _addedSubtype, DependencyType _dependency) {
public AddCardSubtypeAllEffect(FilterPermanent _filter, SubType _addedSubtype, DependencyType _dependency) {
super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
filter = _filter;
staticText = "";

View file

@ -39,6 +39,7 @@ import mage.players.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
@ -49,38 +50,38 @@ import java.util.UUID;
public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl {
protected boolean chooseLandType;
protected ArrayList<String> landTypes = new ArrayList();
protected ArrayList<String> landTypesToAdd = new ArrayList();
protected List<SubType> landTypes = new ArrayList<>();
protected List<SubType> landTypesToAdd = new ArrayList<>();
protected boolean loseOther; // loses all other abilities, card types, and creature types
public BecomesBasicLandTargetEffect(Duration duration) {
this(duration, true, new String[0]);
this(duration, true);
}
public BecomesBasicLandTargetEffect(Duration duration, String... landNames) {
public BecomesBasicLandTargetEffect(Duration duration, SubType... landNames) {
this(duration, false, landNames);
}
public BecomesBasicLandTargetEffect(Duration duration, boolean chooseLandType, String... landNames) {
public BecomesBasicLandTargetEffect(Duration duration, boolean chooseLandType, SubType... landNames) {
this(duration, chooseLandType, true, landNames);
}
public BecomesBasicLandTargetEffect(Duration duration, boolean chooseLandType, boolean loseOther, String... landNames) {
public BecomesBasicLandTargetEffect(Duration duration, boolean chooseLandType, boolean loseOther, SubType... landNames) {
super(duration, Outcome.Detriment);
this.landTypes.addAll(Arrays.asList(landNames));
if (landTypes.contains("Mountain")) {
if (landTypes.contains(SubType.MOUNTAIN)) {
dependencyTypes.add(DependencyType.BecomeMountain);
}
if (landTypes.contains("Forest")) {
if (landTypes.contains(SubType.FOREST)) {
dependencyTypes.add(DependencyType.BecomeForest);
}
if (landTypes.contains("Swamp")) {
if (landTypes.contains(SubType.SWAMP)) {
dependencyTypes.add(DependencyType.BecomeSwamp);
}
if (landTypes.contains("Island")) {
if (landTypes.contains(SubType.ISLAND)) {
dependencyTypes.add(DependencyType.BecomeIsland);
}
if (landTypes.contains("Plains")) {
if (landTypes.contains(SubType.PLAINS)) {
dependencyTypes.add(DependencyType.BecomePlains);
}
this.chooseLandType = chooseLandType;
@ -116,7 +117,7 @@ public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl {
if (controller != null) {
Choice choice = new ChoiceBasicLandType();
controller.choose(outcome, choice, game);
landTypes.add(choice.getChoice());
landTypes.add(SubType.byDescription(choice.getChoice()));
} else {
this.discard();
}
@ -147,7 +148,7 @@ public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl {
land.getSubtype(game).addAll(landTypes);
} else {
landTypesToAdd.clear();
for (String subtype : landTypes) {
for (SubType subtype : landTypes) {
if (!land.getSubtype(game).contains(subtype)) {
land.getSubtype(game).add(subtype);
landTypesToAdd.add(subtype);
@ -156,21 +157,21 @@ public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl {
}
break;
case AbilityAddingRemovingEffects_6:
for (String landType : landTypesToAdd) {
for (SubType landType : landTypesToAdd) {
switch (landType) {
case "Swamp":
case SWAMP:
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
break;
case "Mountain":
case MOUNTAIN:
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
break;
case "Forest":
case FOREST:
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
break;
case "Island":
case ISLAND:
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
break;
case "Plains":
case PLAINS:
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
break;
}
@ -194,7 +195,7 @@ public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl {
} else {
sb.append("Target land becomes a ");
int i = 1;
for (String landType : landTypes) {
for (SubType landType : landTypes) {
if (i > 1) {
if (i == landTypes.size()) {
sb.append(" and ");

View file

@ -94,7 +94,7 @@ class AuraSwapEffect extends OneShotEffect {
if (controller != null) {
Permanent auraSourcePermanent = game.getPermanent(source.getSourceId());
if (auraSourcePermanent != null
&& auraSourcePermanent.getSubtype(game).contains("Aura")
&& auraSourcePermanent.getSubtype(game).contains(SubType.AURA)
&& auraSourcePermanent.getOwnerId().equals(source.getControllerId())) {
Permanent enchantedPermanent = game.getPermanent(auraSourcePermanent.getAttachedTo());
filterCardToCheck.add(new AuraCardCanAttachToPermanentId(enchantedPermanent.getId()));

View file

@ -110,8 +110,8 @@ class EmbalmEffect extends OneShotEffect {
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(card); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer)
token.getColor(game).setColor(ObjectColor.WHITE);
if (!token.getSubtype(game).contains("Zombie")) {
token.getSubtype(game).add(0, "Zombie");
if (!token.getSubtype(game).contains(SubType.ZOMBIE)) {
token.getSubtype(game).add(0, SubType.ZOMBIE);
}
token.getManaCost().clear();
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EMBALMED_CREATURE, token.getId(), source.getSourceId(), controller.getId()));

View file

@ -115,13 +115,13 @@ class EternalizeEffect extends OneShotEffect {
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(card); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer)
token.getColor(game).setColor(ObjectColor.BLACK);
if (!token.getSubtype(game).contains("Zombie")) {
token.getSubtype(game).add(0, "Zombie");
if (!token.getSubtype(game).contains(SubType.ZOMBIE)) {
token.getSubtype(game).add(0, SubType.ZOMBIE);
}
token.getManaCost().clear();
token.getPower().modifyBaseValue(4);
token.getToughness().modifyBaseValue(4);
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EMBALMED_CREATURE, token.getId(), source.getSourceId(), controller.getId()));
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.ETERNALIZED_CREATURE, token.getId(), source.getSourceId(), controller.getId()));
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId(), false, false, null);
// Probably it makes sense to remove also the Eternalize ability (it's not shown on the token cards).
// Also it can never get active or? But it's not mentioned in the reminder text.

View file

@ -292,6 +292,7 @@ public class GameEvent implements Serializable {
EXPLOITED_CREATURE,
EVOLVED_CREATURE,
EMBALMED_CREATURE,
ETERNALIZED_CREATURE,
ATTACH, ATTACHED,
STAY_ATTACHED,
UNATTACH, UNATTACHED,

View file

@ -27,7 +27,6 @@
*/
package mage.game.permanent;
import java.util.*;
import mage.MageObject;
import mage.MageObjectReference;
import mage.ObjectColor;
@ -56,6 +55,8 @@ import mage.players.Player;
import mage.util.GameLog;
import mage.util.ThreadLocalStringBuilder;
import java.util.*;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -925,7 +926,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
@Override
public boolean cantBeAttachedBy(MageObject source, Game game) {
for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) {
if (!(source.getSubtype(game).contains("Aura")
if (!(source.getSubtype(game).contains(SubType.AURA)
&& !ability.removesAuras())
&& !source.getId().equals(ability.getAuraIdNotToBeRemoved())
&& !ability.canTarget(source, game)) {

View file

@ -9,15 +9,6 @@ import java.util.stream.Collectors;
public class SubTypeList extends ArrayList<SubType> {
public void add(int index, String s) {
add(index, SubType.byDescription(s));
}
public void add(int index, SubType s) {
super.add(index, s);
}
public boolean addAll(List<String> subtypes) {
return addAll(subtypes.stream().map(SubType::byDescription).collect(Collectors.toList()));
}
@ -26,9 +17,6 @@ public class SubTypeList extends ArrayList<SubType> {
return removeAll(subtypes.stream().map(SubType::byDescription).collect(Collectors.toList()));
}
public boolean add(SubType s) {
return super.add(s);
}
public boolean add(SubType... subTypes) {
return Collections.addAll(this, subTypes);