openra 0.0.5 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0eaccca1c06eba0b65dde2f17a0981cf1e516d75
4
- data.tar.gz: 34e76e8c18ff3aba1573818d0372128ab84a87f4
3
+ metadata.gz: db310f9109e5d72e9c954d66f1c6e55a221f069b
4
+ data.tar.gz: cfdd3cf6888eac67e326752e0124db49bdf72551
5
5
  SHA512:
6
- metadata.gz: 02d718a012a934b2fc8bbd1ce39ac1977a4f3596c484c20947357af400f22caa6760ebc9f8722d03b5952c7f9d9832f04bba67393c5e613977ee73ffdc9ea3a3
7
- data.tar.gz: 15e6a0cda86840e392d49603b7c26f1dc43b9f84bdc0d4ceb4a60079513f552c11eb7323037e38bdc13586802d9d87a0899fead8f925d3a8131bd73324a52cb1
6
+ metadata.gz: b0eced85bf47e6c285ab0ee65c3353b505c9666b425e6297aaa905c47eea4b6ce7ee545740f67c665807c28d49bb6950537de5187183fecf11b8673480d66258
7
+ data.tar.gz: 8006b46f38bc4be193bbb7bd182d67040dd2b9af7e73f780ad720458806a4b1f26ec9c720b01f30df1e0ec2bee100caa487f9baa4401d6f6da604a6d6ec9605e
@@ -0,0 +1,12 @@
1
+ ## Unreleased
2
+
3
+ [Compare v0.5.0...HEAD](https://github.com/AMHOL/openra-ruby/compare/v0.5.0...HEAD)
4
+
5
+ ## Added
6
+
7
+ * Include server and team chat messages in replay data ([AMHOL](https://github.com/AMHOL))
8
+ * Include is_winner replay data client output ([AMHOL](https://github.com/AMHOL))
9
+
10
+ ## Fixed
11
+
12
+ * Return `null` for client team in replay data when team is not set ([AMHOL](https://github.com/AMHOL))
data/README.md CHANGED
@@ -4,10 +4,17 @@
4
4
  Early WIP, expermimental.
5
5
 
6
6
  ### Installation
7
- ```
7
+ ```sh
8
8
  gem install openra
9
9
  ```
10
10
 
11
+ NOTE: Requires Ruby ([Installation guide](https://www.ruby-lang.org/en/documentation/installation/))
12
+
13
+ ### Updating
14
+ ```sh
15
+ gem update openra
16
+ ```
17
+
11
18
  ### Example usage
12
19
 
13
20
  ```sh
@@ -25,7 +25,9 @@ module Openra
25
25
  next unless key.start_with?('Player')
26
26
  arr << value
27
27
  end
28
- player_indices = players.map { |player| player['ClientIndex'] }
28
+ player_mapping = players.each_with_object({}) do |player, mapping|
29
+ mapping[player['ClientIndex']] = player
30
+ end
29
31
  player_teams = players.map { |player| player['Team'] }
30
32
  team_alignment = player_teams.each_with_object({}) do |team, hash|
31
33
  if team == 0
@@ -74,10 +76,11 @@ module Openra
74
76
  color: data['Color'],
75
77
  faction: data['Faction'],
76
78
  ip: data['IpAddress'],
77
- team: data['Team'] == 0 ? nil : data['Team'],
79
+ team: data['Team'].to_s == '0' ? nil : data['Team'],
78
80
  is_bot: data['Bot'].nil? ? false : true,
79
81
  is_admin: data['IsAdmin'] == 'True',
80
- is_player: player_indices.include?(data['Index']),
82
+ is_player: player_mapping.fetch(data['Index'], false) != false,
83
+ is_winner: player_mapping.fetch(data['Index'], {}).fetch('Outcome', nil) == 'Won',
81
84
  build: []
82
85
  } unless replay_data[:clients].any? { |client| client[:index] == data['Index'] }
83
86
  when 'GlobalSettings'
@@ -131,12 +134,29 @@ module Openra
131
134
  y: order.target_y
132
135
  }
133
136
  }
137
+ when 'Message'
138
+ replay_data[:chat] << {
139
+ channel: :server,
140
+ name: nil,
141
+ message: utf8(order.target)
142
+ }
134
143
  when 'Chat'
135
144
  client = replay_data[:clients].find do |candidate|
136
145
  candidate[:index] == order.client_index.to_s
137
146
  end
138
147
 
139
148
  replay_data[:chat] << {
149
+ channel: :global,
150
+ name: client[:name],
151
+ message: utf8(order.target)
152
+ }
153
+ when 'TeamChat'
154
+ client = replay_data[:clients].find do |candidate|
155
+ candidate[:index] == order.client_index.to_s
156
+ end
157
+
158
+ replay_data[:chat] << {
159
+ channel: client[:team],
140
160
  name: client[:name],
141
161
  message: utf8(order.target)
142
162
  }
@@ -1,3 +1,3 @@
1
1
  module Openra
2
- VERSION = '0.0.5'.freeze
2
+ VERSION = '0.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Holland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-28 00:00:00.000000000 Z
11
+ date: 2018-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata
@@ -75,6 +75,7 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - ".gitignore"
78
+ - CHANGELOG.md
78
79
  - Gemfile
79
80
  - LICENSE
80
81
  - README.md