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/extract_panels.rb | 14 ++++++++++++++ util/generate_gamedata.rb | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 util/extract_panels.rb create mode 100644 util/generate_gamedata.rb (limited to 'util') diff --git a/util/extract_panels.rb b/util/extract_panels.rb new file mode 100644 index 0000000..d524f6e --- /dev/null +++ b/util/extract_panels.rb @@ -0,0 +1,14 @@ +require 'yaml' + +mappath = ARGV[0] +outputpath = ARGV[1] + +panels = [] + +File.readlines(mappath).each do |line| + line.match(/node name=\"(.*)\" parent=\"Panels\/(.*)\" instance/) do |m| + panels << {"id" => m[2] + "/" + m[1]} + end +end + +File.write(outputpath, panels.to_yaml) 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