summary refs log tree commit diff stats
path: root/cards_filter.rb
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-11-04 20:42:36 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2024-11-04 20:42:36 -0500
commit4bc851544831e37b6173d0ad05806fd841e216fb (patch)
treed6470fdb41fa6d9a87dd0a937c34d50af5529c35 /cards_filter.rb
parentb5cc6373fbfe2db20bb14216242c2c56f9bfbafe (diff)
downloadwizard-4bc851544831e37b6173d0ad05806fd841e216fb.tar.gz
wizard-4bc851544831e37b6173d0ad05806fd841e216fb.tar.bz2
wizard-4bc851544831e37b6173d0ad05806fd841e216fb.zip
Re-attempt 10 times, some tweaks to OCR, pre-filter card pool HEAD main
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