Game registry
Registry managing active Werewolf games per Discord guild.
This class acts as a central storage for all running games, indexed by guild ID. It ensures that only one game instance exists per guild.
Source code in sources/bot/game_registry.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
create(guild)
async
¶
Return the guild's game, creating and setting it up if needed.
Source code in sources/bot/game_registry.py
40 41 42 43 | |
get_or_create(guild)
async
¶
Return the guild's game and whether this call created it.
Creation is serialized per guild so that concurrent calls for the same guild cannot set up two games while the first setup is still running, while different guilds are set up in parallel. Only the call that actually created the game gets True.
Source code in sources/bot/game_registry.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |