hlockey 0.1 → 1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/hlockey +41 -33
- data/lib/data/divisions.yaml +845 -0
- data/lib/data/season.rb +27 -0
- data/lib/game.rb +35 -28
- data/lib/league.rb +68 -58
- data/lib/messages.rb +25 -25
- metadata +5 -6
- data/lib/data/names_markov_chain.rb +0 -634
- data/lib/player.rb +0 -41
- data/lib/team.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46e23c61853872982a0e27a07eebb63950fe51fdd283872b365b9c77b665a976
|
4
|
+
data.tar.gz: 9ea49d62dbb908058043fe58b8f88afb0eaeaed5d34c325e2764a4f0a311d94a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c9ec44ba9c7319fdb2b5a7bdc4d13892e07b712c418f268b04d1b1a5d43e4079af6439924dd0095ca71c8e223f07c17e1e107bd29a5b2b0f207d2cebae2b95c
|
7
|
+
data.tar.gz: fe658fc39c7825f4c9015e4b20772914f251bc84e04d0b723a1384a5d4b27f9611840c1b3657ebd8845c42ecdf0661f74f374f4748f20f90a85db2ccb5a4d902
|
data/bin/hlockey
CHANGED
@@ -1,82 +1,90 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
puts
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require_relative('../lib/league')
|
6
|
+
require_relative('../lib/data/season')
|
7
|
+
|
8
|
+
def menu_input(default, *choices)
|
9
|
+
puts('Please enter a number...')
|
10
|
+
# Adding 1 to i when printing choices
|
11
|
+
# to avoid confusing a non-numerical input with the first choice
|
12
|
+
choices.each_with_index { |choice, i| puts("#{(i + 1).to_s.rjust(2)} - #{choice}") }
|
13
|
+
puts("anything else - #{default}")
|
13
14
|
|
14
15
|
# Subtract 1 here to undo adding 1 earlier
|
15
16
|
gets.to_i - 1
|
16
17
|
end
|
17
18
|
|
18
19
|
# Each element from choices should implement to_s
|
19
|
-
def menu_input_elem
|
20
|
-
i = menu_input
|
21
|
-
choices[i] unless i
|
20
|
+
def menu_input_elem(default, choices)
|
21
|
+
i = menu_input(default, *choices)
|
22
|
+
choices[i] unless i.negative?
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
league = League.new season, start_time
|
25
|
+
PUTS = method(:puts)
|
26
|
+
league = League.new(Season::NUMBER, Season::START_TIME)
|
27
27
|
|
28
|
-
if Time.now <
|
29
|
-
puts
|
28
|
+
if Time.now < Season::START_TIME
|
29
|
+
puts Season::START_TIME
|
30
|
+
.strftime("Season #{Season::NUMBER} starts at %H:%M on %A, %B %d.")
|
30
31
|
end
|
31
32
|
|
32
33
|
loop do
|
33
34
|
league.update_state
|
34
35
|
|
35
|
-
puts
|
36
|
+
puts("Season #{Season::NUMBER} day #{league.day}")
|
36
37
|
|
37
|
-
case menu_input
|
38
|
+
case menu_input('Exit', 'Games', 'Standings', 'Rosters', 'Election')
|
38
39
|
when 0 # Games
|
39
40
|
if league.games_in_progress.empty?
|
40
|
-
puts
|
41
|
+
puts('There are currently no games being played.')
|
41
42
|
next
|
42
43
|
end
|
43
44
|
|
44
|
-
game = menu_input_elem
|
45
|
+
game = menu_input_elem('Back', league.games_in_progress)
|
45
46
|
next if game.nil?
|
46
47
|
|
47
48
|
loop do
|
48
49
|
league.update_state
|
49
50
|
|
50
|
-
game.stream.each
|
51
|
+
game.stream.each(&PUTS)
|
51
52
|
|
52
53
|
break unless game.in_progress
|
53
54
|
|
54
55
|
game.stream.clear
|
55
|
-
sleep
|
56
|
+
sleep(5)
|
56
57
|
end
|
57
58
|
when 1 # Standings
|
58
59
|
if league.champion_team
|
59
|
-
puts
|
60
|
+
puts("Your season #{Season::NUMBER} champions are the "\
|
61
|
+
"#{league.champion_team.name}!")
|
60
62
|
elsif league.playoff_teams
|
61
|
-
puts
|
62
|
-
league.playoff_teams.each
|
63
|
+
puts('Playoffs')
|
64
|
+
league.playoff_teams.each(&:print_win_loss)
|
63
65
|
end
|
64
66
|
|
65
67
|
league.divisions.each do |name, teams|
|
66
|
-
puts
|
67
|
-
Team.
|
68
|
+
puts(name)
|
69
|
+
League::Team.sort(teams).each(&:print_win_loss)
|
68
70
|
end
|
69
71
|
when 2 # Rosters
|
70
72
|
teams = league.divisions.values.reduce(:+)
|
71
|
-
team = menu_input_elem
|
72
|
-
|
73
|
+
team = menu_input_elem('All teams', teams)
|
74
|
+
|
73
75
|
if team.nil?
|
74
|
-
teams.each
|
76
|
+
teams.each(&:print_roster)
|
75
77
|
next
|
76
78
|
end
|
77
79
|
team.print_roster
|
80
|
+
when 3 # Election
|
81
|
+
Season::ELECTION.each do |category, options|
|
82
|
+
puts(category)
|
83
|
+
options.each { |name, description| puts(" #{name}: #{description}") }
|
84
|
+
end
|
85
|
+
puts("Go to #{Season::ELECTION_FORM} to vote.\n"\
|
86
|
+
"If you don't want to use Google Forms, DM me on Discord (Lavender#9223).")
|
78
87
|
else
|
79
88
|
exit
|
80
89
|
end
|
81
90
|
end
|
82
|
-
|