forked from c0de/BaseballBot
Remove check_is_running decorator since it didn't work
This commit is contained in:
parent
7cf006cd4f
commit
5cf6b30eb2
@ -24,24 +24,6 @@ from database.models import (
|
|||||||
from game.guess import ProcessGuess
|
from game.guess import ProcessGuess
|
||||||
|
|
||||||
|
|
||||||
def check_is_running(method):
|
|
||||||
"""
|
|
||||||
Decorator that determines if the game is running or not
|
|
||||||
"""
|
|
||||||
|
|
||||||
async def wrapper(self):
|
|
||||||
|
|
||||||
if self.is_running and self.new_game:
|
|
||||||
return await self.message.channel.send("A game is already running")
|
|
||||||
|
|
||||||
if not self.is_running and not self.new_game:
|
|
||||||
return await self.message.channel.send("There is no game running")
|
|
||||||
|
|
||||||
await method(self)
|
|
||||||
|
|
||||||
return wrapper
|
|
||||||
|
|
||||||
|
|
||||||
class GameManager:
|
class GameManager:
|
||||||
"""
|
"""
|
||||||
The game state class
|
The game state class
|
||||||
@ -53,8 +35,6 @@ class GameManager:
|
|||||||
# Only one game should run at at time
|
# Only one game should run at at time
|
||||||
self.is_running = False
|
self.is_running = False
|
||||||
|
|
||||||
self.new_game = True
|
|
||||||
|
|
||||||
self.commands = [
|
self.commands = [
|
||||||
("braveball", self.start),
|
("braveball", self.start),
|
||||||
("resolve", self.stop),
|
("resolve", self.stop),
|
||||||
@ -87,15 +67,15 @@ class GameManager:
|
|||||||
"""
|
"""
|
||||||
database.close()
|
database.close()
|
||||||
|
|
||||||
# @check_is_running
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
"""
|
"""
|
||||||
Start command - Starts a new game if there isn't already one running
|
Start command - Starts a new game if there isn't already one running
|
||||||
"""
|
"""
|
||||||
# print(dir(self.message))
|
|
||||||
|
if self.is_running:
|
||||||
|
return await self.message.channel.send("A game is already running")
|
||||||
|
|
||||||
self.is_running = True
|
self.is_running = True
|
||||||
self.new_game = False
|
|
||||||
|
|
||||||
# game.pitch_value is unknown at the start of the game
|
# game.pitch_value is unknown at the start of the game
|
||||||
self.game = Game.create(game_id=uuid.uuid4(), server_id=self.message.channel.id)
|
self.game = Game.create(game_id=uuid.uuid4(), server_id=self.message.channel.id)
|
||||||
@ -141,13 +121,15 @@ class GameManager:
|
|||||||
|
|
||||||
return int(pitch_value)
|
return int(pitch_value)
|
||||||
|
|
||||||
# @check_is_running
|
|
||||||
async def stop(self):
|
async def stop(self):
|
||||||
"""
|
"""
|
||||||
Stop command - Stops the game if it is currently running,
|
Stop command - Stops the game if it is currently running,
|
||||||
saves the pitch value, and displays differences
|
saves the pitch value, and displays differences
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if not self.is_running:
|
||||||
|
return await self.message.channel.send("There is no game running")
|
||||||
|
|
||||||
# How many valid guesses got placed?
|
# How many valid guesses got placed?
|
||||||
guess_count = (
|
guess_count = (
|
||||||
Guess.select()
|
Guess.select()
|
||||||
@ -191,13 +173,15 @@ class GameManager:
|
|||||||
self.is_running = False
|
self.is_running = False
|
||||||
self.game = None
|
self.game = None
|
||||||
|
|
||||||
# @check_is_running
|
|
||||||
async def guess(self):
|
async def guess(self):
|
||||||
"""
|
"""
|
||||||
Guess command - Allows the player to add a guess to the current
|
Guess command - Allows the player to add a guess to the current
|
||||||
running game
|
running game
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if not self.is_running:
|
||||||
|
return await self.message.channel.send("There is no game running")
|
||||||
|
|
||||||
value = int(self.message.content.split()[1])
|
value = int(self.message.content.split()[1])
|
||||||
if value < 1 or value > 1000:
|
if value < 1 or value > 1000:
|
||||||
return await self.message.channel.send(
|
return await self.message.channel.send(
|
||||||
@ -232,7 +216,7 @@ class GameManager:
|
|||||||
of the players and their points
|
of the players and their points
|
||||||
"""
|
"""
|
||||||
message = (
|
message = (
|
||||||
"Players, who played recently, with their points highest to lowest\n\n"
|
"\nPlayers, who played recently, with their points highest to lowest\n\n"
|
||||||
)
|
)
|
||||||
message += "Player | Total Points | Last Played\n"
|
message += "Player | Total Points | Last Played\n"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user