forked from rhonaCA/6Nimmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rb
73 lines (70 loc) · 2 KB
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require 'json'
require 'csv'
require 'tty-prompt'
require 'tty-box'
require 'rainbow'
require 'artii'
require_relative 'classes/game_setup'
require_relative 'classes/errors'
require_relative 'helpers/methods'
begin
cli = ARGV[0].downcase
name = ARGV[1]
if name.to_s.empty? == true
raise WrongInputError
elsif name.index( /[^[:alnum:]]/ ) != nil
raise WrongInputError
end
rescue WrongInputError
puts ' '
puts Rainbow('Sorry, name can only contains letters and numbers. Please try again!').tomato.bright
puts ' '
exit
rescue
puts ' '
puts Rainbow('Sorry, something went wrong. Please try again!').tomato.bright
puts ' '
exit
end
loop do
case cli
when 'start'
system 'clear'
puts ' '
a = Artii::Base.new :font => 'big'
puts Rainbow(a.asciify('Welcome to 6 Nimmt !')).lightskyblue.bright
puts ' '
ans = prompt_input({ 'Start the game': 1, 'Check out the rules first': 2, 'Checkout scoreboard': 4, 'Exit game': 3 }, 'Shall we start?')
game_round(ans, name)
when 'rules'
show_rules_page
ans = prompt_input({ 'Yes I am ready!': 1, 'Check out the rules again': 2, 'Exit game': 3}, 'Ready to play the game?')
game_round(ans, name)
system 'clear'
when 'scoreboard'
system 'clear'
show_score_board()
puts ' '
ans = prompt_input({ 'Yes I am ready!': 1, 'Check out the rules first': 2, 'Exit game': 3 }, 'Ready to play the game?')
game_round(ans, name)
else
puts 'Wrong option, do you want to try it again? (Y/N)'
try_again = STDIN.gets.chomp.downcase
begin
if try_again == 'y'
puts "What would you like to do? 'Start' to start the game, 'Rules' to checkout the rules, 'Scoreboard' to checkout the scoreboard. Easy! "
cli = STDIN.gets.chomp.downcase
elsif try_again == 'n'
raise WrongOptionError
else
puts 'Wrong option, do you want to try it again? (Y/N)'
try_again = STDIN.gets.chomp.downcase
end
rescue WrongOptionError
puts ' '
puts Rainbow('Byebye, hope I will see you again!').tomato.bright
puts ' '
exit
end
end
end