Actually implement custom stock loading...

pull/11/head
Daniel Asher Resnick 2 years ago
parent 48cda4860a
commit 0b3e725c85
  1. 63
      src/lib/data/custom.rb

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

Loading…
Cancel
Save