forked from External/mage
clean all usage of GameEvent::setSourceId
This commit is contained in:
parent
8771d9b7f5
commit
868cd4d8fd
40 changed files with 114 additions and 100 deletions
|
|
@ -1959,9 +1959,9 @@ public abstract class GameImpl implements Game {
|
|||
informPlayers("You have planeswalked to " + newPlane.getLogName());
|
||||
|
||||
// Fire off the planeswalked event
|
||||
GameEvent event = new GameEvent(GameEvent.EventType.PLANESWALK, newPlane.getId(), null, newPlane.getId(), 0, true);
|
||||
GameEvent event = new GameEvent(GameEvent.EventType.PLANESWALK, newPlane.getId(), (Ability) null, newPlane.getId(), 0, true);
|
||||
if (!replaceEvent(event)) {
|
||||
GameEvent ge = new GameEvent(GameEvent.EventType.PLANESWALKED, newPlane.getId(), null, newPlane.getId(), 0, true);
|
||||
GameEvent ge = new GameEvent(GameEvent.EventType.PLANESWALKED, newPlane.getId(), (Ability) null, newPlane.getId(), 0, true);
|
||||
fireEvent(ge);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import java.util.UUID;
|
|||
public class AttachEvent extends GameEvent {
|
||||
|
||||
public AttachEvent(UUID targetPermanentId, Permanent attachment, Ability source) {
|
||||
super(GameEvent.EventType.ATTACH, targetPermanentId, null, attachment.getControllerId());
|
||||
this.setSourceId(attachment.getId());
|
||||
super(GameEvent.EventType.ATTACH, targetPermanentId, attachment.getId(), attachment.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import java.util.UUID;
|
|||
*/
|
||||
public class AttachedEvent extends GameEvent {
|
||||
|
||||
// TODO: investigate why source is provided but not used at all?
|
||||
public AttachedEvent(UUID targetPermanentId, Permanent attachment, Ability source) {
|
||||
super(GameEvent.EventType.ATTACHED, targetPermanentId, null, attachment.getControllerId());
|
||||
this.setSourceId(attachment.getId());
|
||||
super(GameEvent.EventType.ATTACHED, targetPermanentId, attachment.getId(), attachment.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import java.util.UUID;
|
|||
public class AttackerDeclaredEvent extends GameEvent {
|
||||
|
||||
public AttackerDeclaredEvent(UUID targetId, UUID attackerId, UUID attackerControllerId) {
|
||||
super(GameEvent.EventType.ATTACKER_DECLARED, targetId, null, attackerControllerId);
|
||||
this.setSourceId(attackerId);
|
||||
super(GameEvent.EventType.ATTACKER_DECLARED, targetId, attackerId, attackerControllerId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,21 +9,25 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* Special events created by game engine to track batches of events that occur simultaneously,
|
||||
* for triggers that need such information
|
||||
*
|
||||
* @author xenohedron
|
||||
*/
|
||||
public abstract class BatchEvent<T extends GameEvent> extends GameEvent {
|
||||
|
||||
private final Set<T> events = new HashSet<>();
|
||||
private final boolean singleTargetId;
|
||||
private final boolean singleSourceId;
|
||||
|
||||
/**
|
||||
* @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, T firstEvent) {
|
||||
super(eventType, (singleTargetId ? firstEvent.getTargetId() : null), null, null);
|
||||
protected BatchEvent(EventType eventType, boolean singleTargetId, boolean singleSourceId, T firstEvent) {
|
||||
super(eventType, (singleTargetId ? firstEvent.getTargetId() : null), (singleSourceId ? firstEvent.getSourceId() : null), null);
|
||||
this.singleTargetId = singleTargetId;
|
||||
this.singleSourceId = singleSourceId;
|
||||
if (firstEvent instanceof BatchEvent) { // sanity check, if you need it then think twice and research carefully
|
||||
throw new UnsupportedOperationException("Wrong code usage: nesting batch events not supported");
|
||||
}
|
||||
|
|
@ -34,14 +38,18 @@ public abstract class BatchEvent<T extends GameEvent> extends GameEvent {
|
|||
* For alternate event structure logic used by ZoneChangeBatchEvent, list of events starts empty.
|
||||
*/
|
||||
protected BatchEvent(EventType eventType) {
|
||||
super(eventType, null, null, null);
|
||||
super(eventType, null, (UUID) null, null);
|
||||
this.singleTargetId = false;
|
||||
this.singleSourceId = false;
|
||||
}
|
||||
|
||||
public void addEvent(T event) {
|
||||
if (singleTargetId && !getTargetId().equals(event.getTargetId())) {
|
||||
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");
|
||||
}
|
||||
this.events.add(event);
|
||||
}
|
||||
|
||||
|
|
@ -87,8 +95,10 @@ public abstract class BatchEvent<T extends GameEvent> extends GameEvent {
|
|||
}
|
||||
|
||||
@Override // events can store a diff value, so search it from events list instead
|
||||
@Deprecated // no use case currently supported
|
||||
public UUID getSourceId() {
|
||||
if (singleSourceId) {
|
||||
return super.getSourceId();
|
||||
}
|
||||
throw new IllegalStateException("Wrong code usage. Must search value from a getEvents list");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import java.util.UUID;
|
|||
public class BlockerDeclaredEvent extends GameEvent {
|
||||
|
||||
public BlockerDeclaredEvent(UUID attackerId, UUID blockerId, UUID blockerControllerId) {
|
||||
super(GameEvent.EventType.BLOCKER_DECLARED, attackerId, null, blockerControllerId);
|
||||
this.setSourceId(blockerId);
|
||||
super(GameEvent.EventType.BLOCKER_DECLARED, attackerId, blockerId, blockerControllerId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,11 @@ public class CoinFlippedEvent extends GameEvent {
|
|||
private final int flipCount; // Number of flips that lead to this event. see [[Krark's Thumb]]
|
||||
|
||||
CoinFlippedEvent(UUID playerId, UUID sourceId, int flipCount, boolean result, boolean chosen, boolean winnable) {
|
||||
super(GameEvent.EventType.COIN_FLIPPED, playerId, null, playerId);
|
||||
super(GameEvent.EventType.COIN_FLIPPED, playerId, sourceId, playerId);
|
||||
this.result = result;
|
||||
this.chosen = chosen;
|
||||
this.winnable = winnable;
|
||||
this.flipCount = flipCount;
|
||||
this.setSourceId(sourceId);
|
||||
}
|
||||
|
||||
public boolean getResult() {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import java.util.UUID;
|
|||
public class CopiedStackObjectEvent extends GameEvent {
|
||||
|
||||
public CopiedStackObjectEvent(MageObject target, MageObject newCopy, UUID newControllerId) {
|
||||
super(GameEvent.EventType.COPIED_STACKOBJECT, newCopy.getId(), null, newControllerId);
|
||||
this.setSourceId(target.getId());
|
||||
super(GameEvent.EventType.COPIED_STACKOBJECT, newCopy.getId(), target.getId(), newControllerId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,8 @@ public abstract class DamageEvent extends GameEvent {
|
|||
private boolean asThoughWither = false;
|
||||
|
||||
public DamageEvent(EventType type, UUID targetId, UUID damageSourceId, UUID targetControllerId, int amount, boolean preventable, boolean combat) {
|
||||
super(type, targetId, null, targetControllerId, amount, preventable);
|
||||
super(type, targetId, damageSourceId, targetControllerId, amount, preventable);
|
||||
this.combat = combat;
|
||||
this.setSourceId(damageSourceId);
|
||||
}
|
||||
|
||||
public boolean isCombatDamage() {
|
||||
|
|
|
|||
|
|
@ -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, firstEvent);
|
||||
super(EventType.DAMAGED_BATCH_FOR_ALL, false, false, firstEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package mage.game.events;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
||||
/**
|
||||
* Does not contain any info on damage events, and can fire even when all damage is prevented.
|
||||
* Fire any time a DAMAGED_BATCH_FOR_ALL could have fired (combat & noncombat).
|
||||
|
|
@ -10,6 +12,6 @@ package mage.game.events;
|
|||
public class DamagedBatchCouldHaveFiredEvent extends GameEvent {
|
||||
|
||||
public DamagedBatchCouldHaveFiredEvent(boolean combat) {
|
||||
super(EventType.DAMAGED_BATCH_COULD_HAVE_FIRED, null, null, null, 0, combat);
|
||||
super(EventType.DAMAGED_BATCH_COULD_HAVE_FIRED, null, (Ability) null, null, 0, combat);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, firstEvent);
|
||||
super(GameEvent.EventType.DAMAGED_BATCH_FOR_ONE_PERMANENT, true, false, firstEvent);
|
||||
}
|
||||
|
||||
public boolean isCombatDamage() {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package mage.game.events;
|
|||
public class DamagedBatchForOnePlayerEvent extends BatchEvent<DamagedPlayerEvent> {
|
||||
|
||||
public DamagedBatchForOnePlayerEvent(DamagedPlayerEvent firstEvent) {
|
||||
super(EventType.DAMAGED_BATCH_FOR_ONE_PLAYER, true, firstEvent);
|
||||
super(EventType.DAMAGED_BATCH_FOR_ONE_PLAYER, true, false, firstEvent);
|
||||
}
|
||||
|
||||
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, firstEvent);
|
||||
super(EventType.DAMAGED_BATCH_FOR_PERMANENTS, 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, firstEvent);
|
||||
super(GameEvent.EventType.DAMAGED_BATCH_FOR_PLAYERS, false, false, firstEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@ public abstract class DamagedEvent extends GameEvent {
|
|||
protected int excess;
|
||||
|
||||
public DamagedEvent(EventType type, UUID targetId, UUID attackerId, UUID playerId, int amount, boolean combat) {
|
||||
super(type, targetId, null, playerId, amount, false);
|
||||
super(type, targetId, attackerId, playerId, amount, false);
|
||||
this.combat = combat;
|
||||
this.excess = 0;
|
||||
this.setSourceId(attackerId);
|
||||
}
|
||||
|
||||
public boolean isCombatDamage() {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import java.util.UUID;
|
|||
public class DeclareAttackerEvent extends GameEvent {
|
||||
|
||||
public DeclareAttackerEvent(UUID targetId, UUID attackerId, UUID attackerControllerId) {
|
||||
super(GameEvent.EventType.DECLARE_ATTACKER, targetId, null, attackerControllerId);
|
||||
this.setSourceId(attackerId);
|
||||
super(GameEvent.EventType.DECLARE_ATTACKER, targetId, attackerId, attackerControllerId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import java.util.UUID;
|
|||
public class DeclareBlockerEvent extends GameEvent {
|
||||
|
||||
public DeclareBlockerEvent(UUID attackerId, UUID blockerId, UUID blockerControllerId) {
|
||||
super(GameEvent.EventType.DECLARE_BLOCKER, attackerId, null, blockerControllerId);
|
||||
this.setSourceId(blockerId);
|
||||
super(GameEvent.EventType.DECLARE_BLOCKER, attackerId, blockerId, blockerControllerId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.game.events;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
|
@ -15,7 +16,7 @@ public class DefenderAttackedEvent extends GameEvent {
|
|||
private final Set<MageObjectReference> morSet = new HashSet<>();
|
||||
|
||||
public DefenderAttackedEvent(UUID targetId, UUID playerId) {
|
||||
super(EventType.DEFENDER_ATTACKED, targetId, null, playerId);
|
||||
super(EventType.DEFENDER_ATTACKED, targetId, (Ability) null, playerId);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,16 @@ import java.util.UUID;
|
|||
public class DrawCardEvent extends GameEvent {
|
||||
|
||||
public DrawCardEvent(UUID playerId, Ability source, GameEvent originalDrawEvent) {
|
||||
super(GameEvent.EventType.DRAW_CARD, playerId, source, playerId, 0, false);
|
||||
super(GameEvent.EventType.DRAW_CARD, playerId,
|
||||
// source of draw events must be kept between replacements, example: UnpredictableCycloneTest
|
||||
originalDrawEvent == null
|
||||
? source == null ? null : source.getSourceId()
|
||||
: originalDrawEvent.getSourceId(),
|
||||
playerId, 0, false);
|
||||
|
||||
// source of draw events must be kept between replacements, example: UnpredictableCycloneTest
|
||||
if (originalDrawEvent != null) {
|
||||
this.addAppliedEffects(originalDrawEvent.getAppliedEffects());
|
||||
this.setSourceId(originalDrawEvent.getSourceId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,16 @@ import java.util.UUID;
|
|||
public class DrawCardsEvent extends GameEvent {
|
||||
|
||||
public DrawCardsEvent(UUID playerId, Ability source, GameEvent originalDrawEvent, int amount) {
|
||||
super(GameEvent.EventType.DRAW_CARDS, playerId, source, playerId, amount, false);
|
||||
super(GameEvent.EventType.DRAW_CARDS, playerId,
|
||||
// source of draw events must be kept between replacements, example: UnpredictableCycloneTest
|
||||
originalDrawEvent == null
|
||||
? source == null ? null : source.getSourceId()
|
||||
: originalDrawEvent.getSourceId(),
|
||||
playerId, amount, false);
|
||||
|
||||
// source of draw events must be kept between replacements, example: UnpredictableCycloneTest
|
||||
if (originalDrawEvent != null) {
|
||||
this.addAppliedEffects(originalDrawEvent.getAppliedEffects());
|
||||
this.setSourceId(originalDrawEvent.getSourceId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,11 @@ import java.util.UUID;
|
|||
public class DrewCardEvent extends GameEvent {
|
||||
|
||||
public DrewCardEvent(UUID cardId, UUID playerId, Ability source, GameEvent originalDrawEvent) {
|
||||
super(EventType.DREW_CARD, cardId, source, playerId, 0, false);
|
||||
|
||||
super(EventType.DREW_CARD, cardId,
|
||||
// source of draw events must be kept between replacements, example: UnpredictableCycloneTest
|
||||
if (originalDrawEvent != null) {
|
||||
//this.addAppliedEffects(originalDrawEvent.getAppliedEffects()); // event can't used for replace, so no needs in applied effects
|
||||
this.setSourceId(originalDrawEvent.getSourceId());
|
||||
}
|
||||
originalDrawEvent == null
|
||||
? source == null ? null : source.getSourceId()
|
||||
: originalDrawEvent.getSourceId(),
|
||||
playerId, 0, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import java.util.UUID;
|
|||
*/
|
||||
public class EnchantPlayerEvent extends GameEvent {
|
||||
|
||||
// TODO: investigate why source is provided but not used at all?
|
||||
public EnchantPlayerEvent(UUID targetId, Permanent attachment, Ability source) {
|
||||
super(GameEvent.EventType.ENCHANT_PLAYER, targetId, null, attachment.getControllerId());
|
||||
this.setSourceId(attachment.getId());
|
||||
super(GameEvent.EventType.ENCHANT_PLAYER, targetId, attachment.getId(), attachment.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import java.util.UUID;
|
|||
*/
|
||||
public class EnchantedPlayerEvent extends GameEvent {
|
||||
|
||||
// TODO: investigate why source is provided but not used at all?
|
||||
public EnchantedPlayerEvent(UUID targetId, Permanent attachment, Ability source) {
|
||||
super(GameEvent.EventType.ENCHANTED_PLAYER, targetId, null, attachment.getControllerId());
|
||||
this.setSourceId(attachment.getId());
|
||||
super(GameEvent.EventType.ENCHANTED_PLAYER, targetId, attachment.getId(), attachment.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -641,23 +641,31 @@ public class GameEvent implements Serializable {
|
|||
}
|
||||
|
||||
public GameEvent(EventType type, UUID targetId, Ability source, UUID playerId) {
|
||||
this(type, null, targetId, source, playerId, 0, false);
|
||||
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);
|
||||
}
|
||||
|
||||
public GameEvent(EventType type, UUID targetId, Ability source, UUID playerId, ApprovingObject approvingObject) {
|
||||
this(type, null, targetId, source, playerId, 0, false, approvingObject);
|
||||
this(type, null, targetId, source == null ? null : source.getSourceId(), 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);
|
||||
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);
|
||||
}
|
||||
|
||||
public GameEvent(UUID customEventType, UUID targetId, Ability source, UUID playerId) {
|
||||
this(EventType.CUSTOM_EVENT, customEventType, targetId, source, playerId, 0, false);
|
||||
this(EventType.CUSTOM_EVENT, customEventType, targetId, source == null ? null : source.getSourceId(), 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(EventType.CUSTOM_EVENT, customEventType, targetId, source == null ? null : source.getSourceId(), playerId, amount, flag);
|
||||
}
|
||||
|
||||
public static GameEvent getEvent(EventType type, UUID targetId, Ability source, UUID playerId, int amount) {
|
||||
|
|
@ -674,7 +682,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, null, playerId);
|
||||
return new GameEvent(type, targetId, (UUID) null, playerId);
|
||||
}
|
||||
|
||||
public static GameEvent getEvent(EventType type, UUID targetId, Ability source, UUID playerId, String data, int amount) {
|
||||
|
|
@ -692,16 +700,21 @@ public class GameEvent implements Serializable {
|
|||
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, 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, ApprovingObject approvingObject) {
|
||||
UUID targetId, UUID sourceId, UUID playerId,
|
||||
int amount, boolean flag, ApprovingObject approvingObject
|
||||
) {
|
||||
this.type = type;
|
||||
this.customEventType = customEventType;
|
||||
this.targetId = targetId;
|
||||
this.sourceId = source == null ? null : source.getSourceId();
|
||||
this.sourceId = sourceId;
|
||||
this.amount = amount;
|
||||
this.playerId = playerId;
|
||||
this.flag = flag;
|
||||
|
|
@ -850,15 +863,6 @@ 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
|
||||
*
|
||||
* @param sourceId
|
||||
*/
|
||||
protected void setSourceId(UUID sourceId) {
|
||||
this.sourceId = sourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.type.toString();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import java.util.UUID;
|
|||
public class LifeLostBatchEvent extends BatchEvent<LifeLostEvent> {
|
||||
|
||||
public LifeLostBatchEvent(LifeLostEvent firstEvent) {
|
||||
super(EventType.LOST_LIFE_BATCH, false, firstEvent);
|
||||
super(EventType.LOST_LIFE_BATCH, false, false, firstEvent);
|
||||
}
|
||||
|
||||
public int getLifeLostByPlayer(UUID playerID) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import java.util.UUID;
|
|||
public class MadnessCardExiledEvent extends GameEvent {
|
||||
|
||||
public MadnessCardExiledEvent(UUID cardId, Ability source, UUID controllerId) {
|
||||
super(GameEvent.EventType.MADNESS_CARD_EXILED, cardId, null, controllerId);
|
||||
this.setSourceId(source.getOriginalId()); // save ability's id
|
||||
super(GameEvent.EventType.MADNESS_CARD_EXILED, cardId, source.getOriginalId(), controllerId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ public class ManaPaidEvent extends GameEvent {
|
|||
private final ManaType manaType;
|
||||
|
||||
public ManaPaidEvent(Ability abilityToPay, UUID manaSourceId, boolean manaFlag, UUID manaOriginalId, MageObject sourceObject, ManaType manaType) {
|
||||
super(GameEvent.EventType.MANA_PAID, abilityToPay.getId(), null, abilityToPay.getControllerId(), 0, manaFlag);
|
||||
this.setSourceId(manaSourceId);
|
||||
super(GameEvent.EventType.MANA_PAID, abilityToPay.getId(), manaSourceId, abilityToPay.getControllerId(), 0, manaFlag);
|
||||
this.setData(manaOriginalId.toString());
|
||||
this.sourcePaidId = abilityToPay.getSourceId();
|
||||
this.sourceObject = sourceObject;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package mage.game.events;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
|
||||
/**
|
||||
* Raise events for normal triggers, ignore state based triggers from StateTriggeredAbility
|
||||
|
|
@ -12,14 +10,20 @@ import java.util.UUID;
|
|||
public class NumberOfTriggersEvent extends GameEvent {
|
||||
|
||||
private final GameEvent sourceEvent;
|
||||
private final TriggeredAbility sourceTrigger;
|
||||
|
||||
public NumberOfTriggersEvent(Ability triggeredAbility, GameEvent sourceEvent) {
|
||||
public NumberOfTriggersEvent(TriggeredAbility triggeredAbility, GameEvent sourceEvent) {
|
||||
super(GameEvent.EventType.NUMBER_OF_TRIGGERS, null, triggeredAbility, triggeredAbility.getControllerId());
|
||||
this.sourceEvent = sourceEvent;
|
||||
this.sourceTrigger = triggeredAbility;
|
||||
this.amount = 1; // Number of times to trigger. Panharmonicon can change this.
|
||||
}
|
||||
|
||||
public GameEvent getSourceEvent() {
|
||||
return sourceEvent;
|
||||
}
|
||||
|
||||
public TriggeredAbility getSourceTrigger() {
|
||||
return sourceTrigger;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import java.util.UUID;
|
|||
public class PhaseChangedEvent extends GameEvent {
|
||||
|
||||
public PhaseChangedEvent(UUID playerId, TurnMod extraTurnMode) {
|
||||
super(GameEvent.EventType.PHASE_CHANGED, playerId, null, playerId);
|
||||
this.setSourceId(extraTurnMode == null ? null : extraTurnMode.getId());
|
||||
super(GameEvent.EventType.PHASE_CHANGED, playerId, extraTurnMode == null ? null : extraTurnMode.getId(), playerId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import java.util.UUID;
|
|||
*/
|
||||
public class PreventDamageEvent extends GameEvent {
|
||||
|
||||
// TODO: investigate why source is provided but not used?
|
||||
public PreventDamageEvent(UUID targetId, UUID attackerId, Ability source, UUID playerId, int damageToPrevent, boolean isCombatDamage) {
|
||||
super(GameEvent.EventType.PREVENT_DAMAGE, targetId, null, playerId, damageToPrevent, isCombatDamage);
|
||||
this.setSourceId(attackerId);
|
||||
super(GameEvent.EventType.PREVENT_DAMAGE, targetId, attackerId, playerId, damageToPrevent, isCombatDamage);
|
||||
}
|
||||
|
||||
public boolean isCombatDamage() {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import java.util.UUID;
|
|||
public class PreventedDamageEvent extends GameEvent {
|
||||
|
||||
public PreventedDamageEvent(UUID targetId, UUID attackerId, Ability source, UUID playerId, int preventedDamage) {
|
||||
super(GameEvent.EventType.PREVENTED_DAMAGE, targetId, null, playerId, preventedDamage, false);
|
||||
this.setSourceId(attackerId);
|
||||
super(GameEvent.EventType.PREVENTED_DAMAGE, targetId, attackerId, playerId, preventedDamage, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
package mage.game.events;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class StayAttachedEvent extends GameEvent {
|
||||
|
||||
// TODO: investigate why source is not used as source for the event?
|
||||
public StayAttachedEvent(UUID targetId, UUID attachmentId, Ability source) {
|
||||
super(GameEvent.EventType.STAY_ATTACHED, targetId, null, null);
|
||||
this.setSourceId(attachmentId);
|
||||
super(GameEvent.EventType.STAY_ATTACHED, targetId, attachmentId, null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package mage.game.events;
|
|||
public class TappedBatchEvent extends BatchEvent<TappedEvent> {
|
||||
|
||||
public TappedBatchEvent(TappedEvent firstEvent) {
|
||||
super(EventType.TAPPED_BATCH, false, firstEvent);
|
||||
super(EventType.TAPPED_BATCH, false, false, firstEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,13 +17,11 @@ public class TargetEvent extends GameEvent {
|
|||
* @param sourceControllerId can be different from real controller (example: ability instructs another player to targeting)
|
||||
*/
|
||||
public TargetEvent(Card target, UUID sourceId, UUID sourceControllerId) {
|
||||
super(GameEvent.EventType.TARGET, target.getId(), null, sourceControllerId);
|
||||
this.setSourceId(sourceId);
|
||||
super(GameEvent.EventType.TARGET, target.getId(), sourceId, sourceControllerId);
|
||||
}
|
||||
|
||||
public TargetEvent(Player target, UUID sourceId, UUID sourceControllerId) {
|
||||
super(GameEvent.EventType.TARGET, target.getId(), null, sourceControllerId);
|
||||
this.setSourceId(sourceId);
|
||||
super(GameEvent.EventType.TARGET, target.getId(), sourceId, sourceControllerId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import java.util.UUID;
|
|||
*/
|
||||
public class UnattachEvent extends GameEvent {
|
||||
|
||||
// TODO: investigate why source is not used as source for the event?
|
||||
public UnattachEvent(UUID targetId, UUID attachmentId, Permanent attachment, Ability source) {
|
||||
super(GameEvent.EventType.UNATTACH, targetId, null, attachment == null ? null : attachment.getControllerId());
|
||||
this.setSourceId(attachmentId);
|
||||
super(GameEvent.EventType.UNATTACH, targetId, attachmentId, attachment == null ? null : attachment.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import java.util.UUID;
|
|||
*/
|
||||
public class UnattachedEvent extends GameEvent {
|
||||
|
||||
// TODO: investigate why source is provided but not used at all?
|
||||
public UnattachedEvent(UUID targetId, UUID attachmentId, Permanent attachment, Ability source) {
|
||||
super(GameEvent.EventType.UNATTACHED, targetId, null, attachment == null ? null : attachment.getControllerId());
|
||||
this.setSourceId(attachmentId);
|
||||
super(GameEvent.EventType.UNATTACHED, targetId, attachmentId, attachment == null ? null : attachment.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package mage.game.events;
|
|||
public class UntappedBatchEvent extends BatchEvent<UntappedEvent> {
|
||||
|
||||
public UntappedBatchEvent(UntappedEvent firstEvent) {
|
||||
super(EventType.UNTAPPED_BATCH, false, firstEvent);
|
||||
super(EventType.UNTAPPED_BATCH, false, false, firstEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package mage.game.events;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -8,7 +10,7 @@ import java.util.UUID;
|
|||
public class UntappedEvent extends GameEvent {
|
||||
|
||||
public UntappedEvent(UUID targetId, UUID playerId, boolean duringUntapPhase) {
|
||||
super(EventType.UNTAPPED, targetId, null, playerId, 0, duringUntapPhase);
|
||||
super(EventType.UNTAPPED, targetId, (Ability) null, playerId, 0, duringUntapPhase);
|
||||
}
|
||||
|
||||
public boolean isAnUntapStepEvent() {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,9 @@ public class ZoneChangeGroupEvent extends GameEvent {
|
|||
private final Set<PermanentToken> tokens;
|
||||
/* added this */ Ability source;
|
||||
|
||||
// TODO: investigate why we just discard sourceId and provide source directly?
|
||||
public ZoneChangeGroupEvent(Set<Card> cards, Set<PermanentToken> tokens, UUID sourceId, Ability source, UUID playerId, Zone fromZone, Zone toZone) {
|
||||
super(GameEvent.EventType.ZONE_CHANGE_GROUP, null, null, playerId);
|
||||
super(GameEvent.EventType.ZONE_CHANGE_GROUP, null, (Ability) null, playerId);
|
||||
this.fromZone = fromZone;
|
||||
this.toZone = toZone;
|
||||
this.cards = cards;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue