sc2ai 0.0.0.pre → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/data/data.json +1 -0
  3. data/data/data_readable.json +22842 -0
  4. data/data/sc2ai/protocol/common.proto +59 -0
  5. data/data/sc2ai/protocol/data.proto +120 -0
  6. data/data/sc2ai/protocol/debug.proto +127 -0
  7. data/data/sc2ai/protocol/error.proto +221 -0
  8. data/data/sc2ai/protocol/query.proto +55 -0
  9. data/data/sc2ai/protocol/raw.proto +202 -0
  10. data/data/sc2ai/protocol/sc2api.proto +718 -0
  11. data/data/sc2ai/protocol/score.proto +108 -0
  12. data/data/sc2ai/protocol/spatial.proto +115 -0
  13. data/data/sc2ai/protocol/ui.proto +145 -0
  14. data/data/setup/setup.SC2Map +0 -0
  15. data/data/setup/setup.SC2Replay +0 -0
  16. data/data/stableid.json +35730 -0
  17. data/data/versions.json +554 -0
  18. data/exe/sc2ai +35 -0
  19. data/lib/docker_build/Dockerfile.ruby +74 -0
  20. data/lib/docker_build/docker-compose-base-image.yml +10 -0
  21. data/lib/docker_build/docker-compose-ladderzip.yml +9 -0
  22. data/lib/sc2ai/api/ability_id.rb +1644 -0
  23. data/lib/sc2ai/api/buff_id.rb +306 -0
  24. data/lib/sc2ai/api/data.rb +101 -0
  25. data/lib/sc2ai/api/effect_id.rb +20 -0
  26. data/lib/sc2ai/api/tech_tree.rb +83 -0
  27. data/lib/sc2ai/api/tech_tree_data.rb +2338 -0
  28. data/lib/sc2ai/api/unit_type_id.rb +2022 -0
  29. data/lib/sc2ai/api/upgrade_id.rb +310 -0
  30. data/lib/sc2ai/cli/cli.rb +175 -0
  31. data/lib/sc2ai/cli/ladderzip.rb +154 -0
  32. data/lib/sc2ai/cli/new.rb +88 -0
  33. data/lib/sc2ai/configuration.rb +145 -0
  34. data/lib/sc2ai/connection/connection_listener.rb +30 -0
  35. data/lib/sc2ai/connection/requests.rb +417 -0
  36. data/lib/sc2ai/connection/status_listener.rb +15 -0
  37. data/lib/sc2ai/connection.rb +146 -0
  38. data/lib/sc2ai/local_play/client/configurable_options.rb +115 -0
  39. data/lib/sc2ai/local_play/client.rb +159 -0
  40. data/lib/sc2ai/local_play/client_manager.rb +70 -0
  41. data/lib/sc2ai/local_play/map_file.rb +48 -0
  42. data/lib/sc2ai/local_play/match.rb +184 -0
  43. data/lib/sc2ai/overrides/array.rb +14 -0
  44. data/lib/sc2ai/overrides/async/process/child.rb +31 -0
  45. data/lib/sc2ai/overrides/kernel.rb +33 -0
  46. data/lib/sc2ai/paths.rb +294 -0
  47. data/lib/sc2ai/player/actions.rb +386 -0
  48. data/lib/sc2ai/player/debug.rb +224 -0
  49. data/lib/sc2ai/player/game_state.rb +131 -0
  50. data/lib/sc2ai/player/geometry.rb +766 -0
  51. data/lib/sc2ai/player/previous_state.rb +49 -0
  52. data/lib/sc2ai/player/units.rb +337 -0
  53. data/lib/sc2ai/player.rb +661 -0
  54. data/lib/sc2ai/ports.rb +152 -0
  55. data/lib/sc2ai/protocol/_meta_documentation.rb +39 -0
  56. data/lib/sc2ai/protocol/common_pb.rb +43 -0
  57. data/lib/sc2ai/protocol/data_pb.rb +47 -0
  58. data/lib/sc2ai/protocol/debug_pb.rb +56 -0
  59. data/lib/sc2ai/protocol/error_pb.rb +36 -0
  60. data/lib/sc2ai/protocol/extensions/color.rb +20 -0
  61. data/lib/sc2ai/protocol/extensions/point.rb +23 -0
  62. data/lib/sc2ai/protocol/extensions/point_2_d.rb +26 -0
  63. data/lib/sc2ai/protocol/extensions/position.rb +202 -0
  64. data/lib/sc2ai/protocol/extensions/power_source.rb +19 -0
  65. data/lib/sc2ai/protocol/extensions/unit.rb +489 -0
  66. data/lib/sc2ai/protocol/query_pb.rb +47 -0
  67. data/lib/sc2ai/protocol/raw_pb.rb +57 -0
  68. data/lib/sc2ai/protocol/sc2api_pb.rb +130 -0
  69. data/lib/sc2ai/protocol/score_pb.rb +40 -0
  70. data/lib/sc2ai/protocol/spatial_pb.rb +48 -0
  71. data/lib/sc2ai/protocol/ui_pb.rb +56 -0
  72. data/lib/sc2ai/unit_group/action_ext.rb +74 -0
  73. data/lib/sc2ai/unit_group/filter_ext.rb +379 -0
  74. data/lib/sc2ai/unit_group.rb +277 -0
  75. data/lib/sc2ai/version.rb +2 -1
  76. data/lib/sc2ai.rb +93 -2
  77. data/lib/templates/ladderzip/bin/ladder.tt +23 -0
  78. data/lib/templates/new/.ladderignore +20 -0
  79. data/lib/templates/new/Gemfile.tt +7 -0
  80. data/lib/templates/new/api/common.proto +59 -0
  81. data/lib/templates/new/api/data.proto +120 -0
  82. data/lib/templates/new/api/debug.proto +127 -0
  83. data/lib/templates/new/api/error.proto +221 -0
  84. data/lib/templates/new/api/query.proto +55 -0
  85. data/lib/templates/new/api/raw.proto +202 -0
  86. data/lib/templates/new/api/sc2api.proto +718 -0
  87. data/lib/templates/new/api/score.proto +108 -0
  88. data/lib/templates/new/api/spatial.proto +115 -0
  89. data/lib/templates/new/api/ui.proto +145 -0
  90. data/lib/templates/new/boot.rb.tt +6 -0
  91. data/lib/templates/new/my_bot.rb.tt +23 -0
  92. data/lib/templates/new/run_example_match.rb.tt +14 -0
  93. data/sc2ai.gemspec +80 -0
  94. metadata +344 -13
