Created
November 29, 2016 18:19
-
-
Save Random-Stack-Random-Day/a802a3c785acd9b2810345eeab4dfa11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :cards do | |
desc "Create cards" | |
task :create_cards => :environment do | |
cards = MTG::Card.all | |
cards.each do |card| | |
puts card.name + '-' + card.set | |
card.image_url.blank? ? image_url = "/assets/mtgCardBack.jpg" : image_url = card.image_url | |
card.legalities each do |x| | |
y = [] | |
y << {x.format => x.legality} | |
end | |
Card.create(name: card.name, | |
multiverse_id: card.multiverse_id, | |
manaCost: card.mana_cost, | |
colors: card.colors, | |
cmc: card.cmc, | |
cardtype: card.type, | |
rarity: card.rarity, | |
set: card.set, | |
setName: card.set_name, | |
text: card.text, | |
flavor: card.flavor, | |
artist: card.artist, | |
number: card.number, | |
power: card.power, | |
toughness: card.toughness, | |
layout: card.layout, | |
image_url: image_url, | |
watermark: card.watermark, | |
original_text: card.original_text, | |
original_type: card.original_type, | |
rulings: card.rulings, | |
legalities: y, | |
#legalities: | |
foreign: card.foreign_names | |
) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"[{"Commander"=>"Legal"}, {"Khans of Tarkir Block"=>"Legal"}, {"Legacy"=>"Legal"}, {"Modern"=>"Legal"}, {"Vintage"=>"Legal"}]"