home · contact · privacy
Server/py: Undummify actor_use.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 4 Mar 2015 14:00:04 +0000 (15:00 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 4 Mar 2015 14:00:04 +0000 (15:00 +0100)
plomrogue-server.py

index e763a3dd292590c375f5f09be6dbcdd378bd5e56..fc0a82a853066c5006e4e304a2ec3dcc2064c125 100755 (executable)
@@ -491,7 +491,23 @@ def actor_drop(t):
 
 
 def actor_use(t):
-    pass
+    """Make t use (for now: consume) T_ARGUMENT-indexed Thing in inventory."""
+    # Original wrongly featured lifepoints increase through consumable!
+    # TODO: Handle case where T_ARGUMENT matches nothing.
+    if len(t["T_CARRIES"]):
+        id = t["T_CARRIES"][t["T_ARGUMENT"]]
+        type = world_db["Things"][id]["T_TYPE"]
+        if world_db["ThingTypes"][type]["TT_CONSUMABLE"]:
+            t["T_CARRIES"].remove(id)
+            del world_db["Things"][id]
+            t["T_SATIATION"] += world_db["ThingTypes"][type]["TT_CONSUMABLE"]
+            strong_write(io_db["file_out"], "LOG You consume this object.\n")
+        else:
+            strong_write(io_db["file_out"], "LOG You try to use this " + \
+                                            "object, but fail.\n")
+    else:
+        strong_write(io_db["file_out"], "LOG You try to use an object, " + \
+                                        "but you own none.\n")
 
 
 def turn_over():