blob: cbabd1e0f61fda8086bec05b6e4c6cc3d18a8842 (
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.MIDDLE
elif string == 'Hard':
return Difficulty.HARD
else:
return None
|