Core: add list/dict merging feature to triggers (#2793)

* proof of concept

* add dict support, block top/game level merge

* prevent key error when option being merged is new

* update triggers guide

* Add documentation about add/remove/replace

* move to trailing name instead of proper tag

* update docs

* confirm types

* Update Utils.py

* Update Generate.py

* pep8

* move to + syntax

* forgot to support sets

* specify received type of type error

* Update Generate.py

Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com>

* Apply suggestion from review

* add test for update weights

* move test to new test case

* Apply suggestions from code review

Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>

---------

Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com>
Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
This commit is contained in:
Silvris
2024-03-12 16:08:12 -05:00
committed by GitHub
parent 03d403ff51
commit fb9ef19c15
4 changed files with 94 additions and 5 deletions

View File

@@ -121,4 +121,31 @@ For example:
In this example (thanks to @Black-Sliver), if the `pupdunk` option is rolled, then the difficulty values will be rolled
again using the new options `normal`, `pupdunk_hard`, and `pupdunk_mystery`, and the exp modifier will be rerolled using
new weights for 150 and 200. This allows for two more triggers that will only be used for the new `pupdunk_hard`
and `pupdunk_mystery` options so that they will only be triggered on "pupdunk AND hard/mystery".
and `pupdunk_mystery` options so that they will only be triggered on "pupdunk AND hard/mystery".
Options that define a list, set, or dict can additionally have the character `+` added to the start of their name, which applies the contents of
the activated trigger to the already present equivalents in the game options.
For example:
```yaml
Super Metroid:
start_location:
landing_site: 50
aqueduct: 50
start_hints:
- Morph Ball
triggers:
- option_category: Super Metroid
option_name: start_location
option_result: aqueduct
options:
Super Metroid:
+start_hints:
- Gravity Suit
```
In this example, if the `start_location` option rolls `landing_site`, only a starting hint for Morph Ball will be created.
If `aqueduct` is rolled, a starting hint for Gravity Suit will also be created alongside the hint for Morph Ball.
Note that for lists, items can only be added, not removed or replaced. For dicts, defining a value for a present key will
replace that value within the dict.