openra 1.7.0 → 1.8.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
  SHA256:
3
- metadata.gz: 0f5589223dd3591d9db257c50c14843f99ff9d6cb25e54f667fc2b43a8dbcfaf
4
- data.tar.gz: 83d7082b488eb31f84e0f891e93acf1514f3b1548826190385190d6234a31ea6
3
+ metadata.gz: bdebe6f1d4e30d7cefc66638f4f88f853f31acd04b371e367af70b7e23ccc83b
4
+ data.tar.gz: c61ed7c050d13664ef650d4727c904ecd1814ce789534b93bec693a3863dec94
5
5
  SHA512:
6
- metadata.gz: 56da77ac510188b14c9c2497809f65989ce92751706026350b860c111d8c94a00ad414a47e8d158a03130ff5602b2615266a3e19229f786d3dc4f4d07389aa4c
7
- data.tar.gz: c0ebd68879e4d35bc3084052034b4068105346458665c7a475fb36a550fcb9de57269188e7fc3e5da16df871e53b87b00434fbea6576a03927c9de8397c0ef5b
6
+ metadata.gz: 5b70e814b16cf0d65bad4b6482388753f0f4104c03757589df219e739ef713c156ac306a3fe97a7e06662e19ac808c49c3eee7ad086210f386595fabdbe909bd
7
+ data.tar.gz: 6e80c9a0b8c1c486b6159ca6b58323ca4114ce8cebaca13cc66b6d73a168cfe8a8ff3296f49fe782ddd8055799cbf1d1dc0237bd1a9066320fa6b7ae22837283
@@ -1,12 +1,20 @@
1
1
  ## Unreleased
2
2
 
3
- [Compare v1.7.0...HEAD](https://github.com/AMHOL/openra-ruby/compare/v1.7.0...HEAD)
3
+ [Compare v1.8.0...HEAD](https://github.com/AMHOL/openra-ruby/compare/v1.8.0...HEAD)
4
+
5
+ ## v1.8.0
6
+
7
+ ### Added
8
+
9
+ * [replay-data] Add support_powers with usage counts to output
10
+
11
+ [Compare v1.7.0...v1.8.0](https://github.com/AMHOL/openra-ruby/compare/v1.7.0...v1.8.0)
4
12
 
5
13
  ## v1.7.0
6
14
 
7
15
  ### Improvements
8
16
 
9
- * Decreased memory usage by streaming orders with iterator ([AMHOL](https://github.com/AMHOL))
17
+ * [core] Decreased memory usage by streaming orders with iterator ([AMHOL](https://github.com/AMHOL))
10
18
 
11
19
  [Compare v1.6.0...v1.7.0](https://github.com/AMHOL/openra-ruby/compare/v1.6.0...v1.7.0)
12
20
 
@@ -14,7 +22,7 @@
14
22
 
15
23
  ### Fixed
16
24
 
17
- * Updated to work with release-20200202 (current release) ([AMHOL](https://github.com/AMHOL))
25
+ * [core] Updated to work with release-20200202 (current release) ([AMHOL](https://github.com/AMHOL))
18
26
 
19
27
  [Compare v1.5.0...v1.6.0](https://github.com/AMHOL/openra-ruby/compare/v1.5.0...v1.6.0)
20
28
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'openra/version'
4
+ require 'openra/constants'
4
5
  require 'openra/replays' # Replays requires everything else
@@ -5,6 +5,7 @@ require 'yaml'
5
5
  require 'json'
6
6
  require 'dry/cli'
7
7
  require 'openra/version'
8
+ require 'openra/constants'
8
9
  require 'openra/replays'
9
10
  require 'openra/cli/commands/formatters'
10
11
  require 'openra/cli/commands/detect_production_macros'
@@ -11,6 +11,7 @@ module Openra
11
11
 
12
12
  def call(replay:, **options)
13
13
  replay = Openra::Replays::Replay.new(replay)
14
+ support_powers = SUPPORT_POWERS.fetch(replay.metadata.mod, {})
14
15
 
15
16
  data = {
16
17
  mod: replay.metadata.mod,
@@ -72,7 +73,8 @@ module Openra
72
73
  is_admin: client.is_admin,
73
74
  is_player: !player.nil?,
74
75
  is_winner: player&.outcome == 'Won',
75
- build: []
76
+ build: [],
77
+ support_powers: support_powers.values.product([0]).to_h
76
78
  }
77
79
  end
78
80
 
@@ -99,6 +101,13 @@ module Openra
99
101
  current_sync_clients = Openra::Struct::SyncLobbyClients.new(
100
102
  Openra::YAML.load(order.target)
101
103
  ).clients
104
+ when *support_powers.keys
105
+ key = support_powers.fetch(order.command.force_encoding('UTF-8'))
106
+ client_hash = data[:clients].find do |candidate|
107
+ candidate[:index] == order.client_index.to_s
108
+ end
109
+
110
+ client_hash[:support_powers][key] += 1
102
111
  when 'PlaceBuilding'
103
112
  client_hash = data[:clients].find do |candidate|
104
113
  candidate[:index] == order.client_index.to_s
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openra
4
+ SUPPORT_POWERS = {
5
+ 'ra' => {
6
+ 'SovietSpyPlane' => :spy_plane,
7
+ 'SovietParatroopers' => :paratroopers,
8
+ 'UkraineParabombs' => :parabombs,
9
+ 'Chronoshift' => :chronoshift,
10
+ 'NukePowerInfoOrder' => :nuke,
11
+ 'GrantExternalConditionPowerInfoOrder' => :iron_curtain
12
+ },
13
+ 'cnc' => {
14
+ 'AirstrikePowerInfoOrder' => :airstrike,
15
+ 'IonCannonPowerInfoOrder' => :ion_cannon,
16
+ 'NukePowerInfoOrder' => :nuke
17
+ }
18
+ }.freeze
19
+ end
@@ -11,7 +11,7 @@ module Openra
11
11
  end
12
12
 
13
13
  UTF8String = Types::String.constructor do |input|
14
- input.force_encoding('UTF-8').to_s
14
+ input.force_encoding('UTF-8')
15
15
  end
16
16
  end
17
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Openra
4
- VERSION = '1.7.0'.freeze
4
+ VERSION = '1.8.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Holland
@@ -179,6 +179,7 @@ files:
179
179
  - lib/openra/cli/commands/formatters.rb
180
180
  - lib/openra/cli/commands/replay_data.rb
181
181
  - lib/openra/cli/commands/version.rb
182
+ - lib/openra/constants.rb
182
183
  - lib/openra/replays.rb
183
184
  - lib/openra/replays/file.rb
184
185
  - lib/openra/replays/metadata.rb