hlockey 0 → 2

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: 8b75f6192f6a4e6fd12743a3cb723fbaeb1f89cc49e8be02efb5837be127fecf
4
- data.tar.gz: 826ad54ed58f21c515e086387a8c3eceb94fcd1d8e08d83bbc6986a51a112513
3
+ metadata.gz: 7e46193bf3b3f1113e7c57fe9bf55fa6c346abd442dd01d81e2431364f794a4f
4
+ data.tar.gz: e0b7f24304f815f861255a02f0966dd87c1614a62e5013de92c4e077c062e006
5
5
  SHA512:
6
- metadata.gz: c4da1e46f91f59315c72d4ab0788e85b1427b172c26d395f94975408f73b21cac9eb08d816ba74be9d19f46f2f1f2bbb64399f539b6f077ac63db91eaa66a8c6
7
- data.tar.gz: '05803e28e89961782a6ed54a96826224adc1819aedf23640f8ecf643e5cc298f5880124463c8e0c85d23ee339dda1623803ff81be9fe7fcd10d17789f57d5573'
6
+ metadata.gz: b2551f0b9e49f1222c6f7908027978380574b6fa160912ff46299bf206d8f3c8edd50dcb357b56608dfcb0300a5a5f181d4433b3486b02652788df9d51dd3853
7
+ data.tar.gz: f3c08d82574f1ddacb1e3faf04e200322b08ca1901fc8166bcd1cb47f9489e654c79d90a4ce04563cb609ce4fbb73222bb53c5a6e313449e5c14850d8623de08
data/bin/hlockey CHANGED
@@ -1,82 +1,104 @@
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('hlockey')
6
+
7
+ def menu_input(default, *choices)
8
+ puts('Please enter a number...')
9
+ # Adding 1 to i when printing choices
10
+ # to avoid confusing a non-numerical input with the first choice
11
+ choices.each_with_index { |choice, i| puts("#{(i + 1).to_s.rjust(2)} - #{choice}") }
12
+ puts("anything else - #{default}")
13
13
 
14
14
  # Subtract 1 here to undo adding 1 earlier
15
- gets.to_i - 1
15
+ STDIN.gets.to_i - 1
16
16
  end
17
17
 
18
18
  # 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
19
+ def menu_input_elem(choices)
20
+ i = menu_input('Back', *choices)
21
+ choices[i] unless i.negative?
22
22
  end
23
23
 
24
- season = 0
25
- start_time = Time.utc(2022, 6, 27, 17).localtime
26
- league = League.new season, start_time
24
+ def emoji_team(team)
25
+ "#{team.emoji} #{team}"
26
+ end
27
+
28
+ puts('Please wait...')
27
29
 
28
- if Time.now < start_time
29
- puts start_time.strftime "Season #{season} starts at %H:%M on %A, %B %d."
30
+ PRINT_TEAM_W_L = Proc.new do |team|
31
+ puts(" #{emoji_team(team).ljust(26)} #{team.w_l}")
30
32
  end
31
33
 
34
+ league = Hlockey::League.new
35
+
36
+ puts(Hlockey::Messages.SeasonStarts(league.start_time)) if Time.now < league.start_time
37
+
32
38
  loop do
33
39
  league.update_state
34
40
 
35
- puts "Season #{season} day #{league.day}"
41
+ puts(Hlockey::Messages.SeasonDay(league.day))
36
42
 
37
- case menu_input "Exit", "Games", "Standings", "Rosters"
43
+ case menu_input('Exit', 'Games', 'Standings', 'Team info', 'Election', 'Information')
38
44
  when 0 # Games
39
- if league.games_in_progress.empty?
40
- puts "There are currently no games being played."
45
+ if league.games.empty?
46
+ puts(Hlockey::Messages.NoGames)
41
47
  next
42
48
  end
43
49
 
44
- game = menu_input_elem "Back", league.games_in_progress
50
+ game = menu_input_elem(league.games)
45
51
  next if game.nil?
46
52
 
53
+ puts("#{game.home.emoji} #{game} #{game.away.emoji}")
47
54
  loop do
48
55
  league.update_state
49
56
 
