aboutsummaryrefslogtreecommitdiff
path: root/todo/model/difficulty.py
diff options
context:
space:
mode:
Diffstat (limited to 'todo/model/difficulty.py')
-rw-r--r--todo/model/difficulty.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/todo/model/difficulty.py b/todo/model/difficulty.py
new file mode 100644
index 0000000..526cdb9
--- /dev/null
+++ b/todo/model/difficulty.py
@@ -0,0 +1,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