tormenta20 0.2.7 → 0.2.9

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: 6b2140b8b04d8ee15caca2700f3adb40d350209b10477f852cb86336e9c5d60e
4
- data.tar.gz: 150b76780f6b14e17e6c1883d5c7d3467e9ba73fd1e60a7562be6d284d3c890b
3
+ metadata.gz: d1b98f4734af48a9e6fc4e34b0b36e20f6341138f52ab2893fd5bef241296719
4
+ data.tar.gz: 6a4a8e722d23d3addc71ae256e3ea7e259f43e6e43905fb0405fd3155bd64217
5
5
  SHA512:
6
- metadata.gz: 22d9ecdf602bcd12b0821119914208451aab3a4eb8ae9848f79b0cca281ab070b3eec35ebb19fbef11fb880f2b61e51a3646cfb86b45cee7ca9a3b6fff7b7690
7
- data.tar.gz: a94f9b5d9aa7eac2145409ff8e60f051aee15dd8bf43f5338bb7651bd5448ac0a766761c51b60e07489de9d5e50aff1b8305a65b82fcf6f36da2285b7af53871
6
+ metadata.gz: 84016ffbdc3b37c630165570215a33c426728c1b7dd94b9ed31ea00d4cbec3d61a95213cdcc8ed0339b9f1cbe15b93d14acddba71edd20359b3f995c7f1a1578
7
+ data.tar.gz: 5f2e29cc1c0d8cf1e750d27574fdaefd61d7e43572dca85783a385a8183a48c3e320226f912c4c749d0dba70309ed587901236c30d3fb4707887ef1088f23f26
data/db/schema.sql CHANGED
@@ -45,7 +45,8 @@ CREATE TABLE IF NOT EXISTS poderes (
45
45
  'poder_magia'
46
46
  )),
47
47
  description TEXT,
48
- effects JSON DEFAULT '{}',
48
+ effects JSON DEFAULT '[]',
49
+ costs JSON DEFAULT '[]',
49
50
  prerequisites JSON DEFAULT '[]',
50
51
  origin_id TEXT,
51
52
  class_id TEXT,
data/db/seeds.rb CHANGED
@@ -30,6 +30,7 @@ module Tormenta20
30
30
  import_divindades
31
31
  import_poderes_concedidos
32
32
  import_poderes_tormenta
33
+ import_poderes_gerais
33
34
  import_classes
34
35
  import_magias
35
36
  import_equipamentos
@@ -104,6 +105,44 @@ module Tormenta20
104
105
  )
105
106
  end
106
107
 
108
+ # =======================================================================
109
+ # PODERES GERAIS (combate, destino, magia)
110
+ # =======================================================================
111
+ def import_poderes_gerais
112
+ puts "\nImporting poderes_gerais..."
113
+
114
+ json_dir = File.join(JSON_BASE_PATH, "poderes/poderes_gerais")
115
+ return puts " Directory not found: #{json_dir}" unless Dir.exist?(json_dir)
116
+
117
+ files = Dir.glob(File.join(json_dir, "**", "*.json"))
118
+ puts " Found #{files.size} files"
119
+
120
+ success_count = 0
121
+ error_count = 0
122
+
123
+ files.each_with_index do |file, index|
124
+ data = JSON.parse(File.read(file), symbolize_names: true)
125
+
126
+ record = Models::Poder.find_or_initialize_by(id: data[:id])
127
+ record.name = data[:name]
128
+ record.type = data[:type]
129
+ record.description = data[:description]
130
+ record.effects = data[:effects] || []
131
+ record.costs = data[:costs] || []
132
+ record.prerequisites = data[:requirements] || []
133
+ record.save!
134
+
135
+ success_count += 1
136
+ print "\r Imported: #{index + 1}/#{files.size}" if ((index + 1) % 10).zero?
137
+ rescue StandardError => e
138
+ error_count += 1
139
+ puts "\n Error importing #{File.basename(file)}: #{e.message}"
140
+ end
141
+
142
+ puts "\n Successfully imported #{success_count} poderes_gerais"
143
+ puts " Failed to import #{error_count} poderes_gerais" if error_count.positive?
144
+ end
145
+
107
146
  # =======================================================================
108
147
  # CLASSES
109
148
  # =======================================================================
@@ -124,7 +163,7 @@ module Tormenta20
124
163
  json_dir = File.join(JSON_BASE_PATH, "magias")
125
164
  return puts " Directory not found: #{json_dir}" unless Dir.exist?(json_dir)
126
165
 
127
- files = Dir.glob(File.join(json_dir, "*.json"))
166
+ files = Dir.glob(File.join(json_dir, "**", "*.json"))
128
167
  puts " Found #{files.size} magia files"
129
168
 
130
169
  success_count = 0
@@ -210,11 +249,29 @@ module Tormenta20
210
249
  import_itens
211
250
  end
212
251
 
