From 7aa62e5c0ac0d86e5aed2ead2a7116ea0edbffde Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 16 Apr 2023 16:09:37 -0400 Subject: Implemented color shuffle --- util/generate_gamedata.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 util/generate_gamedata.rb (limited to 'util/generate_gamedata.rb') diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb new file mode 100644 index 0000000..7f4216f --- /dev/null +++ b/util/generate_gamedata.rb @@ -0,0 +1,37 @@ +require 'yaml' + +configpath = ARGV[0] +outputpath = ARGV[1] + +config = YAML.load_file(configpath) +output = config.map do |panel| + ret = panel + if ret["color"].kind_of? String + ret["color"] = [ret["color"]] + end + ret +end.map do |panel| + ret = {} + ret["id"] = "\"#{panel["id"]}\"" + ret["color"] = "[\"" + panel["color"].join("\",\"") + "\"]" + ret["tag"] = "\"#{panel["tag"]}\"" + if panel.include? "subtag" + ret["subtag"] = "\"#{panel["subtag"]}\"" + end + if panel.include? "link" + ret["link"] = "\"#{panel["link"]}\"" + end + if panel.include? "copy_to_sign" + ret["copy_to_sign"] = "\"#{panel["copy_to_sign"]}\"" + end + ret +end.map do |panel| + "{" + panel.to_a.map do |element| + "\"#{element[0]}\":#{element[1]}" + end.join(",") + "}" +end.join(",") + +header = "extends Node\n\nvar panels = [" +footer = "]" + +File.write(outputpath, header + output + footer) \ No newline at end of file -- cgit 1.4.1