rework batch events (#13066)

* add new framework for batch triggers

apply for tapped, untapped, sacrificed, milled

simplify Ob Nixilis, Captive Kingpin

* add a verify check

* fix mistakes

* add simple tests

* another test

* zone change - enters battlefield

* zone change: not battlefield

* zone change - leaves battlefield

* fix Kaya Spirit's Justice

* rename OneOrMoreCombatDamagePlayerTriggeredAbility

* refactor OneOrMoreDamagePlayerTriggeredAbility

* new YoureDealtDamageTriggeredAbility

* new OpponentDealtNoncombatDamageTriggeredAbility

* rework Risona, Asari Commander

* simplify War Elemental

* Add damage batch by source

rework some delayed triggered abilities

* fix Mindblade Render

* rework Initiative and a few others

* [temp] initiative test

* refactor: common style for DealsDamageSourceTriggeredAbility

* refactor cards to use common DealsDamageSourceTriggeredAbility

* update damage players batch triggers

* fix mistake in initiative

* new DealtDamageAnyTriggeredAbility

* new DealtCombatDamageToSourceTriggeredAbility

* update dealt damage to permanent batch triggered abilities

* refactor Hot Soup and param in DealtDamageAttachedTriggeredAbility

* a few more permanent batch triggered abilities

* fix mistake

* update some more damage batch triggers

* add test for Phyrexian Negator

* update Felix Five-Boots and enable test

update Wayta, Trainer Prodigy to align

* update damage batch by source triggers

* undo mistaken change

* fix verify

* cleanup unused methods

* Revert "[temp] initiative test"

This reverts commit 11ed19295fb4f54f5e0870acd4d3d515b54761f1.

* Revert "add a verify check"

This reverts commit e7de47a6562f13c127fdc4c29a7735a08f8da9ea.

* fixes from checking text discrepancies

* fix Shriekwood Devourer

* merge fix

---------

Co-authored-by: Susucre <34709007+Susucre@users.noreply.github.com>
This commit is contained in:
xenohedron 2024-11-19 21:23:08 -05:00 committed by GitHub
parent cef2a1edc8
commit d06d594934
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
192 changed files with 2411 additions and 3363 deletions

View file

@ -73,7 +73,7 @@ public class GameEvent implements Serializable {
*/
ZONE_CHANGE,
ZONE_CHANGE_GROUP, // between two specific zones only; TODO: rework all usages to ZONE_CHANGE_BATCH instead, see #11895
ZONE_CHANGE_BATCH, // all zone changes that occurred from a single effect
ZONE_CHANGE_BATCH(true), // all zone changes that occurred from a single effect
DRAW_TWO_OR_MORE_CARDS, // event calls for multi draws only (if player draws 2+ cards at once)
DRAW_CARD, DREW_CARD,
EXPLORE, EXPLORED, // targetId is exploring permanent, playerId is its controller
@ -116,11 +116,11 @@ public class GameEvent implements Serializable {
combines all MILLED_CARD events for a player milling card at the same time in a single batch
playerId the id of the player whose batch it is
*/
MILLED_CARDS_BATCH_FOR_ONE_PLAYER,
MILLED_CARDS_BATCH_FOR_ONE_PLAYER(true),
/* MILLED_CARDS_BATCH_FOR_ALL,
combines all MILLED_CARD events for any player in a single batch
*/
MILLED_CARDS_BATCH_FOR_ALL,
MILLED_CARDS_BATCH_FOR_ALL(true),
/* DAMAGED_PLAYER
targetId the id of the damaged player
@ -134,18 +134,21 @@ public class GameEvent implements Serializable {
/* DAMAGED_BATCH_FOR_PLAYERS,
combines all player damage events to a single batch (event)
*/
DAMAGED_BATCH_FOR_PLAYERS,
DAMAGED_BATCH_FOR_PLAYERS(true),
/* DAMAGED_BATCH_FOR_ONE_PLAYER
combines all player damage events to a single batch (event) and split it per damaged player
targetId the id of the damaged player (playerId won't work for batch)
*/
DAMAGED_BATCH_FOR_ONE_PLAYER,
DAMAGED_BATCH_FOR_ONE_PLAYER(true),
/* DAMAGED_BATCH_BY_SOURCE
combine all damage events from a single source to a single batch (event)
*/
DAMAGED_BATCH_BY_SOURCE(true),
/* DAMAGED_BATCH_FOR_ALL
includes all damage events, both permanent damage and player damage, in single batch event
*/
DAMAGED_BATCH_FOR_ALL,
DAMAGED_BATCH_FOR_ALL(true),
/* DAMAGED_BATCH_FIRED
* 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).
@ -171,7 +174,7 @@ public class GameEvent implements Serializable {
amount amount of life loss
flag true = from combat damage - other from non combat damage
*/
LOST_LIFE_BATCH,
LOST_LIFE_BATCH(true),
/* LOST_LIFE_BATCH
combines all player life lost events to a single batch (event)
*/
@ -426,7 +429,7 @@ public class GameEvent implements Serializable {
/* TAPPED_BATCH
combine all TAPPED events occuring at the same time in a single event
*/
TAPPED_BATCH,
TAPPED_BATCH(true),
UNTAP,
/* UNTAPPED,
targetId untapped permanent
@ -439,7 +442,7 @@ public class GameEvent implements Serializable {
/* UNTAPPED_BATCH
combine all UNTAPPED events occuring at the same time in a single event
*/
UNTAPPED_BATCH,
UNTAPPED_BATCH(true),
FLIP, FLIPPED,
TRANSFORMING, TRANSFORMED,
ADAPT,
@ -494,12 +497,12 @@ public class GameEvent implements Serializable {
/* DAMAGED_BATCH_FOR_PERMANENTS
combine all permanent damage events to a single batch (event)
*/
DAMAGED_BATCH_FOR_PERMANENTS,
DAMAGED_BATCH_FOR_PERMANENTS(true),
/* DAMAGED_BATCH_FOR_ONE_PERMANENT
combines all permanent damage events to a single batch (event) and split it per damaged permanent
*/
DAMAGED_BATCH_FOR_ONE_PERMANENT,
DAMAGED_BATCH_FOR_ONE_PERMANENT(true),
DESTROY_PERMANENT,
/* DESTROY_PERMANENT_BY_LEGENDARY_RULE
@ -515,7 +518,7 @@ public class GameEvent implements Serializable {
flag true if no regeneration is allowed
*/
DESTROYED_PERMANENT,
SACRIFICE_PERMANENT, SACRIFICED_PERMANENT, SACRIFICED_PERMANENT_BATCH,
SACRIFICE_PERMANENT, SACRIFICED_PERMANENT, SACRIFICED_PERMANENT_BATCH(true),
FIGHTED_PERMANENT,
BATCH_FIGHT,
EXPLOITED_CREATURE,
@ -669,7 +672,21 @@ public class GameEvent implements Serializable {
*/
GAVE_GIFT,
// custom events - must store some unique data to track
CUSTOM_EVENT
CUSTOM_EVENT;
private final boolean isBatch;
EventType() {
this(false);
}
EventType(boolean isBatch) {
this.isBatch = isBatch;
}
public boolean isBatch() {
return isBatch;
}
}
public GameEvent(EventType type, UUID targetId, Ability source, UUID playerId) {