From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 21 Feb 2016 20:53:37 +0000 (+0100)
Subject: Server: Make ai func selectable.
X-Git-Tag: tce~190
X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/static/%7B%7Bprefix%7D%7D/ledger2?a=commitdiff_plain;h=c8f535af53bd1478065ee5daf1ff4230fe423249;p=plomrogue

Server: Make ai func selectable.
---

diff --git a/server/commands.py b/server/commands.py
index 975e1bd..9a10337 100644
--- a/server/commands.py
+++ b/server/commands.py
@@ -507,6 +507,6 @@ def play_move(str_arg):
 
 def command_ai():
     """Call ai() on player Thing, then turn_over()."""
-    from server.ai import ai
-    ai(world_db["Things"][0])
+    from server.config.actions import ai_func
+    ai_func(world_db["Things"][0])
     turn_over()
diff --git a/server/config/actions.py b/server/config/actions.py
index 3e10f32..66be0e2 100644
--- a/server/config/actions.py
+++ b/server/config/actions.py
@@ -5,7 +5,6 @@
 
 from server.actions import actor_wait, actor_move, actor_pickup, actor_drop, \
     actor_use
-
 action_db = {
     "actor_wait": actor_wait,
     "actor_move": actor_move,
@@ -13,3 +12,6 @@ action_db = {
     "actor_drop": actor_drop,
     "actor_use": actor_use
 }
+
+from server.ai import ai
+ai_func = ai
diff --git a/server/world.py b/server/world.py
index 7940f70..9bd9f6d 100644
--- a/server/world.py
+++ b/server/world.py
@@ -309,8 +309,7 @@ def make_world(seed):
 
 def turn_over():
     """Run game world and its inhabitants until new player input expected."""
-    from server.config.actions import action_db
-    from server.ai import ai
+    from server.config.actions import action_db, ai_func
     id = 0
     whilebreaker = False
     while world_db["Things"][0]["T_LIFEPOINTS"]:
@@ -331,7 +330,7 @@ def turn_over():
                     if 0 == id:
                         whilebreaker = True
                         break
-                    ai(Thing)
+                    ai_func(Thing)
                 try_healing(Thing)
                 hunger(Thing)
                 if Thing["T_LIFEPOINTS"]: