2019-10-04 22:00:47 +00:00
|
|
|
from app import db, ma
|
2019-10-02 03:42:21 +00:00
|
|
|
import enum
|
|
|
|
|
|
|
|
|
|
|
|
class TimeSettings(db.Model):
|
2019-10-10 21:57:29 +00:00
|
|
|
__tablename__ = "time_settings"
|
2019-10-02 20:55:09 +00:00
|
|
|
__table_args__ = {'extend_existing': True}
|
2019-10-02 03:42:21 +00:00
|
|
|
|
2019-10-10 21:57:29 +00:00
|
|
|
class TimeTypes(enum.Enum):
|
|
|
|
BYOYOMI = "Counting by time period"
|
|
|
|
ABSOLUTE = "One period to use time"
|
|
|
|
HOURGLASS = "Absolute time for both players"
|
|
|
|
NONE = "Untimed"
|
|
|
|
|
2019-10-02 20:55:09 +00:00
|
|
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
|
|
|
main_time = db.Column(db.Enum(TimeTypes), nullable=False)
|
2019-10-02 03:42:21 +00:00
|
|
|
time_period = db.Column(db.Integer) # number of periods
|
|
|
|
period_length = db.Column(db.Integer) # seconds
|
2019-10-02 20:55:09 +00:00
|
|
|
overtime = db.Column(db.Enum(TimeTypes), nullable=False)
|
2019-10-02 03:42:21 +00:00
|
|
|
overtime_period = db.Column(db.Integer) # number of overtime periods
|
|
|
|
overtime_length = db.Column(db.Integer) # seconds
|
|
|
|
|
|
|
|
|
2019-10-10 21:57:29 +00:00
|
|
|
def __init__(self, main_time=TimeTypes.NONE, overtime=TimeTypes.NONE):
|
|
|
|
self.main_time = main_time
|
|
|
|
self.overtime = overtime
|