Power Grid Board Game Timer. Acts like a chess timer for 3-6 people. Uses an ADXL accelerometer to pause the timer and change players. Uses an LCD screen to prompt the players for input, read that input, and change between rounds.

Dependencies:   DmTouch_UniGraphic UniGraphic-forLdelaney17FinalProject mbed

Revision:
3:22c644f16365
Parent:
2:e6788e73de54
Child:
4:e14c199c2466
--- a/game.cpp	Wed Jan 25 06:50:57 2017 +0000
+++ b/game.cpp	Wed Jan 25 07:08:48 2017 +0000
@@ -2,7 +2,7 @@
 
 void game_setup(){
     init_num_players();
-    //set_player_order();
+    set_player_order();
 }
 
 void init_num_players(){
@@ -29,5 +29,37 @@
     }
 }
 
-//myLCD.fillrect(160,130,200,240,Blue);
+//blocking wait function
+void set_player_order(){
+    player_order.clear();
+    for (int i = 0; i <  num_players; i++){
+        prompt(num_players, "select the player number with the most cities. \r\nIn case of a tie, the higher numbered power \r\nplant goes first\r\n");   
+        while (waiting_for_touch){
+           wait(0.05); //blocking busy wait 
+        }
+        player_order.push_back(prompt_input_val);
+    }
+    //TODO: if has duplicates, display message "invalid turn order" and call set_player_order
+      
+    stringstream ss;
+    ss << "press 1 to confirm that player order is correct. \r\nPress 2 to change";
+    ss << "\r\nPlayer Order:\t";
+    for (int i = 0; i < num_players; i++){
+        ss << player_order[i] << "\t";   
+    }
+    prompt(2, ss.str());
+    while(waiting_for_touch == true){ //until a valid input is read
+        wait(0.1); // can busy wait during setup    
+    }
+    int choice = prompt_input_val;
+    switch(choice){
+        case 1:
+        return;
+        break;
+        case 2:
+        set_player_order();
+        return;
+        break;
+    }
+}