home · contact · privacy
TCE: Refactor eating.
[plomrogue] / plugins / server / TheCrawlingEater.py
index 1c7a76dace33613d51a2e1c3349de1e9ae508c14..cf6f204d8933505190f4e6b0121c67a13ed3fc51 100644 (file)
@@ -129,14 +129,15 @@ def actor_move(t):
         t["pos"] = move_result[1] * world_db["MAP_LENGTH"] + move_result[2]
         build_fov_map(t)
     else:
-        if t["T_BOWEL"] >= 32 or chr(world_db["MAP"][pos]) == "5":
+        height = world_db["MAP"][pos] - ord("0")
+        if t["T_BOWEL"] >= 32 or height == 5:
             return
         eaten = False
-        if chr(world_db["MAP"][pos]) == "3" and 0 == int(rand.next() % 2):
-            t["T_BOWEL"] += 3
+        if height == 3 and 0 == int(rand.next() % 2):
+            t["T_BOWEL"] += height
             eaten = True
-        elif chr(world_db["MAP"][pos]) == "4" and 0 == int(rand.next() % 5):
-            t["T_BOWEL"] += 4
+        elif height == 4 and 0 == int(rand.next() % 5):
+            t["T_BOWEL"] += height
             eaten = True
         log("You EAT.")
         if eaten:
@@ -197,11 +198,8 @@ def calc_effort(ta, t):
                                          t["T_POSY"], t["T_POSX"])
         if 1 == move_result[0]:
             pos = (move_result[1] * world_db["MAP_LENGTH"]) + move_result[2]
-            terrain = chr(world_db["MAP"][pos])
-            if terrain == "1":
-                return 2
-            elif terrain == "2":
-                return 4
+            narrowness = world_db["MAP"][pos] - ord("0")
+            return 2 ** narrowness
     return 1
 world_db["calc_effort"] = calc_effort