252
+ PROFICIENCIA_TO_CATEGORY = {
253
+ "simples" => "simples",
254
+ "marcial" => "marciais",
255
+ "exotica" => "exoticas",
256
+ "fogo" => "fogo"
257
+ }.freeze
258
+
213
259
  def import_armas
214
260
  import_json_files(
215
261
  "equipamentos/armas",
216
262
  Models::Arma,
217
- %i[id name category price damage damage_type critical range weight properties description]
263
+ %i[id name category price damage damage_type critical range weight properties description],
264
+ transform: lambda { |data|
265
+ data[:category] ||= PROFICIENCIA_TO_CATEGORY[data.delete(:proficiencia).to_s]
266
+ data[:price] ||= data.delete(:preco)
267
+ data[:damage] ||= data.delete(:dano)
268
+ data[:damage_type] ||= data.delete(:tipo_dano)
269
+ data[:critical] ||= data.delete(:critico)
270
+ data[:range] ||= data.delete(:alcance)
271
+ data[:weight] ||= data.delete(:espacos)
272
+ data[:properties] ||= [data.delete(:habilidades), data.delete(:especial)].flatten.compact
273
+ data
274
+ }
218
275
  )
219
276
  end
220
277
 
@@ -222,7 +279,16 @@ module Tormenta20
222
279
  import_json_files(
223
280
  "equipamentos/armaduras",
224
281
  Models::Armadura,
225
- %i[id name category price defense_bonus armor_penalty weight properties description]
282
+ %i[id name category price defense_bonus armor_penalty weight properties description],
283
+ transform: lambda { |data|
284
+ data[:category] ||= data.delete(:categoria)
285
+ data[:price] ||= data.delete(:preco)
286
+ data[:defense_bonus] ||= data.delete(:bonus_defesa)
287
+ data[:armor_penalty] ||= data.delete(:penalidade_armadura)
288
+ data[:weight] ||= data.delete(:espacos)
289
+ data[:properties] ||= [data.delete(:especial)].flatten.compact
290
+ data
291
+ }
226
292
  )
227
293
  end
228
294
 
@@ -245,7 +311,13 @@ module Tormenta20
245
311
  import_json_files(
246
312
  "equipamentos/itens",
247
313
  Models::Item,
248
- %i[id name category price weight description effects]
314
+ %i[id name category price weight description effects],
315
+ transform: lambda { |data|
316
+ data[:category] ||= data.delete(:categoria)
317
+ data[:price] ||= data.delete(:preco)
318
+ data[:weight] ||= data.delete(:espacos)
319
+ data
320
+ }
249
321
  )
250
322
  end
251
323
 
@@ -335,7 +407,7 @@ module Tormenta20
335
407
  return
336
408
  end
337
409
 
338
- files = Dir.glob(File.join(json_dir, "*.json"))
410
+ files = Dir.glob(File.join(json_dir, "**", "*.json"))
339
411
  puts " Found #{files.size} files"
340
412
 
341
413
  return if files.empty?
Binary file
@@ -19,6 +19,7 @@ module Tormenta20
19
19
  seed_divindades
20
20
  seed_poderes_concedidos
21
21
  seed_poderes_tormenta
22
+ seed_poderes_gerais
22
23
  seed_classes
23
24
  seed_habilidades_de_classe
24
25
  seed_magias
@@ -125,6 +126,27 @@ module Tormenta20
125
126
  )
126
127
  end
127
128
 
129
+ def seed_poderes_gerais
130
+ base_dir = File.join(JSON_BASE_PATH, "poderes", "poderes_gerais")
131
+ return unless Dir.exist?(base_dir)
132
+
133
+ Dir.glob(File.join(base_dir, "**", "*.json")).each do |file|
134
+ data = JSON.parse(File.read(file), symbolize_names: true)
135
+ next if data[:id].nil?
136
+
137
+ record = Models::Poder.find_or_initialize_by(id: data[:id])
138
+ record.name = data[:name] || data[:id].to_s.humanize
139
+ record.type = data[:type] || "poder_geral"
140
+ record.description = data[:description]
141
+ record.effects = data[:effects] || []
142
+ record.costs = data[:costs] || []
143
+ record.prerequisites = data[:requirements] || []
144
+ record.save!
145
+ rescue StandardError
146
+ next
147
+ end
148
+ end
149
+
128
150
  def seed_classes
129
151
  import_json_files(
130
152
  "classes",
@@ -154,6 +176,7 @@ module Tormenta20
154
176
  record.class_id = class_id
155
177
  record.description = data[:description]
156
178
  record.effects = data[:effects] || []
179
+ record.costs = data[:costs] || []
157
180
  record.prerequisites = data[:requirements] || []
158
181
  record.save!
159
182
  rescue StandardError
@@ -341,3 +364,4 @@ module Tormenta20
341
364
  end
342
365
  end
343
366
  end
367
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tormenta20
4
- VERSION = "0.2.7"
4
+ VERSION = "0.2.9"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tormenta20
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - LuanGB