hlockey 2 → 4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/election.yaml +21 -0
- data/data/external/names.txt +19948 -0
- data/data/information.yaml +24 -0
- data/data/league.yaml +1526 -0
- data/data/links.yaml +3 -0
- data/data/previous_election_results.yaml +59 -0
- data/lib/hlockey/constants.rb +4 -0
- data/lib/hlockey/data.rb +17 -13
- data/lib/hlockey/game/actions.rb +27 -0
- data/lib/hlockey/game/fight.rb +99 -0
- data/lib/hlockey/game.rb +321 -159
- data/lib/hlockey/league.rb +254 -115
- data/lib/hlockey/message.rb +182 -0
- data/lib/hlockey/player.rb +73 -0
- data/lib/hlockey/team.rb +52 -35
- data/lib/hlockey/utils.rb +15 -0
- data/lib/hlockey/version.rb +3 -5
- data/lib/hlockey/weather.rb +168 -0
- data/lib/hlockey.rb +1 -3
- metadata +36 -16
- data/bin/hlockey +0 -104
- data/lib/hlockey/data/election.yaml +0 -16
- data/lib/hlockey/data/information.yaml +0 -12
- data/lib/hlockey/data/league.yaml +0 -846
- data/lib/hlockey/data/links.yaml +0 -2
- data/lib/hlockey/messages.rb +0 -100
data/lib/hlockey/data/links.yaml
DELETED
data/lib/hlockey/messages.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require('hlockey/version')
|
4
|
-
|
5
|
-
module Hlockey
|
6
|
-
class Messages
|
7
|
-
private_class_method(:new)
|
8
|
-
|
9
|
-
def initialize(event, fields, data)
|
10
|
-
@event = event
|
11
|
-
fields.zip(data) do |(f, d)|
|
12
|
-
instance_variable_set("@#{f}", d)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class << self
|
17
|
-
# These are messages logged to game streams
|
18
|
-
|
19
|
-
[
|
20
|
-
%i[StartOfGame],
|
21
|
-
%i[EndOfGame winning_team],
|
22
|
-
%i[StartOfPeriod period],
|
23
|
-
%i[EndOfPeriod period home away home_score away_score],
|
24
|
-
%i[FaceOff winning_player new_puck_team],
|
25
|
-
%i[Hit puck_holder defender puck_taken new_puck_team],
|
26
|
-
%i[Pass sender receiver interceptor new_puck_team],
|
27
|
-
%i[ShootScore shooter home away home_score away_score],
|
28
|
-
%i[ShootBlock shooter blocker puck_taken new_puck_team]
|
29
|
-
].each do |event, *fields|
|
30
|
-
define_method(event) do |*data|
|
31
|
-
new(event, fields, data)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# These are messages used elsewhere
|
36
|
-
|
37
|
-
def SeasonDay(day)
|
38
|
-
"Season #{VERSION} day #{day}"
|
39
|
-
end
|
40
|
-
|
41
|
-
def SeasonStarts(time)
|
42
|
-
time.strftime("Season #{VERSION} starts at %H:%M, %A, %B %d (%Z).")
|
43
|
-
end
|
44
|
-
|
45
|
-
def SeasonChampion(team)
|
46
|
-
"Your season #{VERSION} champions are the #{team}!"
|
47
|
-
end
|
48
|
-
|
49
|
-
def NoGames
|
50
|
-
'no games right now. it is the offseason. join the Hlockey Discord for updates'
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def to_s
|
55
|
-
case @event
|
56
|
-
when :StartOfGame
|
57
|
-
'Hocky!'
|
58
|
-
when :EndOfGame
|
59
|
-
"Game over.\n#{@winning_team} win!"
|
60
|
-
when :StartOfPeriod
|
61
|
-
"Start#{of_period}"
|
62
|
-
when :EndOfPeriod
|
63
|
-
"End#{of_period}#{score}"
|
64
|
-
when :FaceOff
|
65
|
-
"#{@winning_player} wins the faceoff!#{possession_change}"
|
66
|
-
when :Hit
|
67
|
-
"#{@defender} hits #{@puck_holder}#{takes}"
|
68
|
-
when :Pass
|
69
|
-
"#{@sender} passes to #{@receiver}." +
|
70
|
-
"#{"..\nIntercepted by #{@interceptor}!#{possession_change}" if @interceptor}"
|
71
|
-
when :ShootScore
|
72
|
-
"#{shot} and scores!#{score}"
|
73
|
-
when :ShootBlock
|
74
|
-
"#{shot}...\n#{@blocker} blocks the shot#{takes}"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def of_period
|
81
|
-
" of period #{@period}."
|
82
|
-
end
|
83
|
-
|
84
|
-
def score
|
85
|
-
"\n#{@home} #{@home_score}, #{@away} #{@away_score}"
|
86
|
-
end
|
87
|
-
|
88
|
-
def shot
|
89
|
-
"#{@shooter} takes a shot"
|
90
|
-
end
|
91
|
-
|
92
|
-
def takes
|
93
|
-
@puck_taken ? " and takes the puck!#{possession_change}" : '!'
|
94
|
-
end
|
95
|
-
|
96
|
-
def possession_change
|
97
|
-
"\n#{@new_puck_team} have possession."
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|