Skip to content

rmosolgo/mtg_rb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MtgRb

Card objects from MTGJSON

Normalize MTGJSON into a coherent, normalized Ruby object tree.

mtg_json_path = File.expand_path("../path/to/AllSets-x.json", __FILE__)
mtg_json_hash = JSON.parse(File.read(mtg_json_path))
MULTIVERSE = MtgRb::Multiverse.from_hash(mtg_json_hash)
MULTIVERSE.expansions["Conflux"] # => Expansion instance
MULTIVERSE.cards["Icy Manipulator"] # => Card instance

Card and Expansion are joined by Printing.

Manipulate scans

There are places you can get zips of high-quality MTG scans. You can unzip them and write them to new files.

MtgRb::Scans::Migrate.execute(
  # this directory contains `**/ENG*.zip` files of of scans
  from_dir: "~/Downloads/mtg_scans",
  # optional whitelist expansions, defaults to all expansions
  expansion_codes: ["ALA", "CON", "ARB"],
) do |expansion_code, name, entry|
  # This block gets called with each card.
  #
  # In the case of split cards,
  # the block will be called twice with the same entry
  #
  # `entry` is a Zip::Entry from "rubyzip"
  entry.expand("#{expansion_code}/#{name}.jpg")
end

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published