@@ -0,0 +1,306 @@
1
+ # Generated from stableid.json, do not edit.
2
+
3
+ module Api
4
+ # Constant reference of Buff ids
5
+ module BuffId
6
+ NULL = 0
7
+ RADAR25 = 1
8
+ TAUNTB = 2
9
+ DISABLEABILS = 3
10
+ TRANSIENTMORPH = 4
11
+ GRAVITONBEAM = 5
12
+ GHOSTCLOAK = 6
13
+ BANSHEECLOAK = 7
14
+ POWERUSERWARPABLE = 8
15
+ VORTEXBEHAVIORENEMY = 9
16
+ CORRUPTION = 10
17
+ QUEENSPAWNLARVATIMER = 11
18
+ GHOSTHOLDFIRE = 12
19
+ GHOSTHOLDFIREB = 13
20
+ LEECH = 14
21
+ LEECHDISABLEABILITIES = 15
22
+ EMPDECLOAK = 16
23
+ FUNGALGROWTH = 17
24
+ GUARDIANSHIELD = 18
25
+ SEEKERMISSILETIMEOUT = 19
26
+ TIMEWARPPRODUCTION = 20
27
+ ETHEREAL = 21
28
+ NEURALPARASITE = 22
29
+ NEURALPARASITEWAIT = 23
30
+ STIMPACKMARAUDER = 24
31
+ SUPPLYDROP = 25
32
+ def self._250MMSTRIKECANNONS = 26
33
+ STIMPACK = 27
34
+ PSISTORM = 28
35
+ CLOAKFIELDEFFECT = 29
36
+ CHARGING = 30
37
+ AIDANGERBUFF = 31
38
+ VORTEXBEHAVIOR = 32
39
+ SLOW = 33
40
+ TEMPORALRIFTUNIT = 34
41
+ SHEEPBUSY = 35
42
+ CONTAMINATED = 36
43
+ TIMESCALECONVERSIONBEHAVIOR = 37
44
+ BLINDINGCLOUDSTRUCTURE = 38
45
+ COLLAPSIBLEROCKTOWERCONJOINEDSEARCH = 39
46
+ COLLAPSIBLEROCKTOWERRAMPDIAGONALCONJOINEDSEARCH = 40
47
+ COLLAPSIBLETERRANTOWERCONJOINEDSEARCH = 41
48
+ COLLAPSIBLETERRANTOWERRAMPDIAGONALCONJOINEDSEARCH = 42
49
+ DIGESTERCREEPSPRAYVISION = 43
50
+ INVULNERABILITYSHIELD = 44
51
+ MINEDRONECOUNTDOWN = 45
52
+ MOTHERSHIPSTASIS = 46
53
+ MOTHERSHIPSTASISCASTER = 47
54
+ MOTHERSHIPCOREENERGIZEVISUAL = 48
55
+ ORACLEREVELATION = 49
56
+ GHOSTSNIPEDOT = 50
57
+ NEXUSPHASESHIFT = 51
58
+ NEXUSINVULNERABILITY = 52
59
+ ROUGHTERRAINSEARCH = 53
60
+ ROUGHTERRAINSLOW = 54
61
+ ORACLECLOAKFIELD = 55
62
+ ORACLECLOAKFIELDEFFECT = 56
63
+ SCRYERFRIENDLY = 57
64
+ SPECTRESHIELD = 58
65
+ VIPERCONSUMESTRUCTURE = 59
66
+ RESTORESHIELDS = 60
67
+ MERCENARYCYCLONEMISSILES = 61
68
+ MERCENARYSENSORDISH = 62
69
+ MERCENARYSHIELD = 63
70
+ SCRYER = 64
71
+ STUNROUNDINITIALBEHAVIOR = 65
72
+ BUILDINGSHIELD = 66
73
+ LASERSIGHT = 67
74
+ PROTECTIVEBARRIER = 68
75
+ CORRUPTORGROUNDATTACKDEBUFF = 69
76
+ BATTLECRUISERANTIAIRDISABLE = 70
77
+ BUILDINGSTASIS = 71
78
+ STASIS = 72
79
+ RESOURCESTUN = 73
80
+ MAXIMUMTHRUST = 74
81
+ CHARGEUP = 75
82
+ CLOAKUNIT = 76
83
+ NULLFIELD = 77
84
+ RESCUE = 78
85
+ BENIGN = 79
86
+ LASERTARGETING = 80
87
+ ENGAGE = 81
88
+ CAPRESOURCE = 82
89
+ BLINDINGCLOUD = 83
90
+ DOOMDAMAGEDELAY = 84
91
+ EYESTALK = 85
92
+ BURROWCHARGE = 86
93
+ HIDDEN = 87
94
+ MINEDRONEDOT = 88
95
+ MEDIVACSPEEDBOOST = 89
96
+ EXTENDBRIDGEEXTENDINGBRIDGENEWIDE8OUT = 90
97
+ EXTENDBRIDGEEXTENDINGBRIDGENWWIDE8OUT = 91
98
+ EXTENDBRIDGEEXTENDINGBRIDGENEWIDE10OUT = 92
99
+ EXTENDBRIDGEEXTENDINGBRIDGENWWIDE10OUT = 93
100
+ EXTENDBRIDGEEXTENDINGBRIDGENEWIDE12OUT = 94
101
+ EXTENDBRIDGEEXTENDINGBRIDGENWWIDE12OUT = 95
102
+ PHASESHIELD = 96
103
+ PURIFY = 97
104
+ VOIDSIPHON = 98
105
+ ORACLEWEAPON = 99
106
+ ANTIAIRWEAPONSWITCHCOOLDOWN = 100
107
+ ARBITERMPSTASISFIELD = 101
108
+ IMMORTALOVERLOAD = 102
109
+ CLOAKINGFIELDTARGETED = 103
110
+ LIGHTNINGBOMB = 104
111
+ ORACLEPHASESHIFT = 105
112
+ RELEASEINTERCEPTORSCOOLDOWN = 106
113
+ RELEASEINTERCEPTORSTIMEDLIFEWARNING = 107
114
+ RELEASEINTERCEPTORSWANDERDELAY = 108
115
+ RELEASEINTERCEPTORSBEACON = 109
116
+ ARBITERMPCLOAKFIELDEFFECT = 110
117
+ PURIFICATIONNOVA = 111
118
+ CORRUPTIONBOMBDAMAGE = 112
119
+ CORSAIRMPDISRUPTIONWEB = 113
120
+ DISRUPTORPUSH = 114
121
+ LIGHTOFAIUR = 115
122
+ LOCKON = 116
123
+ OVERCHARGE = 117
124
+ OVERCHARGEDAMAGE = 118
125
+ OVERCHARGESPEEDBOOST = 119
126
+ SEEKERMISSILE = 120
127
+ TEMPORALFIELD = 121
128
+ VOIDRAYSWARMDAMAGEBOOST = 122
129
+ VOIDMPIMMORTALREVIVESUPRESSED = 123
130
+ DEVOURERMPACIDSPORES = 124
131
+ DEFILERMPCONSUME = 125
132
+ DEFILERMPDARKSWARM = 126
133
+ DEFILERMPPLAGUE = 127
134
+ QUEENMPENSNARE = 128
135
+ ORACLESTASISTRAPTARGET = 129
136
+ SELFREPAIR = 130
137
+ AGGRESSIVEMUTATION = 131
138
+ PARASITICBOMB = 132
139
+ PARASITICBOMBUNITKU = 133
140
+ PARASITICBOMBSECONDARYUNITSEARCH = 134
141
+ ADEPTDEATHCHECK = 135
142
+ LURKERHOLDFIRE = 136
143
+ LURKERHOLDFIREB = 137
144
+ TIMESTOPSTUN = 138
145
+ SLAYNELEMENTALGRABSTUN = 139
146
+ PURIFICATIONNOVAPOST = 140
147
+ DISABLEINTERCEPTORS = 141
148
+ BYPASSARMORDEBUFFONE = 142
149
+ BYPASSARMORDEBUFFTWO = 143
150
+ BYPASSARMORDEBUFFTHREE = 144
151
+ CHANNELSNIPECOMBAT = 145
152
+ TEMPESTDISRUPTIONBLASTSTUNBEHAVIOR = 146
153
+ GRAVITONPRISON = 147
154
+ INFESTORDISEASE = 148
155
+ SS_LIGHTNINGPROJECTOR = 149
156
+ PURIFIERPLANETCRACKERCHARGE = 150
157
+ SPECTRECLOAKING = 151
158
+ WRAITHCLOAK = 152
159
+ PSYTROUSOXIDE = 153
160
+ BANSHEECLOAKCROSSSPECTRUMDAMPENERS = 154
161
+ SS_BATTLECRUISERHUNTERSEEKERTIMEOUT = 155
162
+ SS_STRONGERENEMYBUFF = 156
163
+ SS_TERRATRONARMMISSILETARGETCHECK = 157
164
+ SS_MISSILETIMEOUT = 158
165
+ SS_LEVIATHANBOMBCOLLISIONCHECK = 159
166
+ SS_LEVIATHANBOMBEXPLODETIMER = 160
167
+ SS_LEVIATHANBOMBMISSILETARGETCHECK = 161
168
+ SS_TERRATRONCOLLISIONCHECK = 162
169
+ SS_CARRIERBOSSCOLLISIONCHECK = 163
170
+ SS_CORRUPTORMISSILETARGETCHECK = 164
171
+ SS_INVULNERABLE = 165
172
+ SS_LEVIATHANTENTACLEMISSILETARGETCHECK = 166
173
+ SS_LEVIATHANTENTACLEMISSILETARGETCHECKINVERTED = 167
174
+ SS_LEVIATHANTENTACLETARGETDEATHDELAY = 168
175
+ SS_LEVIATHANTENTACLEMISSILESCANSWAPDELAY = 169
176
+ SS_POWERUPDIAGONAL2 = 170
177
+ SS_BATTLECRUISERCOLLISIONCHECK = 171
178
+ SS_TERRATRONMISSILESPINNERMISSILELAUNCHER = 172
179
+ SS_TERRATRONMISSILESPINNERCOLLISIONCHECK = 173
180
+ SS_TERRATRONMISSILELAUNCHER = 174
181
+ SS_BATTLECRUISERMISSILELAUNCHER = 175
182
+ SS_TERRATRONSTUN = 176
183
+ SS_VIKINGRESPAWN = 177
184
+ SS_WRAITHCOLLISIONCHECK = 178
185
+ SS_SCOURGEMISSILETARGETCHECK = 179
186
+ SS_SCOURGEDEATH = 180
187
+ SS_SWARMGUARDIANCOLLISIONCHECK = 181
188
+ SS_FIGHTERBOMBMISSILEDEATH = 182
189
+ SS_FIGHTERDRONEDAMAGERESPONSE = 183
190
+ SS_INTERCEPTORCOLLISIONCHECK = 184
191
+ SS_CARRIERCOLLISIONCHECK = 185
192
+ SS_MISSILETARGETCHECKVIKINGDRONE = 186
193
+ SS_MISSILETARGETCHECKVIKINGSTRONG1 = 187
194
+ SS_MISSILETARGETCHECKVIKINGSTRONG2 = 188
195
+ SS_POWERUPHEALTH1 = 189
196
+ SS_POWERUPHEALTH2 = 190
197
+ SS_POWERUPSTRONG = 191
198
+ SS_POWERUPMORPHTOBOMB = 192
199
+ SS_POWERUPMORPHTOHEALTH = 193
200
+ SS_POWERUPMORPHTOSIDEMISSILES = 194
201
+ SS_POWERUPMORPHTOSTRONGERMISSILES = 195
202
+ SS_CORRUPTORCOLLISIONCHECK = 196
203
+ SS_SCOUTCOLLISIONCHECK = 197
204
+ SS_PHOENIXCOLLISIONCHECK = 198
205
+ SS_SCOURGECOLLISIONCHECK = 199
206
+ SS_LEVIATHANCOLLISIONCHECK = 200
207
+ SS_SCIENCEVESSELCOLLISIONCHECK = 201
208
+ SS_TERRATRONSAWCOLLISIONCHECK = 202
209
+ SS_LIGHTNINGPROJECTORCOLLISIONCHECK = 203
210
+ SHIFTDELAY = 204
211
+ BIOSTASIS = 205
212
+ PERSONALCLOAKINGFREE = 206
213
+ EMPDRAIN = 207
214
+ MINDBLASTSTUN = 208
215
+ def self._330MMBARRAGECANNONS = 209
216
+ VOODOOSHIELD = 210
217
+ SPECTRECLOAKINGFREE = 211
218
+ ULTRASONICPULSESTUN = 212
219
+ IRRADIATE = 213
220
+ NYDUSWORMLAVAINSTANTDEATH = 214
221
+ PREDATORCLOAKING = 215
222
+ PSIDISRUPTION = 216
223
+ MINDCONTROL = 217
224
+ QUEENKNOCKDOWN = 218
225
+ SCIENCEVESSELCLOAKFIELD = 219
226
+ SPORECANNONMISSILE = 220
227
+ ARTANISTEMPORALRIFTUNIT = 221
228
+ ARTANISCLOAKINGFIELDEFFECT = 222
229
+ ARTANISVORTEXBEHAVIOR = 223
230
+ INCAPACITATED = 224
231
+ KARASSPSISTORM = 225
232
+ DUTCHMARAUDERSLOW = 226
233
+ JUMPSTOMPSTUN = 227
234
+ JUMPSTOMPFSTUN = 228
235
+ RAYNORMISSILETIMEDLIFE = 229
236
+ PSIONICSHOCKWAVEHEIGHTANDSTUN = 230
237
+ SHADOWCLONE = 231
238
+ AUTOMATEDREPAIR = 232
239
+ SLIMED = 233
240
+ RAYNORTIMEBOMBMISSILE = 234
241
+ RAYNORTIMEBOMBUNIT = 235
242
+ TYCHUSCOMMANDOSTIMPACK = 236
243
+ VIRALPLASMA = 237
244
+ NAPALM = 238
245
+ BURSTCAPACITORSDAMAGEBUFF = 239
246
+ COLONYINFESTATION = 240
247
+ DOMINATION = 241
248
+ EMPBURST = 242
249
+ HYBRIDCZERGYROOTS = 243
250
+ HYBRIDFZERGYROOTS = 244
251
+ LOCKDOWNB = 245
252
+ SPECTRELOCKDOWNB = 246
253
+ VOODOOLOCKDOWN = 247
254
+ ZERATULSTUN = 248
255
+ BUILDINGSCARAB = 249
256
+ VORTEXBEHAVIORERADICATOR = 250
257
+ GHOSTBLAST = 251
258
+ HEROICBUFF03 = 252
259
+ CANNONRADAR = 253
260
+ SS_MISSILETARGETCHECKVIKING = 254
261
+ SS_MISSILETARGETCHECK = 255
262
+ SS_MAXSPEED = 256
263
+ SS_MAXACCELERATION = 257
264
+ SS_POWERUPDIAGONAL1 = 258
265
+ WATER = 259
266
+ DEFENSIVEMATRIX = 260
267
+ TESTATTRIBUTE = 261
268
+ TESTVETERANCY = 262
269
+ SHREDDERSWARMDAMAGEAPPLY = 263
270
+ CORRUPTORINFESTING = 264
271
+ MERCGROUNDDROPDELAY = 265
272
+ MERCGROUNDDROP = 266
273
+ MERCAIRDROPDELAY = 267
274
+ SPECTREHOLDFIRE = 268
275
+ SPECTREHOLDFIREB = 269
276
+ ITEMGRAVITYBOMBS = 270
277
+ CARRYMINERALFIELDMINERALS = 271
278
+ CARRYHIGHYIELDMINERALFIELDMINERALS = 272
279
+ CARRYHARVESTABLEVESPENEGEYSERGAS = 273
280
+ CARRYHARVESTABLEVESPENEGEYSERGASPROTOSS = 274
281
+ CARRYHARVESTABLEVESPENEGEYSERGASZERG = 275
282
+ PERMANENTLYCLOAKED = 276
283
+ RAVENSCRAMBLERMISSILE = 277
284
+ RAVENSHREDDERMISSILETIMEOUT = 278
285
+ RAVENSHREDDERMISSILETINT = 279
286
+ RAVENSHREDDERMISSILEARMORREDUCTION = 280
287
+ CHRONOBOOSTENERGYCOST = 281
288
+ NEXUSSHIELDRECHARGEONPYLONBEHAVIOR = 282
289
+ NEXUSSHIELDRECHARGEONPYLONBEHAVIORSECONDARYONTARGET = 283
290
+ INFESTORENSNARE = 284
291
+ INFESTORENSNAREMAKEPRECURSORREHEIGHTSOURCE = 285
292
+ NEXUSSHIELDOVERCHARGE = 286
293
+ PARASITICBOMBDELAYTIMEDLIFE = 287
294
+ TRANSFUSION = 288
295
+ ACCELERATIONZONETEMPORALFIELD = 289
296
+ ACCELERATIONZONEFLYINGTEMPORALFIELD = 290
297
+ INHIBITORZONEFLYINGTEMPORALFIELD = 291
298
+ LOADOUTSPRAYTRACKER = 292
299
+ INHIBITORZONETEMPORALFIELD = 293
300
+ RESONATINGGLAIVESPHASESHIFT = 294
301
+ NEURALPARASITECHILDREN = 295
302
+ AMORPHOUSARMORCLOUD = 296
303
+ RAVENSHREDDERMISSILEARMORREDUCTIONUISUBTRUCT = 297
304
+ BATTERYOVERCHARGE = 298
305
+ end
306
+ end
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ability_id"
4
+ require_relative "unit_type_id"
5
+ require_relative "upgrade_id"
6
+ require_relative "buff_id"
7
+ require_relative "effect_id"
8
+ require_relative "tech_tree"
9
+
10
+ module Sc2
11
+ # Holds game data from tech tree and Api::ResponseData
12
+ # Called once on game start
13
+ class Data
14
+ # @!attribute abilities
15
+ # @return [Hash<Integer, Api::AbilityData>] AbilityId => AbilityData
16
+ attr_accessor :abilities
17
+ # @!attribute units
18
+ # @return [Hash<Integer, Api::UnitTypeData>] UnitId => UnitData
19
+ attr_accessor :units
20
+ # @!attribute upgrades
21
+ # @return [Hash<Integer, Api::UnitTypeData>] UnitTypeId => UnitTypeData
22
+ attr_accessor :upgrades
23
+ # @!attribute buffs
24
+ # Not particularly useful data. Just use BuffId directly
25
+ # @return [Hash<Integer, Api::BuffData>] BuffId => BuffData
26
+ attr_accessor :buffs
27
+ # @!attribute effects
28
+ # Not particularly useful data. Just use EffectId directly
29
+ # @return [Hash<Integer, Api::EffectData>] EffectId => EffectData
30
+ attr_accessor :effects
31
+
32
+ # @param data [Api::ResponseData]
33
+ def initialize(data)
34
+ return unless data
35
+
36
+ @abilities = abilities_from_proto(data.abilities)
37
+ @units = units_from_proto(data.units)
38
+ @upgrades = upgrades_from_proto(data.upgrades)
39
+ @buffs = buffs_from_proto(data.buffs)
40
+ @effects = effects_from_proto(data.effects)
41
+ end
42
+
43
+ private
44
+
45
+ # Indexes ability data by ability id
46
+ # @param abilities [Array<Api::AbilityData>]
47
+ # @return [Hash<Integer, Api::AbilityData] indexed data
48
+ def abilities_from_proto(abilities)
49
+ result = {}
50
+
51
+ ability_ids = Api::AbilityId.constants.map { |c| Api::AbilityId.const_get(c) }
52
+ abilities.each do |a|
53
+ next if a.ability_id.zero?
54
+ next if ability_ids.delete(a.ability_id).nil?
55
+
56
+ result[a.ability_id] = a
57
+ end
58
+ result
59
+ end
60
+
61
+ # Indexes unit data by id
62
+ # @param units [Array<Api::UnitTypeData>]
63
+ # @return [Hash<Integer, Api::UnitTypeData] indexed data
64
+ def units_from_proto(units)
65
+ result = {}
66
+ units.each do |u|
67
+ next unless u.available
68
+
69
+ result[u.unit_id] = u
70
+ end
71
+ result
72
+ end
73
+
74
+ # Indexes upgrades data by id
75
+ # @param upgrades [Array<Api::UpgradeData>]
76
+ # @return [Hash<Integer, Api::UpgradeData] indexed data
77
+ def upgrades_from_proto(upgrades)
78
+ result = {}
79
+ upgrades.each do |u|
80
+ result[u.upgrade_id] = u
81
+ end
82
+ result
83
+ end
84
+
85
+ def effects_from_proto(effects)
86
+ result = {}
87
+ effects.each do |e|
88
+ result[e.effect_id] = e
89
+ end
90
+ result
91
+ end
92
+
93
+ def buffs_from_proto(buffs)
94
+ result = {}
95
+ buffs.each do |b|
96
+ result[b.buff_id] = b
97
+ end
98
+ result
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,20 @@
1
+ # Generated from stableid.json, do not edit.
2
+
3
+ module Api
4
+ # Constant reference of Effect ids
5
+ module EffectId
6
+ NULL = 0
7
+ PSISTORMPERSISTENT = 1
8
+ GUARDIANSHIELDPERSISTENT = 2
9
+ TEMPORALFIELDGROWINGBUBBLECREATEPERSISTENT = 3
10
+ TEMPORALFIELDAFTERBUBBLECREATEPERSISTENT = 4
11
+ THERMALLANCESFORWARD = 5
12
+ SCANNERSWEEP = 6
13
+ NUKEPERSISTENT = 7
14
+ LIBERATORTARGETMORPHDELAYPERSISTENT = 8
15
+ LIBERATORTARGETMORPHPERSISTENT = 9
16
+ BLINDINGCLOUDCP = 10
17
+ RAVAGERCORROSIVEBILECP = 11
18
+ LURKERMP = 12
19
+ end
20
+ end
@@ -0,0 +1,83 @@
1
+ require_relative "tech_tree_data"
2
+
3
+
4
+ module Api
5
+ # Provides helper functions which work with and rely on auto generated data in tech_tree_data.rb
6
+ # To lighten code generation, these methods live in a file of their own and may be modified.
7
+ module TechTree
8
+ class << self
9
+ # Get units can be created at source + the ability to trigger it. Optionally target a specific unit from source
10
+ # @example
11
+ # # The data we reference looks like this, unit_type_creation_abilities_data
12
+ # UnitTypeId.FACTORY: {
13
+ # UnitTypeId.CYCLONE: {
14
+ # 'ability': AbilityId.TRAIN_CYCLONE,
15
+ # 'requires_techlab': True
16
+ # },
17
+ # UnitTypeId.HELLION: {
18
+ # 'ability': AbilityId.FACTORYTRAIN_HELLION
19
+ # },
20
+ #
21
+ # Targeting only a source, i.e. factory, your results are all units
22
+ # {
23
+ # UnitTypeId.CYCLONE: {
24
+ # 'ability': AbilityId.TRAIN_CYCLONE,
25
+ # 'requires_techlab': True
26
+ # },
27
+ # UnitTypeId.HELLION: {
28
+ # 'ability': AbilityId.FACTORYTRAIN_HELLION
29
+ # },...
30
+ # }
31
+ #
32
+ # To get the requirements, you could call a source and target like such
33
+ # Api::TechTree.unit_type_creation_abilities(source: ..., target: ... )
34
+ # {
35
+ # "ability" => 123
36
+ # "requires_techlab" => true
37
+ # "required_building" => 456
38
+ # }
39
+ # @param source [Integer] Api::UnitTypeId the unit type which will do the creation
40
+ # @param target [Integer] (optional) Api::UnitTypeId the unit type which will be created
41
+ # @return [Hash] either a hash of [UnitTypeId] => { ability hash } or { ability hash } when target is present
42
+ def unit_type_creation_abilities(source:, target: nil)
43
+ creates_unit_types = unit_type_creation_abilities_data[source]
44
+ unless target.nil?
45
+ return creates_unit_types[target]
46
+ end
47
+ creates_unit_types
48
+ end
49
+
50
+ # Which ability id creates the target, given the source unit/building
51
+ # @see Api::TechTree#unit_type_creation_abilities to get a full list of units and their creation abilities
52
+ # @param source [Integer] Api::UnitTypeId the unit type which will do the creation
53
+ # @param target [Integer] (optional) Api::UnitTypeId the unit type which will be created
54
+ # @return [Integer, nil] AbilityId or nil if target is not found at source
55
+ def unit_type_creation_ability_id(source:, target:)
56
+ ability_hash = unit_type_creation_abilities(source: source, target: target)
57
+ return ability_hash[:ability] if ability_hash && ability_hash[:ability]
58
+ nil
59
+ end
60
+
61
+ # Returns what unit types a specific unit type can produce
62
+ # @param unit_type_id [Integer] the unit which you want to check
63
+ # @return [Array<Integer>] returns an array of unit type ids as per Api:UnitTypeId
64
+ def creates_unit_types(unit_type_id:)
65
+ unit_type_creation_abilities_data[unit_type_id].keys
66
+ end
67
+
68
+ # Returns what the unit type another is created from
69
+ # @param unit_type_id [Integer] the unit which you want to check
70
+ # @return [Array<Integer>] returns an array of unit type ids as per Api:UnitTypeId
71
+ def unit_created_from(unit_type_id:)
72
+ unit_created_from_data[unit_type_id]
73
+ end
74
+
75
+ # Returns what the unit type an upgrade is researched from
76
+ # @param upgrade_id [Integer] the unit which you want to check
77
+ # @return [Integer] unit_type_id an array of unit type ids as per Api:UnitTypeId
78
+ def upgrade_researched_from(upgrade_id:)
79
+ upgrade_researched_from_data[upgrade_id]
80
+ end
81
+ end
82
+ end
83
+ end