Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/nutrinoweb/controllers/Avatar.py
diff options
context:
space:
mode:
Diffstat (limited to 'nutrinoweb/controllers/Avatar.py')
-rw-r--r--nutrinoweb/controllers/Avatar.py111
1 files changed, 45 insertions, 66 deletions
diff --git a/nutrinoweb/controllers/Avatar.py b/nutrinoweb/controllers/Avatar.py
index 6dbfebe..3eaab37 100644
--- a/nutrinoweb/controllers/Avatar.py
+++ b/nutrinoweb/controllers/Avatar.py
@@ -1,3 +1,10 @@
+import os
+import json
+
+path_to_this_file = os.path.abspath( __file__ )
+temp_json = os.path.join(os.path.dirname(path_to_this_file), "../../sample/status.json")
+
+
class Character:
def __init__(self):
@@ -26,75 +33,47 @@ class Character:
self.vit_total = 0.0
self.construction = 0.0
-
- def reset(self, gender=None):
- """
- Restore some character properties to its default values.
- """
- pass
+ def load_status(self):
+ fh = open(temp_json,'r')
+ status = json.load(fh)
+ fh.close()
- def load_status(self):
- fobj = open('/Users/stefanienobel/Documents/workspace/nutrinoweb/nutrinoweb/controllers/status.txt')
-
- for line in fobj:
- zuordnung = line.split("|")
- self.water = zuordnung[1]
- self.energie = zuordnung[2]
- self.calcium = zuordnung[3]
- self.iron =zuordnung[4]
- self.magnesium = zuordnung[5]
- self.phosphorus = zuordnung[6]
- self.potassium = zuordnung[7]
- self.sodium = zuordnung[8]
- self.zinc = zuordnung[9]
- self.copper = zuordnung[10]
- self.vit_c = zuordnung[11]
- self.thiamin = zuordnung[12]
- self.riboflavin = zuordnung[13]
- self.niacin =zuordnung[14]
- self.panto_acid = zuordnung[15]
- self.vit_b6 = zuordnung[16]
- self.folate_tot = zuordnung[17]
- self.vit_b12 = zuordnung[18]
- self.vit_a = zuordnung[19]
- self.vit_e = zuordnung[20]
- self.vit_d = zuordnung[21]
- self.vit_total = zuordnung[22]
- self.construction = zuordnung[23]
+ return status
- fobj.close()
+ def save_status(self, status):
+ fh = open(temp_json,'w')
+ json.dump(status,fh)
+ fh.close()
- status = {
- "water": self.water,
- "energie": self.energie,
- "calcium": self.calcium,
- "iron" : self.iron,
- "magnesium": self.magnesium,
- "phosphorus": self.phosphorus,
- "potassium": self.potassium,
- "sodium": self.sodium,
- "zinc": self.zinc,
- "copper": self.copper,
- "vit_c": self.vit_c,
- "thiamin": self.thiamin,
- "riboflavin": self.riboflavin,
- "niacin": self.niacin,
- "panto_acid": self.panto_acid,
- "vit_b6": self.vit_b6,
- "folate_tot": self.folate_tot,
- "vit_b12": self.vit_b12,
- "vit_a": self.vit_a,
- "vit_e": self.vit_e,
- "vit_d": self.vit_d,
- "vit_total": self.vit_total,
- "construction": self.construction
- }
- return status
+ def reset_status(self):
+ status = {
+ "water": 0,
+ "energie": 0,
+ "calcium": 0,
+ "iron" : 0,
+ "magnesium": 0,
+ "phosphorus": 0,
+ "potassium": 0,
+ "sodium": 0,
+ "zinc": 0,
+ "copper": 0,
+ "vit_c": 0,
+ "thiamin": 0,
+ "riboflavin": 0,
+ "niacin": 0,
+ "panto_acid": 0,
+ "vit_b6": 0,
+ "folate_tot": 0,
+ "vit_b12": 0,
+ "vit_a": 0,
+ "vit_e": 0,
+ "vit_d": 0,
+ "vit_total": 0,
+ "construction": 0
+ }
+ fh = open(temp_json,'w')
+ json.dump(status,fh)
+ fh.close()
- def save_status(self, water, energie, calcium, iron, magnesium, phosphorus, potassium, sodium, zinc, copper, vit_c, thiamin, riboflavin, niacin, panto_acid, vit_b6, folate_tot, vit_b12, vit_a, vit_e, vit_d, vit_total, construction):
- fobj = open('/Users/stefanienobel/Documents/workspace/nutrinoweb/nutrinoweb/controllers/status.txt', 'w')
- fobj.truncate()
- fobj.write('|' + water + '|' + energie + '|' + calcium + '|' + iron + '|' + magnesium + '|' + phosphorus + '|' + potassium + '|' + sodium + '|' + zinc + '|' + copper + '|' + vit_c + '|' + thiamin + '|' + riboflavin + '|' + niacin + '|' + panto_acid + '|' + vit_b6 + '|' + folate_tot + '|' + vit_b12 + '|' + vit_a + '|' + vit_e + '|' + vit_d + '|' + vit_total + '|' + construction)
- fobj.close()