From ca11ff515801cdbc5194024514b0a861d8886334 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Fri, 17 May 2013 01:48:07 +0200
Subject: [PATCH] Starting to move all multi-line actions in key command loop
 into their own functions. Starting with wait action.

---
 roguelike.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/roguelike.c b/roguelike.c
index 8a358f3..c22cc48 100644
--- a/roguelike.c
+++ b/roguelike.c
@@ -53,6 +53,7 @@ int get_action_key (struct KeyBinding *, char *);
 char * get_keyname(int);
 char is_passable (struct World *, int, int);
 void move_player (struct World *, char);
+void player_wait(struct World *);
 
 void draw_with_linebreaks (struct Win * win, char * text, int start_y) {
 // Write text into window content space. Start on row start_y. Fill unused rows with whitespace.
@@ -395,6 +396,11 @@ void move_player (struct World * world, char d) {
   prev = success * d;
   next_turn (world); }
 
+void player_wait(struct World * world) {
+// Make player wait one turn.
+  next_turn (world);
+  update_log (world, "\nYou wait."); }
+
 int main () {
   struct World world;
   init_keybindings(&world);
@@ -495,9 +501,8 @@ int main () {
       move_player(&world, 'e');
     else if (key == get_action_key(world.keybindings, "player left"))
       move_player(&world, 'w');
-    else if (key == get_action_key(world.keybindings, "wait") ) {
-      next_turn (&world);
-      update_log (&world, "\nYou wait."); } }
+    else if (key == get_action_key(world.keybindings, "wait") )
+      player_wait (&world); }
 
   free(map.cells);
   for (key = 0; key <= world.keyswindata->max; key++)
-- 
2.30.2