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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd5809297e263857801bd4718a7ae81e286e48b29d55661a48e8f962977f4ebf
4
- data.tar.gz: b1b317bcc5646676415e7ab2f4516f6150c0832e56925461521066ed354cff6e
3
+ metadata.gz: 46e23c61853872982a0e27a07eebb63950fe51fdd283872b365b9c77b665a976
4
+ data.tar.gz: 9ea49d62dbb908058043fe58b8f88afb0eaeaed5d34c325e2764a4f0a311d94a
5
5
  SHA512:
6
- metadata.gz: 02bea157d0ffe8caf3dcdc8cc151deb530c637db571c1c3812585766c91df9ef0acba073fa0baf7ec3fe8558042c911f4d243d36123eb488d1402ef32ac37f46
7
- data.tar.gz: c18f4122bf5ccfacd2ee25d3bc7afc41ecc7f8116e674d1be3c3014e95394ab02d8eb45d4c380affd4060dfc235eadc023cf849c1e53f81bc2f0a9f4fd208972
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
- require_relative "../lib/league"
4
- require_relative "../lib/team"
5
-
6
- def menu_input default, *choices
7
- puts "Please enter a number..."
8
- choices.each_with_index do |choice, i|
9
- # Adding 1 to i to avoid confusing a non-numerical input with the first choice
10
- puts "#{(i + 1).to_s.rjust 2} - #{choice}"
11
- end
12
- puts "anything else - #{default}"
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 default, choices
20
- i = menu_input default, *choices
21
- choices[i] unless i < 0
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
- season = 0.1
25
- start_time = Time.utc(2022, 6, 27, 17).localtime
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 < start_time
29
- puts start_time.strftime "Season #{season} starts at %H:%M on %A, %B %d."
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 "Season #{season} day #{league.day}"
36
+ puts("Season #{Season::NUMBER} day #{league.day}")
36
37
 
37
- case menu_input "Exit", "Games", "Standings", "Rosters"
38
+ case menu_input('Exit', 'Games', 'Standings', 'Rosters', 'Election')
38
39
  when 0 # Games
39
40
  if league.games_in_progress.empty?
40
- puts "There are currently no games being played."
41
+ puts('There are currently no games being played.')
41
42
  next
42
43
  end
43
44
 
44
- game = menu_input_elem "Back", league.games_in_progress
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 &method(:puts)
51
+ game.stream.each(&PUTS)
51
52
 
52
53
  break unless game.in_progress
53
54
 
54
55
  game.stream.clear
55
- sleep 5
56
+ sleep(5)
56
57
  end
57
58
  when 1 # Standings
58
59
  if league.champion_team
59
- puts "Your season #{season} champions are the #{league.champion_team.name}!"
60
+ puts("Your season #{Season::NUMBER} champions are the "\
61
+ "#{league.champion_team.name}!")
60
62
  elsif league.playoff_teams
61
- puts "Playoffs"
62
- league.playoff_teams.each &:print_win_loss
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 name
67
- Team.sort_teams(teams).each &:print_win_loss
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 "All teams", teams
72
-
73
+ team = menu_input_elem('All teams', teams)
74
+
73
75
  if team.nil?
74
- teams.each &:print_roster
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
-