about summary refs log tree commit diff stats
path: root/util/generate_gamedata.rb
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-04-16 16:09:37 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-04-16 16:09:37 -0400
commit7aa62e5c0ac0d86e5aed2ead2a7116ea0edbffde (patch)
tree2e35e9166e01ead9e0bdddb1db9c3a18a2fa6266 /util/generate_gamedata.rb
parent36eee0423e7f29e352c9c44d0ebb592007ec7436 (diff)
downloadlingo-archipelago-7aa62e5c0ac0d86e5aed2ead2a7116ea0edbffde.tar.gz
lingo-archipelago-7aa62e5c0ac0d86e5aed2ead2a7116ea0edbffde.tar.bz2
lingo-archipelago-7aa62e5c0ac0d86e5aed2ead2a7116ea0edbffde.zip
Implemented color shuffle
Diffstat (limited to 'util/generate_gamedata.rb')
-rw-r--r--util/generate_gamedata.rb37
1 files changed, 37 insertions, 0 deletions
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 @@
1require 'yaml'
2
3configpath = ARGV[0]
4outputpath = ARGV[1]
5
6config = YAML.load_file(configpath)
7output = config.map do |panel|
8 ret = panel
9 if ret["color"].kind_of? String
10 ret["color"] = [ret["color"]]
11 end
12 ret
13end.map do |panel|
14 ret = {}
15 ret["id"] = "\"#{panel["id"]}\""
16 ret["color"] = "[\"" + panel["color"].join("\",\"") + "\"]"
17 ret["tag"] = "\"#{panel["tag"]}\""
18 if panel.include? "subtag"
19 ret["subtag"] = "\"#{panel["subtag"]}\""
20 end
21 if panel.include? "link"
22 ret["link"] = "\"#{panel["link"]}\""
23 end
24 if panel.include? "copy_to_sign"
25 ret["copy_to_sign"] = "\"#{panel["copy_to_sign"]}\""
26 end
27 ret
28end.map do |panel|
29 "{" + panel.to_a.map do |element|
30 "\"#{element[0]}\":#{element[1]}"
31 end.join(",") + "}"
32end.join(",")
33
34header = "extends Node\n\nvar panels = ["
35footer = "]"
36
37File.write(outputpath, header + output + footer) \ No newline at end of file