diff options
Diffstat (limited to 'src/model/difficulty.py')
-rw-r--r-- | src/model/difficulty.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/model/difficulty.py b/src/model/difficulty.py new file mode 100644 index 0000000..595f844 --- /dev/null +++ b/src/model/difficulty.py @@ -0,0 +1,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 |