From 90148fd1ba2339dcc1c5e2babfc8d0fb94116f45 Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Sun, 10 Nov 2024 13:55:36 -0700 Subject: [PATCH] Fixes - Add section to botconfig template to let admins know this is a thing they can do, along with a suggested set of weights - Make it so you can specify as ints instead of dicts in botconfig - Fix missing metadata in sleepy --- botconfig.example.yml | 32 ++++++++++++++++++ src/config.py | 8 ++--- src/defaultsettings.yml | 72 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 107 insertions(+), 5 deletions(-) diff --git a/botconfig.example.yml b/botconfig.example.yml index 423755e6..0a52ac60 100644 --- a/botconfig.example.yml +++ b/botconfig.example.yml @@ -164,6 +164,38 @@ gameplay: notice: true # Include which user is spectating in the above alert, if enabled. include_user: false + # You can adjust how likely gamemodes are to appear by default. Setting a mode to 0 will require that players + # select the mode with a majority vote before the game starts, ensuring it will never randomly appear. + # If you have a lot of new players, you can uncomment the following to disable the hardest modes by default + # (e.g. modes with special mechanics that could confuse new players) while making simpler modes far more likely. +# modes: +# # Very simple modes with little complexity +# default: 100 +# classic: 100 +# # Simple modes that introduce few twists, primarily team switching or win-stealing neutral roles +# alpha: 50 +# charming: 50 +# foolish: 50 +# lycan: 50 +# # Moderate modes that have more complex roles or introduce minor mechanical changes, such as totem or gun chances +# aleatoire: 10 +# drunkfire: 10 +# kaboom: 10 +# mad: 10 +# masquerade: 10 +# noreveal: 10 +# random: 10 +# # Difficult modes that feature more complex mechanical changes, such as modifying default win conditions +# evilvillage: 6 +# guardian: 6 +# mudkip: 6 +# rapidfire: 6 +# valentines: 6 +# # Very difficult modes that feature significant mechanical changes +# boreal: 0 +# pactbreaker: 0 +# maelstrom: 0 +# sleepy: 0 # Reaper. Users that leave during the game or are otherwise idle will be automatically removed from the game # after a period of time (by killing them in-game). This allows a game to continue onwards with the active players diff --git a/src/config.py b/src/config.py index 51929e72..ab725d45 100644 --- a/src/config.py +++ b/src/config.py @@ -262,8 +262,8 @@ def merge(metadata: dict[str, Any], base, settings, *path: str, if not path: path = ("",) - settings_type = metadata["_type"] - assert settings_type is not None + settings_type = metadata.get("_type", None) + assert settings_type is not None, f"Path {path} does not define a metadata type" if type_override is not None: settings_type = type_override @@ -284,13 +284,13 @@ def merge(metadata: dict[str, Any], base, settings, *path: str, ctors = metadata.get("_ctors", []) if ctors: - assert settings_type == "dict" and "_default" in metadata + assert settings_type == "dict" and "_default" in metadata, f"Path {path} defines a constructor but is not a dict with a default" if ctors and not isinstance(settings, dict): for ctor in ctors: # if a constructor fits our current data type, we'll merge that # into the default object and return it set_metadata = metadata["_default"][ctor["_set"]] - assert ctor["_type"] == set_metadata["_type"] + assert ctor["_type"] == set_metadata["_type"], f"Path {path} constructor type doesn't match the type of value it is setting" try: value = {ctor["_set"]: merge(set_metadata, Empty, settings, *path, ctor["_set"])} return merge(metadata, base, value, *path, strategy_override="replace") diff --git a/src/defaultsettings.yml b/src/defaultsettings.yml index 6fb28d97..03ea2386 100644 --- a/src/defaultsettings.yml +++ b/src/defaultsettings.yml @@ -893,6 +893,9 @@ gameplay: &gameplay aleatoire: _desc: Settings for the aleatoire game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -901,6 +904,9 @@ gameplay: &gameplay alpha: _desc: Settings for the alpha game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -909,6 +915,9 @@ gameplay: &gameplay boreal: _desc: Settings for the boreal game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: nights: _desc: How many nights the village needs to survive to win the game even if wolf shamans remain alive. @@ -949,6 +958,9 @@ gameplay: &gameplay charming: _desc: Settings for the charming game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -957,6 +969,9 @@ gameplay: &gameplay classic: _desc: Settings for the classic game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -965,6 +980,9 @@ gameplay: &gameplay default: _desc: Settings for the default game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -973,6 +991,9 @@ gameplay: &gameplay drunkfire: _desc: Settings for the drunkfire game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -981,6 +1002,9 @@ gameplay: &gameplay evilvillage: _desc: Settings for the evilvillage game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -989,6 +1013,9 @@ gameplay: &gameplay foolish: _desc: Settings for the foolish game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -997,6 +1024,9 @@ gameplay: &gameplay guardian: _desc: Settings for the guardian game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -1005,6 +1035,9 @@ gameplay: &gameplay kaboom: _desc: Settings for the kaboom game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -1013,6 +1046,9 @@ gameplay: &gameplay lycan: _desc: Settings for the lycan game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -1021,6 +1057,9 @@ gameplay: &gameplay mad: _desc: Settings for the mad game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -1029,6 +1068,9 @@ gameplay: &gameplay maelstrom: _desc: Settings for the maelstrom game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -1037,6 +1079,9 @@ gameplay: &gameplay masquerade: _desc: Settings for the masquerade game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -1045,6 +1090,9 @@ gameplay: &gameplay mudkip: _desc: Settings for the mudkip game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -1053,6 +1101,9 @@ gameplay: &gameplay noreveal: _desc: Settings for the noreveal game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -1061,6 +1112,9 @@ gameplay: &gameplay pactbreaker: _desc: Settings for the pactbreaker game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -1069,6 +1123,9 @@ gameplay: &gameplay random: _desc: Settings for the random game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -1077,6 +1134,9 @@ gameplay: &gameplay rapidfire: _desc: Settings for the rapidfire game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. @@ -1085,6 +1145,9 @@ gameplay: &gameplay sleepy: _desc: Settings for the sleepy game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: nightmare: _desc: Settings related to the nightmare mechanic in the sleepy mode. @@ -1108,6 +1171,10 @@ gameplay: &gameplay _desc: > How likely certain roles (seer, harlot, cultist) are to change into other roles when priest dies. A value between 0 and 1 is the percentage chance for these roles to turn (e.g. 0.42 is a 42% chance). + _type: + - float + - int + _default: 0.6 weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. _type: int @@ -1115,11 +1182,14 @@ gameplay: &gameplay valentines: _desc: Settings for the valentines game mode. _type: dict + _ctors: + - _type: int + _set: weight _default: weight: _desc: How likely this mode is to appear if there are no votes for gamemodes. _type: int - _default: 5 + _default: 0 ratelimits: &ratelimits _name: ratelimits