aboutsummaryrefslogtreecommitdiff
path: root/src/model/difficulty.py
blob: 595f844d007076e46489ea0ed15dc62172fb89bb (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):
    LOW = 0
    MEDIUM = 1
    HIGH = 2

values = [
    Difficulty.LOW,
    Difficulty.MEDIUM,
    Difficulty.HIGH]

def format(difficulty: Difficulty) -> str:
    if difficulty == Difficulty.LOW:
        return 'Low'
    elif difficulty == Difficulty.MEDIUM:
        return 'Medium'
    elif difficulty == Difficulty.HIGH:
        return 'High'

def parse(string: str) -> Optional[Difficulty]:
    if string == 'Low':
        return Difficulty.LOW
    elif string == 'Medium':
        return Difficulty.MEDIUM
    elif string == 'High':
        return Difficulty.HIGH
    else:
        return None