home · contact · privacy
TCE: Add basic crawl eating.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 7 Mar 2016 00:03:57 +0000 (01:03 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 7 Mar 2016 00:03:57 +0000 (01:03 +0100)
confserver/TheCrawlingEater
plugins/server/TheCrawlingEater.py [new file with mode: 0644]

index a9b5e95bcf7dd1b86902cf74352c12d2cb33abad..74ff2312ca495810ca13312ff11eefcb317ae7c3 100644 (file)
@@ -1,9 +1,15 @@
+PLUGIN TheCrawlingEater
+
 MAP_LENGTH 64
 PLAYER_TYPE 0
 
 TA_ID 1
 TA_NAME wait
 
+TA_ID 2
+TA_EFFORT 5
+TA_NAME move
+
 TT_ID 0
 TT_START_NUMBER 1
 TT_LIFEPOINTS 30
diff --git a/plugins/server/TheCrawlingEater.py b/plugins/server/TheCrawlingEater.py
new file mode 100644 (file)
index 0000000..71eb14e
--- /dev/null
@@ -0,0 +1,57 @@
+# This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
+# or any later version. For details on its copyright, license, and warranties,
+# see the file NOTICE in the root directory of the PlomRogue source package.
+
+
+from server.config.world_data import world_db
+
+
+def make_map():
+    from server.make_map import new_pos, is_neighbor
+    from server.utils import rand
+    world_db["MAP"] = bytearray(b'X' * (world_db["MAP_LENGTH"] ** 2))
+    length = world_db["MAP_LENGTH"]
+    add_half_width = (not (length % 2)) * int(length / 2)
+    world_db["MAP"][int((length ** 2) / 2) + add_half_width] = ord("#")
+    while (1):
+        y, x, pos = new_pos()
+        if "X" == chr(world_db["MAP"][pos]) and is_neighbor((y, x), "#"):
+            if y == 0 or y == (length - 1) or x == 0 or x == (length - 1):
+                break
+            world_db["MAP"][pos] = ord("#")
+    n_trees = int((length ** 2) / 16)
+    i_trees = 0
+    while (i_trees <= n_trees):
+        single_allowed = rand.next() % 32
+        y, x, pos = new_pos()
+        if "#" == chr(world_db["MAP"][pos]) \
+                and ((not single_allowed) or is_neighbor((y, x), ".")):
+            world_db["MAP"][pos] = ord(".")
+            i_trees += 1
+
+
+def actor_move_attempts_hook(t, move_result, pos):
+    from server.utils import rand
+    if ord("#") == world_db["MAP"][pos] and 0 == int(rand.next() % 5):
+        world_db["MAP"][pos] = ord(".")
+        return True
+    return False
+
+
+def play_move_attempt_hook(t, direction, pos):
+    if ord("#") == world_db["MAP"][pos]:
+        log("You bite.")
+        world_db["Things"][0]["T_ARGUMENT"] = direction
+        set_command("move")
+        return True
+    return False
+
+
+import server.config.actions
+server.config.actions.actor_move_attempts_hook = actor_move_attempts_hook
+import server.config.commands
+server.config.commands.play_move_attempt_hook = play_move_attempt_hook
+import server.config.world_data
+server.config.world_data.symbols_hide += "#"
+import server.config.make_world_helpers
+server.config.make_world_helpers.make_map = make_map