50
- game.stream.each &method(:puts)
57
+ game.stream.each(&method(:puts))
51
58
 
52
59
  break unless game.in_progress
53
60
 
54
61
  game.stream.clear
55
- sleep 5
62
+ sleep(5)
56
63
  end
57
64
  when 1 # Standings
58
65
  if league.champion_team
59
- puts "Your season #{season} champions are the #{champion_team.name}!"
66
+ puts(Hlockey::Messages.SeasonChampion(league.champion_team))
60
67
  elsif league.playoff_teams
61
- puts "Playoffs"
62
- league.playoff_teams.each &:print_win_loss
68
+ puts('Playoffs')
69
+ league.playoff_teams.each(&PRINT_TEAM_W_L)
63
70
  end
64
71
 
65
72
  league.divisions.each do |name, teams|
66
- puts name
67
- Team.sort_teams(teams).each &:print_win_loss
73
+ puts(name)
74
+ teams.each(&PRINT_TEAM_W_L)
68
75
  end
69
- when 2 # Rosters
70
- teams = league.divisions.values.reduce(:+)
71
- team = menu_input_elem "All teams", teams
72
-
73
- if team.nil?
74
- teams.each &:print_roster
75
- next
76
+ when 2 # Team info
77
+ team = menu_input_elem(league.teams)
78
+ next if team.nil?
79
+
80
+ puts(emoji_team(team))
81
+ team.roster.each do |pos, player|
82
+ puts(" #{Hlockey.pos_name(pos)}:\n #{player}")
83
+ player.stats.each { |stat, value| puts(" #{stat}: #{value.round(1)}") }
84
+ end
85
+ puts(" wins: #{team.wins}")
86
+ puts(" losses: #{team.losses}")
87
+ when 3 # Election
88
+ election = Hlockey.load_data('election')
89
+ election.each do |category, options|
90
+ puts(category)
91
+ options.each { |name, description| puts(" #{name}: #{description}") }
76
92
  end
77
- team.print_roster
93
+ puts('Go to the website (https://hlockey.herokuapp.com) to vote.')
94
+ when 4 # Information
95
+ Hlockey.load_data('information').each do |title, info|
96
+ puts(title)
97
+ info.each_line { |l| puts(" #{l}") }
98
+ end
99
+ puts('Links')
100
+ Hlockey.load_data('links').each { |site, link| puts(" #{site}: #{link}") }
78
101
  else
79
102
  exit
80
103
  end
81
104
  end
82
-
@@ -0,0 +1,16 @@
1
+ ---
2
+ :Bribery:
3
+ :Flavor Text: Give each team a motto.
4
+ :Weather: Move all the stadiums outdoors.
5
+ :We Do A Little Losing: Recognize the losingest teams with an Underbracket.
6
+ :Treasure:
7
+ :Vengabus: All your team's stats are boosted by your team's losses * 0.005.
8
+ :Dave: The worst stat on your team is set to 4.5.
9
+ :Nice: Boost your worst player by 0.69 in every stat.
10
+ :Convenient Math Error: Your team starts the next season with 5 wins.
11
+ :Coaching:
12
+ :Please Block Shots: Move your team's best defensive player to goalie.
13
+ :Please Win Faceoffs: Move your team's player best offensive player to center.
14
+ :Draft: Replace your team's worst player with a random new player.
15
+ :Small Gamble: All your team's stats go up or down by 0.5 at random.
16
+ :Big Gamble: All your team's stats go up or down by 1.0 at random.
@@ -0,0 +1,12 @@
1
+ ---
2
+ :Format: |-
3
+ Hlockey has 3 game long regular season matchups, & 5 game long postseason matchups.
4
+ The regular season is round robin format.
5
+ Teams play 2 regular season matchups against each other.
6
+ Playoffs are single-elimination tournaments.
7
+ The top 2 teams of each division qualify for playoffs.
8
+ Playoffs are perfectly seeded (best team plays worst team, etc).
9
+ :Relation to Blaseball: |-
10
+ Both Hlockey and Blaseball are splorts, therefore they have some similarities.
11
+ Breaks will usually be scheduled when Blaseball is more active.
12
+ Hlockey is inspired by Blaseball, & would most likely not exist without it.