Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
skizzerz committed Nov 10, 2024
1 parent 49c3930 commit 90148fd
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 5 deletions.
32 changes: 32 additions & 0 deletions botconfig.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ def merge(metadata: dict[str, Any], base, settings, *path: str,
if not path:
path = ("<root>",)

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

Expand All @@ -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")
Expand Down
72 changes: 71 additions & 1 deletion src/defaultsettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -1108,18 +1171,25 @@ 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
_default: 5
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
Expand Down

0 comments on commit 90148fd

Please sign in to comment.