mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 12:52:06 -08:00
consolidate batch event constructor (related to 7c3bbed8)
This commit is contained in:
parent
f482eef06a
commit
30d498b80f
9 changed files with 13 additions and 19 deletions
|
|
@ -19,16 +19,6 @@ public abstract class BatchEvent<T extends GameEvent> extends GameEvent {
|
|||
private final boolean singleSourceId;
|
||||
private final boolean singlePlayerId;
|
||||
|
||||
/**
|
||||
* @param eventType specific type of event
|
||||
* @param singleSourceId if true, all included events must have same source id
|
||||
* @param singleTargetId if true, all included events must have same target id
|
||||
* @param firstEvent added to initialize the batch (batch is never empty)
|
||||
*/
|
||||
protected BatchEvent(EventType eventType, boolean singleTargetId, boolean singleSourceId, T firstEvent) {
|
||||
this(eventType, singleTargetId, singleSourceId, false, firstEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eventType specific type of event
|
||||
* @param singleSourceId if true, all included events must have same source id
|
||||
|
|
@ -67,7 +57,10 @@ public abstract class BatchEvent<T extends GameEvent> extends GameEvent {
|
|||
throw new IllegalStateException("Wrong code usage. Batch event initiated with single target id, but trying to add event with different target id");
|
||||
}
|
||||
if (singleSourceId && !getSourceId().equals(event.getSourceId())) {
|
||||
throw new IllegalStateException("Wrong code usage. Batch event initiated with single source id, but trying to add event with different target id");
|
||||
throw new IllegalStateException("Wrong code usage. Batch event initiated with single source id, but trying to add event with different source id");
|
||||
}
|
||||
if (singlePlayerId && !getPlayerId().equals(event.getPlayerId())) {
|
||||
throw new IllegalStateException("Wrong code usage. Batch event initiated with single player id, but trying to add event with different player id");
|
||||
}
|
||||
this.events.add(event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ package mage.game.events;
|
|||
public class DamagedBatchAllEvent extends BatchEvent<DamagedEvent> {
|
||||
|
||||
public DamagedBatchAllEvent(DamagedEvent firstEvent) {
|
||||
super(EventType.DAMAGED_BATCH_FOR_ALL, false, false, firstEvent);
|
||||
super(EventType.DAMAGED_BATCH_FOR_ALL, false, false, false, firstEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package mage.game.events;
|
|||
public class DamagedBatchForOnePermanentEvent extends BatchEvent<DamagedPermanentEvent> {
|
||||
|
||||
public DamagedBatchForOnePermanentEvent(DamagedPermanentEvent firstEvent) {
|
||||
super(GameEvent.EventType.DAMAGED_BATCH_FOR_ONE_PERMANENT, true, false, firstEvent);
|
||||
super(GameEvent.EventType.DAMAGED_BATCH_FOR_ONE_PERMANENT, true, false, false, firstEvent);
|
||||
}
|
||||
|
||||
public boolean isCombatDamage() {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ package mage.game.events;
|
|||
public class DamagedBatchForOnePlayerEvent extends BatchEvent<DamagedPlayerEvent> {
|
||||
|
||||
public DamagedBatchForOnePlayerEvent(DamagedPlayerEvent firstEvent) {
|
||||
super(EventType.DAMAGED_BATCH_FOR_ONE_PLAYER, true, false, firstEvent);
|
||||
super(EventType.DAMAGED_BATCH_FOR_ONE_PLAYER, true, false, false, firstEvent);
|
||||
// TODO: rework to support singlePlayerId = true
|
||||
}
|
||||
|
||||
public boolean isCombatDamage() {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ package mage.game.events;
|
|||
public class DamagedBatchForPermanentsEvent extends BatchEvent<DamagedPermanentEvent> {
|
||||
|
||||
public DamagedBatchForPermanentsEvent(DamagedPermanentEvent firstEvent) {
|
||||
super(EventType.DAMAGED_BATCH_FOR_PERMANENTS, false, false, firstEvent);
|
||||
super(EventType.DAMAGED_BATCH_FOR_PERMANENTS, false, false, false, firstEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ package mage.game.events;
|
|||
public class DamagedBatchForPlayersEvent extends BatchEvent<DamagedPlayerEvent> {
|
||||
|
||||
public DamagedBatchForPlayersEvent(DamagedPlayerEvent firstEvent) {
|
||||
super(GameEvent.EventType.DAMAGED_BATCH_FOR_PLAYERS, false, false, firstEvent);
|
||||
super(GameEvent.EventType.DAMAGED_BATCH_FOR_PLAYERS, false, false, false, firstEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import java.util.UUID;
|
|||
public class LifeLostBatchEvent extends BatchEvent<LifeLostEvent> {
|
||||
|
||||
public LifeLostBatchEvent(LifeLostEvent firstEvent) {
|
||||
super(EventType.LOST_LIFE_BATCH, false, false, firstEvent);
|
||||
super(EventType.LOST_LIFE_BATCH, false, false, false, firstEvent);
|
||||
}
|
||||
|
||||
public int getLifeLostByPlayer(UUID playerID) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package mage.game.events;
|
|||
public class TappedBatchEvent extends BatchEvent<TappedEvent> {
|
||||
|
||||
public TappedBatchEvent(TappedEvent firstEvent) {
|
||||
super(EventType.TAPPED_BATCH, false, false, firstEvent);
|
||||
super(EventType.TAPPED_BATCH, false, false, false, firstEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package mage.game.events;
|
|||
public class UntappedBatchEvent extends BatchEvent<UntappedEvent> {
|
||||
|
||||
public UntappedBatchEvent(UntappedEvent firstEvent) {
|
||||
super(EventType.UNTAPPED_BATCH, false, false, firstEvent);
|
||||
super(EventType.UNTAPPED_BATCH, false, false, false, firstEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue