Last active
August 29, 2015 14:01
-
-
Save apgordon/826a892a76924f066064 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| player = [] | |
| i = 0 | |
| until i == 1 | |
| print "Player? " | |
| p = gets.chomp.capitalize | |
| #puts "OK, #{0 - i} players left to enter." | |
| player.push(p) | |
| print "Players entered so far: #{player} \n \n" | |
| i += 1 | |
| end | |
| location = ["Square 0", "Square 1", "Square 2", "Square 3"] | |
| player_location = [0,0,0] | |
| x = 0 | |
| until x == 3 | |
| puts "#{player[0]} is in #{location[player_location[0]]}" | |
| puts "#{player_location[0]}" | |
| print "Move forward <1>, move backward <2>, or quit <3>. " | |
| x = gets.chomp | |
| if x.to_i == 1 | |
| puts "Move forward." | |
| player_location[0] += 1 | |
| if player_location[0] > 3 | |
| puts "No more squares this way; try going backward." | |
| player_location[0] = 3 | |
| end | |
| elsif x.to_i ==2 | |
| puts "Move backward." | |
| player_location[0] -= 1 | |
| if player_location[0] < 0 | |
| puts "No more squares this way; try going forward." | |
| player_location[0] = 0 | |
| end | |
| elsif x.to_i == 3 | |
| break | |
| else puts "You entered '#{x},' which isn't valid. Enter 1, 2, or 3. \n" | |
| end | |
| end | |
| puts "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment