hlockey-cli 3 → 4.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/lib/hlockey-cli/actions.rb +60 -22
- data/lib/hlockey-cli/user_selection.rb +3 -7
- data/lib/hlockey-cli/version.rb +1 -1
- data/lib/hlockey-cli.rb +14 -3
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20dbbe21705cef26f25805ff8ff5e00093b6cae75b631b5285a03524401b80a9
|
4
|
+
data.tar.gz: e7858da88ee692700c1a47dd2496ba9b533e3e9c69d86cbfa144ef9eb825455b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09539eff948b07b8c1674f6ad55eac92eb388738bdc3db8fa936b08e122668e5fc22242c1d228f6b621013aca534547f94a991936dbd5443fa2f3af7f31cfc40'
|
7
|
+
data.tar.gz: c374e0f96b827d21ec6777fc168474b876aae83ea2e03ade519d7f105be3d0ca26e5cb81668ea49f469aa465dd2e6c9970cdb60a841e3152e8bd4064e9330ec9
|
data/lib/hlockey-cli/actions.rb
CHANGED
@@ -19,13 +19,13 @@ module HlockeyCLI
|
|
19
19
|
|
20
20
|
puts("#{chosen_game.home.emoji} #{chosen_game} #{chosen_game.away.emoji}")
|
21
21
|
|
22
|
+
stream_idx = 0
|
22
23
|
loop do
|
23
24
|
league.update_state
|
24
|
-
chosen_game.stream.each { |message| puts("#{message}\n\n") }
|
25
|
-
|
25
|
+
chosen_game.stream[stream_idx..].each { |message| puts("#{message}\n\n") }
|
26
|
+
stream_idx = chosen_game.stream.length
|
26
27
|
break unless chosen_game.in_progress
|
27
28
|
|
28
|
-
chosen_game.stream.clear
|
29
29
|
sleep(5)
|
30
30
|
end
|
31
31
|
end
|
@@ -34,34 +34,55 @@ module HlockeyCLI
|
|
34
34
|
if league.champion_team
|
35
35
|
puts(Hlockey::Message.SeasonChampion(league.champion_team))
|
36
36
|
elsif league.playoff_teams
|
37
|
-
|
37
|
+
(league.playoff_teams.length / 2).times do |i|
|
38
|
+
put_standings("Playoff Matchup #{i + 1}",
|
39
|
+
[league.playoff_teams[i], league.playoff_teams[-i - 1]])
|
40
|
+
end
|
41
|
+
puts("_" * 31) # Separator from regular standings
|
38
42
|
end
|
39
43
|
league.divisions.each { |name, teams| put_standings(name, teams) }
|
40
44
|
end
|
41
45
|
|
42
46
|
def team_info(league)
|
43
|
-
chosen_team = HlockeyCLI.user_selection(league.teams)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
chosen_team = HlockeyCLI.user_selection(league.teams, default: "All teams")
|
48
|
+
|
49
|
+
(chosen_team.nil? ? league.teams : [chosen_team]).each do |team|
|
50
|
+
puts("#{team.emoji} #{team}")
|
51
|
+
puts("\"#{team.motto}\"")
|
52
|
+
team.roster.each do |pos, player|
|
53
|
+
puts(" #{Hlockey::Team.pos_name(pos)}:\n #{player}")
|
54
|
+
put_stats(player)
|
55
|
+
end
|
56
|
+
puts(" Shadows:")
|
57
|
+
team.shadows.each do |player|
|
58
|
+
puts(" #{player}")
|
59
|
+
put_stats(player)
|
51
60
|
end
|
61
|
+
puts(" Wins: #{team.wins}")
|
62
|
+
puts(" Losses: #{team.losses}")
|
52
63
|
end
|
53
|
-
puts(" wins: #{chosen_team.wins}")
|
54
|
-
puts(" losses: #{chosen_team.losses}")
|
55
64
|
end
|
56
65
|
|
57
|
-
def election(
|
58
|
-
|
59
|
-
puts(
|
60
|
-
|
66
|
+
def election(league)
|
67
|
+
if league.start_time < Time.now
|
68
|
+
puts("Current election options\nGo to the website to vote.")
|
69
|
+
Hlockey::Data.election.each do |category, options|
|
70
|
+
puts(" #{category}")
|
71
|
+
options.each { |name, description| puts(" #{name}\n #{description}") }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
election_results = Hlockey::Data.previous_election_results
|
76
|
+
puts("Previous election results\nvotes cast: #{election_results[:vote_amt]}")
|
77
|
+
election_results[:categories].each do |category, options|
|
78
|
+
puts(" #{category}")
|
79
|
+
options.each do |name, result|
|
80
|
+
puts(" #{name}\n #{result[:winner]}")
|
81
|
+
next if result[:most_votes].nil?
|
82
|
+
|
83
|
+
puts(" team with most votes: #{result[:most_votes]}")
|
84
|
+
end
|
61
85
|
end
|
62
|
-
# TODO: add an actual link to the website,
|
63
|
-
# probably should be from Hlockey lib data
|
64
|
-
puts("Go to the website to vote.")
|
65
86
|
end
|
66
87
|
|
67
88
|
def information(_)
|
@@ -77,7 +98,24 @@ module HlockeyCLI
|
|
77
98
|
|
78
99
|
def put_standings(division_name, teams)
|
79
100
|
puts(division_name)
|
80
|
-
teams.each
|
101
|
+
teams.each do |team|
|
102
|
+
status_emoji = case team.status
|
103
|
+
when :partying
|
104
|
+
" 🎉"
|
105
|
+
when :qualified
|
106
|
+
" ✅"
|
107
|
+
else
|
108
|
+
""
|
109
|
+
end
|
110
|
+
puts("#{team.emoji} #{team}".ljust(27) + team.w_l + status_emoji)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# @param player [Hlockey::Player]
|
115
|
+
def put_stats(player)
|
116
|
+
player.stat_strings.each do |key, value|
|
117
|
+
puts(" #{key}: #{value}")
|
118
|
+
end
|
81
119
|
end
|
82
120
|
end
|
83
121
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module HlockeyCLI
|
2
|
-
def self.user_selection(choices, default:
|
2
|
+
def self.user_selection(choices, default: "Back", str_process: ->(s) { s })
|
3
3
|
puts("Please enter a number...")
|
4
4
|
|
5
5
|
# 1 is added to i when printing choices
|
@@ -7,15 +7,11 @@ module HlockeyCLI
|
|
7
7
|
choices.each_with_index do |choice, i|
|
8
8
|
puts("#{(i + 1).to_s.rjust(2)} - #{str_process.call(choice)}")
|
9
9
|
end
|
10
|
-
puts("anything else - #{default
|
10
|
+
puts("anything else - #{default}")
|
11
11
|
|
12
12
|
# 1 is subracted to undo adding 1 earlier
|
13
13
|
choice_idx = $stdin.gets.to_i - 1
|
14
14
|
|
15
|
-
|
16
|
-
choices[choice_idx]
|
17
|
-
else
|
18
|
-
default
|
19
|
-
end
|
15
|
+
!choice_idx.negative? && choice_idx < choices.length ? choices[choice_idx] : nil
|
20
16
|
end
|
21
17
|
end
|
data/lib/hlockey-cli/version.rb
CHANGED
data/lib/hlockey-cli.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require("hlockey")
|
2
|
+
require("paint")
|
2
3
|
require("hlockey-cli/actions")
|
3
4
|
require("hlockey-cli/user_selection")
|
4
5
|
require("hlockey-cli/version")
|
@@ -7,20 +8,30 @@ module HlockeyCLI
|
|
7
8
|
def self.main
|
8
9
|
puts("Please wait...")
|
9
10
|
|
11
|
+
Hlockey::Message.colorize = ->(color, string) { Paint[string, color] }
|
12
|
+
|
10
13
|
league = Hlockey::League.new
|
14
|
+
alerts = league.alerts.clone
|
11
15
|
|
12
16
|
puts(Hlockey::Message.SeasonStarts(league.start_time)) if Time.now < league.start_time
|
13
17
|
|
14
18
|
loop do
|
15
19
|
league.update_state
|
20
|
+
|
21
|
+
unless alerts == league.alerts
|
22
|
+
alerts = league.alerts.clone
|
23
|
+
alerts.each(&method(:puts))
|
24
|
+
puts # newline
|
25
|
+
end
|
16
26
|
puts(Hlockey::Message.SeasonDay(league.day))
|
17
27
|
|
18
28
|
selected_action = user_selection(
|
19
29
|
Actions::ACTIONS,
|
20
|
-
default:
|
21
|
-
str_process:
|
30
|
+
default: "Exit",
|
31
|
+
str_process: ->(s) { s.to_s.capitalize.sub("_", " ") }
|
22
32
|
)
|
23
|
-
exit if selected_action
|
33
|
+
exit if selected_action.nil?
|
34
|
+
|
24
35
|
Actions.send(selected_action, league)
|
25
36
|
end
|
26
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hlockey-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '4.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lavender Perry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hlockey
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: paint
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.3'
|
27
41
|
description: Hlockey console application.
|
28
42
|
email: endie2@protonmail.com
|
29
43
|
executables:
|