magefree / magefree/mage

Dev: TARGETED and TARGET events must be refactored to support objectId data

Open
#8,395 0 comments 0 reactions 0 assignees View on GitHub
refactoring
Dominant language
Java
Stars
2.4k
Forks
940
Avg merge
2d 12h
Merged PRs (30d)
160

Description

Current `GameEvent.EventType.TARGETED` game event lost information about source of the event -- it contains only `sourceId` (e.g. id of the targeting card). But it doesn't contains `objectId` information (e.g. real object id that called the target).

Use case: if you need to find a stack object but the stack contains multiple objects from the same card (bug example and workaround: #8394). It's ok in most use cases cause you need to check the controller only, but it's potentially buggy on stack object usage.

TODO:
* [ ] Add `TargetedEvent` class for `TARGETED` event (example: `ManaPaidEvent`). It must contains `Ability source` and `UUID objectId` params and updated docs (`TARGETED` event must have objectId description too). You can't store `objectId` data in the `sourceId` field due #7242.
* [ ] Replace all `getEvent(GameEvent.EventType.TARGETED` by new `TargetedEvent` with additional param `objectId`.
* [ ] It require to modify all `void addTarget(UUID id...` Target's methods by additional `objectId` param (there are ~100 calls of the methods):
* calls from effects or game engine must pass `source.getSourceId()` to `objectId` param;
* calls from stack objects must pass an own id;
* [ ] ? Maybe `TARGET` event must be refactored same way?

P.S. Another potentially refactored events or places can be found by:
* `= game.getStack().getStackObject(event.getSourceId());`

Good usage (controller info will be same for all source's objects):
![shot_211019_101346](https://user-images.githubusercontent.com/8344157/137857661-806d8d94-7ab9-47c3-a9dd-3c468c936174.png)

Bad usage (you need stack object id for the effect):
![shot_211019_101650](https://user-images.githubusercontent.com/8344157/137857551-56b9023a-d8dc-4742-9c51-a078511c2bfb.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.