summary refs log tree commit diff stats
path: root/cards_filter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'cards_filter.rb')
-rw-r--r--cards_filter.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/cards_filter.rb b/cards_filter.rb new file mode 100644 index 0000000..aba66e3 --- /dev/null +++ b/cards_filter.rb
@@ -0,0 +1,41 @@
1require 'json'
2
3input = File.open(ARGV[0]) do |file|
4 JSON.load(file)
5end
6
7filtered = input.select do |cardJson|
8 cardJson["object"] == "card" &&
9 # It needs to have a downloadable image
10 cardJson.count("image_uris") &&
11 # Make sure we can support the card layout
12 ["normal", "leveler", "saga"].include?(cardJson["layout"]) &&
13 # We only support modern and m15 frames
14 ["2015", "2003"].include?(cardJson["frame"]) &&
15 # Digital cards look slightly different so ignore them
16 !cardJson["digital"] &&
17 # Only use english printings
18 cardJson["lang"] == "en" &&
19 # Currently not supporting silver bordered cards
20 cardJson["border_color"] != "silver" &&
21 # It is hard to read the name of a planeswalker
22 !cardJson["type_line"].include?("Planeswalker") &&
23 # This cuts out checklists and special tokens
24 cardJson["type_line"] != "Card" &&
25 # Amonkhet invocations are impossible
26 cardJson["set"] != "mp2" &&
27 # Unknown Event is not a real thing huh
28 cardJson["set"] != "da1"
29end.map do |cardJson|
30 {
31 "id" => cardJson["id"],
32 "name" => cardJson["name"],
33 "imageUri" => cardJson["image_uris"]["png"],
34 "frame" => cardJson["frame"],
35 "artist" => cardJson["artist"]
36 }
37end
38
39File.open(ARGV[1], 'w') do |file|
40 JSON.dump(filtered, file)
41end