From: Christian Heller Date: Sun, 3 Aug 2014 03:49:23 +0000 (+0200) Subject: Add command to let the AI decide player's next move. X-Git-Tag: tce~672 X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/%7B%7Bdb.prefix%7D%7D/conditions?a=commitdiff_plain;h=c8841380b53dbd999061a8de399e71d5d8272fb0;p=plomrogue Add command to let the AI decide player's next move. --- diff --git a/SERVER_COMMANDS b/SERVER_COMMANDS index e31d331..50ac853 100644 --- a/SERVER_COMMANDS +++ b/SERVER_COMMANDS @@ -54,6 +54,9 @@ Shut down server. Player commands --------------- +ai +Do what the AI would do. + wait Make player character wait one turn. diff --git a/confclient/commands b/confclient/commands index e4efa8a..c5f94d1 100644 --- a/confclient/commands +++ b/confclient/commands @@ -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 diff --git a/confclient/interface_conf b/confclient/interface_conf index 8a4a36f..9b97af3 100644 --- a/confclient/interface_conf +++ b/confclient/interface_conf @@ -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 diff --git a/confclient/single_wins/info b/confclient/single_wins/info index 80343ef..636f5fa 100644 --- a/confclient/single_wins/info +++ b/confclient/single_wins/info @@ -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 diff --git a/confclient/single_wins/inventory b/confclient/single_wins/inventory index c9e8930..c664b3e 100644 --- a/confclient/single_wins/inventory +++ b/confclient/single_wins/inventory @@ -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 diff --git a/confclient/single_wins/log b/confclient/single_wins/log index 9944687..be5408c 100644 --- a/confclient/single_wins/log +++ b/confclient/single_wins/log @@ -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 diff --git a/confclient/single_wins/map b/confclient/single_wins/map index d3a48bb..e9283d9 100644 --- a/confclient/single_wins/map +++ b/confclient/single_wins/map @@ -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 diff --git a/src/server/hardcoded_strings.c b/src/server/hardcoded_strings.c index 4e801cf..82f7a3e 100644 --- a/src/server/hardcoded_strings.c +++ b/src/server/hardcoded_strings.c @@ -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"; diff --git a/src/server/hardcoded_strings.h b/src/server/hardcoded_strings.h index 3c8dd81..ebfa079 100644 --- a/src/server/hardcoded_strings.h +++ b/src/server/hardcoded_strings.h @@ -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]; diff --git a/src/server/run.c b/src/server/run.c index 3ae7175..8c1297d 100644 --- a/src/server/run.c +++ b/src/server/run.c @@ -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;