aboutsummaryrefslogtreecommitdiff
path: root/todo/model/difficulty.py
blob: 526cdb96b6569d4b8c9425aa17b008ce1c73b140 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from enum import IntEnum
from typing import Optional

class Difficulty(IntEnum):
    EASY = 0
    NORMAL = 1
    HARD = 2

values = [
    Difficulty.EASY,
    Difficulty.NORMAL,
    Difficulty.HARD]

def format(difficulty: Difficulty) -> str:
    if difficulty == Difficulty.EASY:
        return "Easy"
    elif difficulty == Difficulty.NORMAL:
        return "Normal"
    elif difficulty == Difficulty.HARD:
        return "Hard"

def parse(string: str) -> Optional[Difficulty]:
    if string == "Easy":
        return Difficulty.EASY
    elif string == "Normal":
        return Difficulty.NORMAL
    elif string == "Hard":
        return Difficulty.HARD
    else:
        return None