-
Notifications
You must be signed in to change notification settings - Fork 0
/
miscellaneous.rb
76 lines (68 loc) · 1.47 KB
/
miscellaneous.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
74
75
76
# Here I stored some short but also necessary functions,
# including dead_ball, change_ball, rebound_decide, who_did_it, timeout, steal
# and turnover.
def dead_ball
puts "(time/sub/no)?"
ans = gets.chomp
if ans == "time"
timeout
elsif ans == "sub"
substitution
end
end
def change_ball
$whose_ball == true ? false : true
show
end
def rebound_decide(ans)
if ans == "h" && $whose_ball == false
change_ball
elsif ans == "a" && $whose_ball == true
change_ball
else
show
end
end
def who_did_it
puts "who did it?"
$num = gets.chomp
end
def show
puts $whose_ball ? "Home's ball now." : "Away's ball now."
end
def timeout
puts "Which team called a timeout? (home/away/tv)"
team = gets.chomp
puts "#{team} timeout."
end
def steal
who_did_it
puts $whose_ball ? "[Away] number #{num} steal the ball. Away's ball." \
: "[Home] number #{num} steal the ball. Home's ball."
change_ball
end
def turnover
puts "Which kind of turnover? (out/jumpball)"
type = gets.chomp
case type
when "out"
puts "Whose ball? (h/a)"
ans = gets.chomp
rebound_decide(ans)
when "jumpball"
puts "Jumpball."
if $ball_right == true && $whose_ball == true
show
$ball_right = false
elsif $ball_right == false && $whose_ball == true
change_ball
$ball_right = true
elsif $ball_right == true && $whose_ball == false
change_ball
$ball_right = false
else
show
$ball_right = true
end
end
end