home · contact · privacy
Add command to let the AI decide player's next move.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 3 Aug 2014 03:49:23 +0000 (05:49 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 3 Aug 2014 03:49:23 +0000 (05:49 +0200)
SERVER_COMMANDS
confclient/commands
confclient/interface_conf
confclient/single_wins/info
confclient/single_wins/inventory
confclient/single_wins/log
confclient/single_wins/map
src/server/hardcoded_strings.c
src/server/hardcoded_strings.h
src/server/run.c

index e31d3312e81fcc6cfc410b5ce5a0de662b90c8c8..50ac853fe343e84a065304e021a9c85c6e950064 100644 (file)
@@ -54,6 +54,9 @@ Shut down server.
 Player commands
 ---------------
 
+ai
+Do what the AI would do.
+
 wait
 Make player character wait one turn.
 
index e4efa8a4b832a681f2a3cd1229a748c8d074b31e..c5f94d12fe4dda75a483c801b02b51b0c5e4fad3 100644 (file)
@@ -1,3 +1,8 @@
+COMMAND ai
+DESCRIPTION 'let AI decide move'
+SERVER_COMMAND ai
+SERVER_ARGUMENT 0
+
 COMMAND wait
 DESCRIPTION 'wait / next turn'
 SERVER_COMMAND wait
index 8a4a36fd910339937311035872a2dcb295f2af55..9b97af383113cad2bc13ad6bef1aedf8e8f7afcc 100644 (file)
@@ -87,6 +87,7 @@ NAME 'Map'
 BREAK 0
 WIDTH -42
 HEIGHT 0
+KEY 97 ai
 KEY 112 pick
 KEY 58 wait
 KEY 101 move_e
index 80343ef125e7345a7cd30eb46f7d8acc6cfc632b..636f5fa9abbb615e0c60627a7e3371e51cfadc8c 100644 (file)
@@ -15,6 +15,7 @@ KEY 262 scrl_l
 KEY 360 scrl_r
 KEY 82 reload_conf
 KEY 67 save_conf
+KEY 97 ai
 KEY 112 pick
 KEY 58 wait
 KEY 101 move_e
index c9e893093226adc2532e6d1f8ce6ba374c583b49..c664b3e5cdc0314b915e3e476edafed8abd99367 100644 (file)
@@ -15,6 +15,7 @@ KEY 262 scrl_l
 KEY 360 scrl_r
 KEY 82 reload_conf
 KEY 67 save_conf
+KEY 97 ai
 KEY 112 pick
 KEY 58 wait
 KEY 101 move_e
index 9944687a2a9846e272c60bafc59692733ac96250..be5408c0efd9aa1b731a69524b3b657ada694444 100644 (file)
@@ -15,6 +15,7 @@ KEY 262 scrl_l
 KEY 360 scrl_r
 KEY 82 reload_conf
 KEY 67 save_conf
+KEY 97 ai
 KEY 112 pick
 KEY 58 wait
 KEY 101 move_e
index d3a48bbdd94d2b04700e2ce0fa9071b293ab80d5..e9283d9b2964efc1c141bbd2721e3564919d4ffb 100644 (file)
@@ -15,6 +15,7 @@ KEY 262 scrl_l
 KEY 360 scrl_r
 KEY 82 reload_conf
 KEY 67 save_conf
+KEY 97 ai
 KEY 112 pick
 KEY 58 wait
 KEY 101 move_e
index 4e801cfb3476646fd6125a948697e39b0e669dda..82f7a3ebf462dde84a1d96e02ac8f8099f763925 100644 (file)
@@ -4,7 +4,7 @@
 
 
 
-char * s[39];
+char * s[40];
 
 
 
@@ -37,6 +37,7 @@ extern void init_strings()
     s[S_CMD_T_HP] = "T_LIFEPOINTS";
     s[S_CMD_T_CARRIES] = "T_CARRIES";
     s[S_CMD_T_MEMMAP] = "T_MEMMAP";
+    s[S_CMD_AI] = "ai";
     s[S_CMD_WAIT] = "wait";
     s[S_CMD_MOVE] = "move";
     s[S_CMD_PICKUP] = "pick_up";
index 3c8dd8161d96c742974d186e3bd5a4dfbf05a06c..ebfa0799528dc2dad2767afad7bf178e8bf1b4f3 100644 (file)
@@ -37,6 +37,7 @@ enum string_num
     S_CMD_T_HP,
     S_CMD_T_CARRIES,
     S_CMD_T_MEMMAP,
+    S_CMD_AI,
     S_CMD_WAIT,
     S_CMD_MOVE,
     S_CMD_PICKUP,
@@ -53,7 +54,7 @@ enum string_num
 
 extern void init_strings();
 
-extern char * s[39];
+extern char * s[40];
 
 
 
index 3ae71757fe6ec0568a3bc6f937608846a129db4e..8c1297d1da1172a51a802578c5d01c5ce99f016a 100644 (file)
@@ -86,12 +86,20 @@ static uint8_t player_commands_allowed()
 static uint8_t parse_player_command_0arg(char * tok0)
 {
     struct Thing * player = get_player();
-    if (!strcmp(tok0, s[S_CMD_WAIT]) || !strcmp(tok0, s[S_CMD_PICKUP]))
+    if (   !strcmp(tok0, s[S_CMD_WAIT]) || !strcmp(tok0, s[S_CMD_PICKUP])
+        || !strcmp(tok0, s[S_CMD_AI]))
     {
         if (player_commands_allowed())
         {
-            player->command = get_thing_action_id_by_name(tok0);
-            player->arg = 0;
+            if (!strcmp(tok0, s[S_CMD_AI]))
+            {
+                ai(player);
+            }
+            else
+            {
+                player->command = get_thing_action_id_by_name(tok0);
+                player->arg = 0;
+            }
             turn_over();
         }
         return 1;