Created
April 22, 2018 15:25
-
-
Save alexonozor/1679f9d9f0d6243cee440e25ad833980 to your computer and use it in GitHub Desktop.
Code snippet from my ruby hangman gem.
This file contains 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
def menu | |
option_choice = get_input('') | |
case option_choice | |
when "1" | |
menu_start_game | |
when "2" | |
load | |
when "3" | |
menu_instruction | |
when "4", "X", "x", "Q", "q", :quit | |
@display.conclusion | |
else | |
menu_invalid_entry | |
end | |
end | |
def menu_start_game | |
@status = :game_started | |
game_method | |
end | |
def menu_instruction | |
send_message(@display.instruction) | |
start_menu | |
end | |
def menu_invalid_entry | |
send_message "Invalid entry, retry" | |
sleep 1 | |
menu | |
end | |
def game_method | |
until @model.game_complete | |
select = get_input(@display.game_warning).downcase | |
break if this_is_a_control_method(select) | |
break if this_is_the_complete_secret(select) | |
check_selection(select) | |
end | |
you_have_exhausted_all_your_chances if @model.chances == 0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment