-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (22 loc) · 769 Bytes
/
main.py
File metadata and controls
32 lines (22 loc) · 769 Bytes
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
31
32
import json
from typing import Protocol
from tasks import Pulse, Recalibrate, Reinforce
class Task(Protocol):
def run(self) -> None:
...
def main() -> None:
with open("./tasks.json", encoding="utf-8") as file:
data = json.load(file)
tasks: list[Task] = []
for item in data["tasks"]:
if item["type"] == "pulse":
tasks.append(Pulse(item["strength"]))
elif item["type"] == "recalibrate":
tasks.append(Recalibrate(item["target"]))
elif item["type"] == "reinforce":
tasks.append(Reinforce(item["plating_type"], item["target"]))
# run the tasks
for task in tasks:
task.run()
if __name__ == "__main__":
main()