From e66fb136c8fd10fe8bafb273c938a3d332d997ba Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Sun, 1 Sep 2024 00:27:54 +0200 Subject: setting tasks for ships --- modules/ships.py | 8 ++++---- modules/task_type.py | 10 ++++++++++ modules/tasks.py | 5 ----- 3 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 modules/task_type.py delete mode 100644 modules/tasks.py (limited to 'modules') diff --git a/modules/ships.py b/modules/ships.py index 0a296ca..8dfe41a 100644 --- a/modules/ships.py +++ b/modules/ships.py @@ -1,4 +1,4 @@ -from . import tasks +from . import task_type from .database import cursor, conn @@ -13,15 +13,15 @@ class Ship: cursor.execute("SELECT task, params FROM ships WHERE symbol = ?", (self.symbol,)) row = cursor.fetchone() if row is None: - cursor.execute("INSERT INTO ships (symbol, task, params) VALUES (?, ?, ?)", (self.symbol, tasks.IDLE, None)) + cursor.execute("INSERT INTO ships (symbol, task, params) VALUES (?, ?, ?)", (self.symbol, task_type.IDLE, None)) conn.commit() - self.task = tasks.IDLE + self.task = task_type.IDLE else: self.task = row[0] def set_task(self, task): self.task = task - if task != tasks.ERROR: + if task != task_type.ERROR: cursor.execute("UPDATE ships SET task = ? WHERE symbol = ?", (task, self.symbol)) conn.commit() diff --git a/modules/task_type.py b/modules/task_type.py new file mode 100644 index 0000000..7579ad0 --- /dev/null +++ b/modules/task_type.py @@ -0,0 +1,10 @@ +IDLE = 'IDLE' +MINING = 'MINING' + +MIA = 'MIA' +ERROR = 'ERROR' + +task_types = [ + IDLE, + MINING, +] diff --git a/modules/tasks.py b/modules/tasks.py deleted file mode 100644 index 8479134..0000000 --- a/modules/tasks.py +++ /dev/null @@ -1,5 +0,0 @@ -IDLE = 'IDLE' -MINING = 'MINING' - -MIA = 'MIA' -ERROR = 'ERROR' -- cgit v1.2.3-70-g09d2