diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-11-04 20:42:36 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-11-04 20:42:36 -0500 |
| commit | 4bc851544831e37b6173d0ad05806fd841e216fb (patch) | |
| tree | d6470fdb41fa6d9a87dd0a937c34d50af5529c35 /cards_filter.rb | |
| parent | b5cc6373fbfe2db20bb14216242c2c56f9bfbafe (diff) | |
| download | wizard-main.tar.gz wizard-main.tar.bz2 wizard-main.zip | |
Diffstat (limited to 'cards_filter.rb')
| -rw-r--r-- | cards_filter.rb | 41 |
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 @@ | |||
| 1 | require 'json' | ||
| 2 | |||
| 3 | input = File.open(ARGV[0]) do |file| | ||
| 4 | JSON.load(file) | ||
| 5 | end | ||
| 6 | |||
| 7 | filtered = 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" | ||
| 29 | end.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 | } | ||
| 37 | end | ||
| 38 | |||
| 39 | File.open(ARGV[1], 'w') do |file| | ||
| 40 | JSON.dump(filtered, file) | ||
| 41 | end | ||
