summaryrefslogtreecommitdiff
path: root/hercules/code/configutils.py
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-04-10 00:45:07 -0300
committerJesusaves <cpntb1@ymail.com>2021-04-10 00:45:07 -0300
commitc6095ad062eaa0f5576cfab1c4fe436b90c2fbfe (patch)
tree742dd839971d2aab1f08fd0291af66e6439646ab /hercules/code/configutils.py
downloadtools-c6095ad062eaa0f5576cfab1c4fe436b90c2fbfe.tar.gz
tools-c6095ad062eaa0f5576cfab1c4fe436b90c2fbfe.tar.bz2
tools-c6095ad062eaa0f5576cfab1c4fe436b90c2fbfe.tar.xz
tools-c6095ad062eaa0f5576cfab1c4fe436b90c2fbfe.zip
Add initial tools
Diffstat (limited to 'hercules/code/configutils.py')
-rw-r--r--hercules/code/configutils.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/hercules/code/configutils.py b/hercules/code/configutils.py
new file mode 100644
index 0000000..6d9ddb2
--- /dev/null
+++ b/hercules/code/configutils.py
@@ -0,0 +1,51 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2014 Evol Online
+# Author: Andrei Karas (4144)
+
+def writeIntField(w, name, value):
+ if value == "":
+ value = "0"
+ w.write(" {0}: {1}\n".format(name, value))
+
+def writeIntField2(w, name, value):
+ if value == "":
+ value = "0"
+ w.write(" {0}: {1}\n".format(name, value))
+
+def writeStrField(w, name, value):
+ w.write(" {0}: \"{1}\"\n".format(name, value))
+
+def writeCondField2(w, cond, name):
+ if cond != 0:
+ w.write(" {0}: true\n".format(name))
+
+def writeSubField(w, name, value):
+ w.write(" {0}: {1}\n".format(name, value))
+
+def writeFieldArr(w, name, value, value2):
+ w.write(" {0}: [{1}, {2}]\n".format(name, value, value2))
+
+def writeFieldList(w, name, value, value2):
+ w.write(" {0}: ({1}, {2})\n".format(name, value, value2))
+
+def writeStartBlock(w, text):
+ w.write(" {0}: {{\n".format(text))
+
+def writeEndBlock(w):
+ w.write(" }\n")
+
+def writeStartScript(w, name):
+ w.write(" {0}: <\"\n".format(name))
+
+def writeEndScript(w):
+ w.write(" \">\n")
+
+def isHaveData(fields, start, cnt):
+ for f in range(0, cnt):
+ value = fields[start + f * 2]
+ chance = fields[start + f * 2]
+ if value == "" or value == "0" or chance == "" or chance == "0":
+ continue
+ return True
+ return False