hlockey 0 → 2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/hlockey +62 -40
- data/lib/hlockey/data/election.yaml +16 -0
- data/lib/hlockey/data/information.yaml +12 -0
- data/lib/hlockey/data/league.yaml +846 -0
- data/lib/hlockey/data/links.yaml +2 -0
- data/lib/hlockey/data.rb +13 -0
- data/lib/hlockey/game.rb +159 -0
- data/lib/hlockey/league.rb +115 -0
- data/lib/hlockey/messages.rb +100 -0
- data/lib/hlockey/team.rb +35 -0
- data/lib/hlockey/version.rb +5 -0
- data/lib/hlockey.rb +3 -0
- metadata +17 -12
- data/lib/data/names_markov_chain.rb +0 -634
- data/lib/game.rb +0 -153
- data/lib/league.rb +0 -130
- data/lib/messages.rb +0 -64
- 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: 7e46193bf3b3f1113e7c57fe9bf55fa6c346abd442dd01d81e2431364f794a4f
|
4
|
+
data.tar.gz: e0b7f24304f815f861255a02f0966dd87c1614a62e5013de92c4e077c062e006
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
puts
|
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
|
20
|
-
i = menu_input
|
21
|
-
choices[i] unless i
|
19
|
+
def menu_input_elem(choices)
|
20
|
+
i = menu_input('Back', *choices)
|
21
|
+
choices[i] unless i.negative?
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
def emoji_team(team)
|
25
|
+
"#{team.emoji} #{team}"
|
26
|
+
end
|
27
|
+
|
28
|
+
puts('Please wait...')
|
27
29
|
|
28
|
-
|
29
|
-
puts
|
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
|
41
|
+
puts(Hlockey::Messages.SeasonDay(league.day))
|
36
42
|
|
37
|
-
case menu_input
|
43
|
+
case menu_input('Exit', 'Games', 'Standings', 'Team info', 'Election', 'Information')
|
38
44
|
when 0 # Games
|
39
|
-
if league.
|
40
|
-
puts
|
45
|
+
if league.games.empty?
|
46
|
+
puts(Hlockey::Messages.NoGames)
|
41
47
|
next
|
42
48
|
end
|
43
49
|
|
44
|
-
game = menu_input_elem
|
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
|
57
|
+
game.stream.each(&method(:puts))
|
51
58
|
|
52
59
|
break unless game.in_progress
|
53
60
|
|
54
61
|
game.stream.clear
|
55
|
-
sleep
|
62
|
+
sleep(5)
|
56
63
|
end
|
57
64
|
when 1 # Standings
|
58
65
|
if league.champion_team
|
59
|
-
puts
|
66
|
+
puts(Hlockey::Messages.SeasonChampion(league.champion_team))
|
60
67
|
elsif league.playoff_teams
|
61
|
-
puts
|
62
|
-
league.playoff_teams.each
|
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
|
67
|
-
|
73
|
+
puts(name)
|
74
|
+
teams.each(&PRINT_TEAM_W_L)
|
68
75
|
end
|
69
|
-
when 2 #
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
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
|
-
|
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.
|