hlockey 2 → 4

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.
@@ -1,2 +0,0 @@
1
- :GitHub: https://github.com/Hlockey
2
- :Discord: https://discord.gg/hQMRZyexUB
@@ -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