hlockey 1 → 2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46e23c61853872982a0e27a07eebb63950fe51fdd283872b365b9c77b665a976
4
- data.tar.gz: 9ea49d62dbb908058043fe58b8f88afb0eaeaed5d34c325e2764a4f0a311d94a
3
+ metadata.gz: 7e46193bf3b3f1113e7c57fe9bf55fa6c346abd442dd01d81e2431364f794a4f
4
+ data.tar.gz: e0b7f24304f815f861255a02f0966dd87c1614a62e5013de92c4e077c062e006
5
5
  SHA512:
6
- metadata.gz: 8c9ec44ba9c7319fdb2b5a7bdc4d13892e07b712c418f268b04d1b1a5d43e4079af6439924dd0095ca71c8e223f07c17e1e107bd29a5b2b0f207d2cebae2b95c
7
- data.tar.gz: fe658fc39c7825f4c9015e4b20772914f251bc84e04d0b723a1384a5d4b27f9611840c1b3657ebd8845c42ecdf0661f74f374f4748f20f90a85db2ccb5a4d902
6
+ metadata.gz: b2551f0b9e49f1222c6f7908027978380574b6fa160912ff46299bf206d8f3c8edd50dcb357b56608dfcb0300a5a5f181d4433b3486b02652788df9d51dd3853
7
+ data.tar.gz: f3c08d82574f1ddacb1e3faf04e200322b08ca1901fc8166bcd1cb47f9489e654c79d90a4ce04563cb609ce4fbb73222bb53c5a6e313449e5c14850d8623de08
data/bin/hlockey CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  # frozen_string_literal: true
4
4
 
5
- require_relative('../lib/league')
6
- require_relative('../lib/data/season')
5
+ require('hlockey')
7
6
 
8
7
  def menu_input(default, *choices)
9
8
  puts('Please enter a number...')
@@ -13,42 +12,49 @@ def menu_input(default, *choices)
13
12
  puts("anything else - #{default}")
14
13
 
15
14
  # Subtract 1 here to undo adding 1 earlier
16
- gets.to_i - 1
15
+ STDIN.gets.to_i - 1
17
16
  end
18
17
 
19
18
  # Each element from choices should implement to_s
20
- def menu_input_elem(default, choices)
21
- i = menu_input(default, *choices)
19
+ def menu_input_elem(choices)
20
+ i = menu_input('Back', *choices)
22
21
  choices[i] unless i.negative?
23
22
  end
24
23
 
25
- PUTS = method(:puts)
26
- league = League.new(Season::NUMBER, 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 < Season::START_TIME
29
- puts Season::START_TIME
30
- .strftime("Season #{Season::NUMBER} 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}")
31
32
  end
32
33
 
34
+ league = Hlockey::League.new
35
+
36
+ puts(Hlockey::Messages.SeasonStarts(league.start_time)) if Time.now < league.start_time
37
+
33
38
  loop do
34
39
  league.update_state
35
40
 
36
- puts("Season #{Season::NUMBER} day #{league.day}")
41
+ puts(Hlockey::Messages.SeasonDay(league.day))
37
42
 
38
- case menu_input('Exit', 'Games', 'Standings', 'Rosters', 'Election')
43
+ case menu_input('Exit', 'Games', 'Standings', 'Team info', 'Election', 'Information')
39
44
  when 0 # Games
40
- if league.games_in_progress.empty?
41
- puts('There are currently no games being played.')
45
+ if league.games.empty?
46
+ puts(Hlockey::Messages.NoGames)
42
47
  next
43
48
  end
44
49
 
45
- game = menu_input_elem('Back', league.games_in_progress)
50
+ game = menu_input_elem(league.games)
46
51
  next if game.nil?
47
52
 
53
+ puts("#{game.home.emoji} #{game} #{game.away.emoji}")
48
54
  loop do
49
55
  league.update_state
50
56
 
51
- game.stream.each(&PUTS)
57
+ game.stream.each(&method(:puts))
52
58
 
53
59
  break unless game.in_progress
54
60
 
@@ -57,33 +63,41 @@ loop do
57
63
  end
58
64
  when 1 # Standings
59
65
  if league.champion_team
60
- puts("Your season #{Season::NUMBER} champions are the "\
61
- "#{league.champion_team.name}!")
66
+ puts(Hlockey::Messages.SeasonChampion(league.champion_team))
62
67
  elsif league.playoff_teams
63
68
  puts('Playoffs')
64
- league.playoff_teams.each(&:print_win_loss)
69
+ league.playoff_teams.each(&PRINT_TEAM_W_L)
65
70
  end
66
71
 
67
72
  league.divisions.each do |name, teams|
68
73
  puts(name)
69
- League::Team.sort(teams).each(&:print_win_loss)
74
+ teams.each(&PRINT_TEAM_W_L)
70
75
  end
71
- when 2 # Rosters
72
- teams = league.divisions.values.reduce(:+)
73
- team = menu_input_elem('All teams', teams)
74
-
75
- if team.nil?
76
- teams.each(&:print_roster)
77
- 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)}") }
78
84
  end
79
- team.print_roster
85
+ puts(" wins: #{team.wins}")
86
+ puts(" losses: #{team.losses}")
80
87
  when 3 # Election
81
- Season::ELECTION.each do |category, options|
88
+ election = Hlockey.load_data('election')
89
+ election.each do |category, options|
82
90
  puts(category)
83
91
  options.each { |name, description| puts(" #{name}: #{description}") }
84
92
  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).")
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}") }
87
101
  else
88
102
  exit
89
103
  end
@@ -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.