2022-11-11 04:42:08 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright 2022 - c0de <c0de@c0de.dev>
|
|
|
|
# Licensed under the MIT License (https://opensource.org/licenses/MIT)
|
|
|
|
|
2022-12-10 04:30:36 +00:00
|
|
|
# pylint: disable=missing-module-docstring,too-few-public-methods
|
2022-11-11 04:42:08 +00:00
|
|
|
|
|
|
|
from database.models import GameModel as Game
|
2022-11-12 02:06:14 +00:00
|
|
|
from game.base import BaseGameManager
|
2022-11-11 04:42:08 +00:00
|
|
|
|
2022-11-11 04:44:24 +00:00
|
|
|
|
2022-11-11 04:42:08 +00:00
|
|
|
class NewGameManager(BaseGameManager):
|
|
|
|
"""Commands that run at the start of a new game"""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
2024-04-23 22:19:20 +00:00
|
|
|
self.commands.append(("bb", self.start))
|
2022-11-11 04:42:08 +00:00
|
|
|
|
|
|
|
async def start(self):
|
|
|
|
"""
|
|
|
|
Start command - Starts a new game if there isn't already one running
|
|
|
|
"""
|
|
|
|
|
|
|
|
if self.is_running:
|
|
|
|
return await self.message.channel.send("A game is already running")
|
|
|
|
|
|
|
|
self.is_running = True
|
|
|
|
|
|
|
|
# game.pitch_value is unknown at the start of the game
|
2022-12-10 03:34:32 +00:00
|
|
|
self.game = Game.create(server_id=self.message.channel.id)
|
2022-11-11 04:42:08 +00:00
|
|
|
|
|
|
|
await self.message.channel.send("Send me your guesses with !guess <number>")
|