mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
Refactored more subtypes usages to enum
This commit is contained in:
parent
92b999a9b4
commit
3cc178196e
29 changed files with 82 additions and 65 deletions
|
|
@ -29,6 +29,7 @@ package mage.abilities.common;
|
|||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
|
@ -57,7 +58,7 @@ public class AuraAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getTargetId().equals(this.getSourceId())) {
|
||||
Permanent attachment = game.getPermanent(event.getSourceId());
|
||||
if (attachment != null && attachment.getSubtype(game).contains("Aura")) {
|
||||
if (attachment != null && attachment.getSubtype(game).contains(SubType.AURA)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.SubType;
|
||||
|
||||
/**
|
||||
* Describes condition when creature is equipped with more than one Equipment.
|
||||
|
|
@ -50,7 +51,7 @@ public enum EquippedMultipleSourceCondition implements Condition {
|
|||
if (permanent != null) {
|
||||
for (UUID uuid : permanent.getAttachments()) {
|
||||
Permanent attached = game.getBattlefield().getPermanent(uuid);
|
||||
if (attached != null && attached.getSubtype(game).contains("Equipment")) {
|
||||
if (attached != null && attached.getSubtype(game).contains(SubType.EQUIPMENT)) {
|
||||
countEquipped++;
|
||||
if (countEquipped >= 2) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.SubType;
|
||||
|
||||
/**
|
||||
* Describes condition when creature is equipped.
|
||||
|
|
@ -49,7 +50,7 @@ public enum EquippedSourceCondition implements Condition {
|
|||
if (permanent != null) {
|
||||
for (UUID uuid : permanent.getAttachments()) {
|
||||
Permanent attached = game.getBattlefield().getPermanent(uuid);
|
||||
if (attached != null && attached.getSubtype(game).contains("Equipment")) {
|
||||
if (attached != null && attached.getSubtype(game).contains(SubType.EQUIPMENT)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import java.util.UUID;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
|
@ -63,7 +64,7 @@ public class AuraAttachedCount implements DynamicValue {
|
|||
List<UUID> attachments = p.getAttachments();
|
||||
for (UUID attachmentId : attachments) {
|
||||
Permanent attached = game.getPermanent(attachmentId);
|
||||
if (attached != null && attached.getSubtype(game).contains("Aura")) {
|
||||
if (attached != null && attached.getSubtype(game).contains(SubType.AURA)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
|
@ -62,19 +63,19 @@ public class DomainValue implements DynamicValue {
|
|||
}
|
||||
for (Permanent p : game.getBattlefield().getAllActivePermanents(targetPlayer)) {
|
||||
if (p.isLand()) {
|
||||
if (havePlains == 0 && p.getSubtype(game).contains("Plains")) {
|
||||
if (havePlains == 0 && p.getSubtype(game).contains(SubType.PLAINS)) {
|
||||
havePlains = 1;
|
||||
}
|
||||
if (haveIslands == 0 && p.getSubtype(game).contains("Island")) {
|
||||
if (haveIslands == 0 && p.getSubtype(game).contains(SubType.ISLAND)) {
|
||||
haveIslands = 1;
|
||||
}
|
||||
if (haveMountains == 0 && p.getSubtype(game).contains("Mountain")) {
|
||||
if (haveMountains == 0 && p.getSubtype(game).contains(SubType.MOUNTAIN)) {
|
||||
haveMountains = 1;
|
||||
}
|
||||
if (haveSwamps == 0 && p.getSubtype(game).contains("Swamp")) {
|
||||
if (haveSwamps == 0 && p.getSubtype(game).contains(SubType.SWAMP)) {
|
||||
haveSwamps = 1;
|
||||
}
|
||||
if (haveForests == 0 && p.getSubtype(game).contains("Forest")) {
|
||||
if (haveForests == 0 && p.getSubtype(game).contains(SubType.FOREST)) {
|
||||
haveForests = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import java.util.UUID;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
|
@ -63,7 +64,7 @@ public class EquipmentAttachedCount implements DynamicValue {
|
|||
List<UUID> attachments = permanent.getAttachments();
|
||||
for (UUID attachmentId : attachments) {
|
||||
Permanent attached = game.getPermanent(attachmentId);
|
||||
if (attached != null && attached.getSubtype(game).contains("Equipment")) {
|
||||
if (attached != null && attached.getSubtype(game).contains(SubType.EQUIPMENT)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class BecomesCreatureIfVehicleEffect extends ContinuousEffectImpl {
|
|||
Permanent aura = game.getPermanent(source.getSourceId());
|
||||
if (aura != null && aura.getAttachedTo() != null) {
|
||||
Permanent enchanted = game.getPermanent(aura.getAttachedTo());
|
||||
if (enchanted != null && enchanted.getSubtype(game).contains("Vehicle")) {
|
||||
if (enchanted != null && enchanted.getSubtype(game).contains(SubType.VEHICLE)) {
|
||||
enchanted.addCardType(addedType);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import mage.cards.Card;
|
|||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
|
|
@ -182,7 +183,7 @@ class SpliceOntoArcaneEffect extends SpliceCardEffectImpl {
|
|||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
MageObject object = game.getObject(abilityToModify.getSourceId());
|
||||
if (object != null && object.getSubtype(game).contains("Arcane")) {
|
||||
if (object != null && object.getSubtype(game).contains(SubType.ARCANE)) {
|
||||
return spliceSpellCanBeActivated(source, game);
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
package mage.filter.predicate.permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
|
@ -20,7 +21,7 @@ public class EquippedPredicate implements Predicate<Permanent> {
|
|||
public boolean apply(Permanent input, Game game) {
|
||||
for (UUID attachmentId : input.getAttachments()) {
|
||||
Permanent attachment = game.getPermanent(attachmentId);
|
||||
if (attachment != null && attachment.getSubtype(game).contains("Equipment")) {
|
||||
if (attachment != null && attachment.getSubtype(game).contains(SubType.EQUIPMENT)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1900,9 +1900,9 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
Permanent attachment = getPermanent(attachmentId);
|
||||
if (attachment != null
|
||||
&& (attachment.isCreature()
|
||||
|| !(attachment.getSubtype(this).contains("Aura")
|
||||
|| attachment.getSubtype(this).contains("Equipment")
|
||||
|| attachment.getSubtype(this).contains("Fortification")))) {
|
||||
|| !(attachment.getSubtype(this).contains(SubType.AURA)
|
||||
|| attachment.getSubtype(this).contains(SubType.EQUIPMENT)
|
||||
|| attachment.getSubtype(this).contains(SubType.FORTIFICATION)))) {
|
||||
if (perm.removeAttachment(attachment.getId(), this)) {
|
||||
somethingHappened = true;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
}
|
||||
counter(null, game);
|
||||
return false;
|
||||
} else if (this.isEnchantment() && this.getSubtype(game).contains("Aura")) {
|
||||
} else if (this.isEnchantment() && this.getSubtype(game).contains(SubType.AURA)) {
|
||||
if (ability.getTargets().stillLegal(ability, game)) {
|
||||
updateOptionalCosts(0);
|
||||
boolean bestow = ability instanceof BestowAbility;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue