diff --git a/Mage/src/main/java/mage/ApprovingObject.java b/Mage/src/main/java/mage/ApprovingObject.java index 9468aad1577..75ee9157574 100644 --- a/Mage/src/main/java/mage/ApprovingObject.java +++ b/Mage/src/main/java/mage/ApprovingObject.java @@ -3,11 +3,13 @@ package mage; import mage.abilities.Ability; import mage.game.Game; +import java.io.Serializable; + /** * * @author LevelX2 */ -public class ApprovingObject { +public class ApprovingObject implements Serializable { private final Ability approvingAbility; private final MageObjectReference approvingMageObjectReference; diff --git a/Mage/src/main/java/mage/game/events/GameEvent.java b/Mage/src/main/java/mage/game/events/GameEvent.java index 2f5c579cd6e..3c8cdbdf64b 100644 --- a/Mage/src/main/java/mage/game/events/GameEvent.java +++ b/Mage/src/main/java/mage/game/events/GameEvent.java @@ -32,7 +32,6 @@ public class GameEvent implements Serializable { protected Zone zone; protected List appliedEffects = new ArrayList<>(); protected ApprovingObject approvingObject; // e.g. the approving object for casting a spell from non hand zone - protected UUID customEventType = null; public enum EventType { @@ -668,28 +667,20 @@ public class GameEvent implements Serializable { playerId player who gave the gift */ GAVE_GIFT, - //custom events + // custom events - must store some unique data to track CUSTOM_EVENT } public GameEvent(EventType type, UUID targetId, Ability source, UUID playerId) { - this(type, null, targetId, source, playerId, 0, false); + this(type, targetId, source, playerId, 0, false, null); } public GameEvent(EventType type, UUID targetId, Ability source, UUID playerId, ApprovingObject approvingObject) { - this(type, null, targetId, source, playerId, 0, false, approvingObject); + this(type, targetId, source, playerId, 0, false, approvingObject); } public GameEvent(EventType type, UUID targetId, Ability source, UUID playerId, int amount, boolean flag) { - this(type, null, targetId, source, playerId, amount, flag); - } - - public GameEvent(UUID customEventType, UUID targetId, Ability source, UUID playerId) { - this(EventType.CUSTOM_EVENT, customEventType, targetId, source, playerId, 0, false); - } - - public GameEvent(UUID customEventType, UUID targetId, Ability source, UUID playerId, int amount, boolean flag) { - this(EventType.CUSTOM_EVENT, customEventType, targetId, source, playerId, amount, flag); + this(type, targetId, source, playerId, amount, flag, null); } public static GameEvent getEvent(EventType type, UUID targetId, Ability source, UUID playerId, int amount) { @@ -716,24 +707,10 @@ public class GameEvent implements Serializable { return event; } - public static GameEvent getEvent(UUID customEventType, UUID targetId, Ability source, UUID playerId, int amount) { - return new GameEvent(customEventType, targetId, source, playerId, amount, false); - } - - public static GameEvent getEvent(UUID customEventType, UUID targetId, Ability source, UUID playerId) { - return new GameEvent(customEventType, targetId, source, playerId); - } - - private GameEvent(EventType type, UUID customEventType, UUID targetId, Ability source, UUID playerId, int amount, boolean flag) { - this(type, customEventType, targetId, source, playerId, amount, flag, null); - } - - private GameEvent(EventType type, UUID customEventType, - UUID targetId, Ability source, UUID playerId, + private GameEvent(EventType type, UUID targetId, Ability source, UUID playerId, int amount, boolean flag, ApprovingObject approvingObject ) { this.type = type; - this.customEventType = customEventType; this.targetId = targetId; this.sourceId = source == null ? null : source.getSourceId(); // We only keep the sourceId from the whole source. this.amount = amount; @@ -747,18 +724,12 @@ public class GameEvent implements Serializable { return type; } - public UUID getCustomEventType() { - return customEventType; - } - public UUID getId() { return id; } /** * Some batch events can contain multiple events list, see BatchGameEvent for usage - * - * @return */ public UUID getTargetId() { return targetId; @@ -825,8 +796,6 @@ public class GameEvent implements Serializable { /** * Returns possibly approving object that allowed the creation of the event. - * - * @return */ public ApprovingObject getAdditionalReference() { return approvingObject; @@ -847,17 +816,11 @@ public class GameEvent implements Serializable { * creature or player, it deals double that damage to that creature or * player instead." A creature that normally deals 2 damage will deal 8 * damage--not just 4, and not an infinite amount. - * - * @return */ public List getAppliedEffects() { return appliedEffects; } - public boolean isCustomEvent(UUID customEventType) { - return type == EventType.CUSTOM_EVENT && this.customEventType.equals(customEventType); - } - public void addAppliedEffects(List appliedEffects) { if (appliedEffects != null) { this.appliedEffects.addAll(appliedEffects); @@ -867,7 +830,7 @@ public class GameEvent implements Serializable { public void setAppliedEffects(List appliedEffects) { if (appliedEffects != null) { if (this.appliedEffects.isEmpty()) { - this.appliedEffects = appliedEffects; // Use object refecence to handle that an replacement effect can only be once applied to an event + this.appliedEffects = appliedEffects; // Use object reference to handle that an replacement effect can only be once applied to an event } else { this.appliedEffects.addAll(appliedEffects); } @@ -888,9 +851,7 @@ public class GameEvent implements Serializable { * Custom sourceId setup for some events (use it in constructor). * TODO: replace all custom sourceId to normal event classes * for now, having the setter helps find all that do not provide an Ability source, - * so keeping it is worthwhile until a thoughtfull cleanup. - * - * @param sourceId + * so keeping it is worthwhile until a thoughtful cleanup. */ protected void setSourceId(UUID sourceId) { this.sourceId = sourceId;