From c8f535af53bd1478065ee5daf1ff4230fe423249 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 21 Feb 2016 21:53:37 +0100
Subject: [PATCH] Server: Make ai func selectable.

---
 server/commands.py       | 4 ++--
 server/config/actions.py | 4 +++-
 server/world.py          | 5 ++---
 3 files changed, 7 insertions(+), 6 deletions(-)

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"]:
-- 
2.30.2