pull/11/head
Daniel Asher Resnick 2 years ago
parent 5091396638
commit f5d94d1d67
  1. 1
      src/lib/data.rb
  2. 55
      src/lib/data/custom.rb

@ -63,5 +63,6 @@ module Charred
def json_get(filename) def json_get(filename)
JSON.parse(File.read(filename)) JSON.parse(File.read(filename))
end
end end
end end

@ -3,29 +3,46 @@ require 'json'
module Charred module Charred
module Custom module Custom
def load_custom(data) def load_custom(data)
Dir.glob("data/custom/*/") { |dir| Dir.glob("data/custom/**/*") { |file|
stock_name = File.basename(dir) if File.file?(file)
case File.extname(file)
if File.readable?("dir/skills.json") when "skills"
skills = json_get("dir/skills.json") verbose_merge data[:skills], json_get(file)
verbose_merge data[:skills], skills when "traits"
verbose_merge data[:traits], json_get(file)
when "stock"
stock = Stock.new(json_get(file))
data[:stocks][stock.key] = stock # This overwrites existing data...
when "lifepaths"
#
when "resources"
#
end
end end
}
# Dir.glob("data/custom/*/") { |dir|
# stock_name = File.basename(dir)
if File.readable?("dir/traits.json") # if File.readable?("dir/skills.json")
traits = json_get("dir/traits.json") # skills = json_get("dir/skills.json")
verbose_merge data[:traits], traits # verbose_merge data[:skills], skills
end # end
if File.readable?("dir/lifepaths.json") # if File.readable?("dir/traits.json")
lifepaths = json_get("dir/lifepaths.json") # traits = json_get("dir/traits.json")
data[:lifepaths][stock_name] = lifepaths # verbose_merge data[:traits], traits
end # end
if File.readable?("dir/resources.json") # if File.readable?("dir/lifepaths.json")
resources = json_get("dir/resources.json") # lifepaths = json_get("dir/lifepaths.json")
data[:resources][stock_name] = resources # data[:lifepaths][stock_name] = lifepaths
end # end
}
# if File.readable?("dir/resources.json")
# resources = json_get("dir/resources.json")
# data[:resources][stock_name] = resources
# end
# }
end end
end end
end end

Loading…
Cancel
Save