revert the GameEvent::setSourceId removal

xenodron mentionned that one of the use of setSourceId is to more easily find the Event that use non-standard
sourceId.

So reverting the change made in a previous commit.

It was a non-functional change meant to ease new
BatchEvent sharing sourceId, but I'll use setSourceId
instead there.
This commit is contained in:
Susucre 2024-04-30 11:51:11 +02:00
parent 00556c4cf6
commit 95adcf0e9a
26 changed files with 88 additions and 63 deletions

View file

@ -641,31 +641,23 @@ public class GameEvent implements Serializable {
}
public GameEvent(EventType type, UUID targetId, Ability source, UUID playerId) {
this(type, null, targetId, source == null ? null : source.getSourceId(), playerId, 0, false);
}
protected GameEvent(EventType type, UUID targetId, UUID sourceId, UUID playerId) {
this(type, null, targetId, sourceId, playerId, 0, false);
this(type, null, targetId, source, playerId, 0, false);
}
public GameEvent(EventType type, UUID targetId, Ability source, UUID playerId, ApprovingObject approvingObject) {
this(type, null, targetId, source == null ? null : source.getSourceId(), playerId, 0, false, approvingObject);
this(type, null, 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 == null ? null : source.getSourceId(), playerId, amount, flag);
}
public GameEvent(EventType type, UUID targetId, UUID sourceId, UUID playerId, int amount, boolean flag) {
this(type, null, targetId, sourceId, playerId, amount, 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 == null ? null : source.getSourceId(), playerId, 0, false);
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 == null ? null : source.getSourceId(), playerId, amount, flag);
this(EventType.CUSTOM_EVENT, customEventType, targetId, source, playerId, amount, flag);
}
public static GameEvent getEvent(EventType type, UUID targetId, Ability source, UUID playerId, int amount) {
@ -682,7 +674,7 @@ public class GameEvent implements Serializable {
@Deprecated // usage must be replaced by getEvent with source ability
public static GameEvent getEvent(EventType type, UUID targetId, UUID playerId) {
return new GameEvent(type, targetId, (UUID) null, playerId);
return new GameEvent(type, targetId, null, playerId);
}
public static GameEvent getEvent(EventType type, UUID targetId, Ability source, UUID playerId, String data, int amount) {
@ -700,21 +692,18 @@ public class GameEvent implements Serializable {
return new GameEvent(customEventType, targetId, source, playerId);
}
private GameEvent(EventType type, UUID customEventType,
UUID targetId, UUID sourceId, UUID playerId,
int amount, boolean flag
) {
this(type, customEventType, targetId, sourceId, playerId, amount, flag, null);
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, UUID sourceId, UUID playerId,
UUID targetId, Ability source, UUID playerId,
int amount, boolean flag, ApprovingObject approvingObject
) {
this.type = type;
this.customEventType = customEventType;
this.targetId = targetId;
this.sourceId = sourceId;
this.sourceId = source == null ? null : source.getSourceId(); // We only keep the sourceId from the whole source.
this.amount = amount;
this.playerId = playerId;
this.flag = flag;
@ -863,6 +852,18 @@ public class GameEvent implements Serializable {
return identifier.equals(approvingObject.getApprovingAbility().getIdentifier());
}
/**
* 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
*/
protected void setSourceId(UUID sourceId) {
this.sourceId = sourceId;
}
@Override
public String toString() {
return this.type.toString();