summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-02-14 15:56:05 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-02-14 17:38:09 +0100
commite7c1f8b74f92778f16721a6ad358f4f248f2a9f6 (patch)
tree58d2d98b4ed38e5204ae54409357eee8ec576fd0 /ishtar_common/utils.py
parentaef3dfa74b0e2a0a7563d4798ebcf6b0f9998b02 (diff)
downloadIshtar-e7c1f8b74f92778f16721a6ad358f4f248f2a9f6.tar.bz2
Ishtar-e7c1f8b74f92778f16721a6ad358f4f248f2a9f6.zip
🐛 fix VALUES serialization for preventive archaeological files
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index 95a7ebbaa..e69ef0290 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -112,10 +112,31 @@ class InlineClass:
"""
Dynamic class used in templates
"""
+
def __init__(self, dct):
for k in dct:
setattr(self, k, dct[k])
+ def toJSON(self):
+ return json.dumps(
+ self,
+ default=lambda o: o.__dict__,
+ sort_keys=True,
+ indent=4
+ )
+
+
+def json_used_equipments(value):
+ res = []
+ for gp in value:
+ res.append(gp[:4] + [cost.toJSON() for cost in gp[-1]])
+ return res
+
+
+JSON_SERIALIZATION = {
+ "used_equipments": json_used_equipments
+}
+
def fake_task(*args):
def fake(func):