 fs = require 'fs'
 webpage = require 'webpage'
+
+# XXX split cards (eg Fire // Ice) need massaging
 
 sets = [
   'Gatecrash'

  'Unlimited Edition'
  'Limited Edition Beta'
  'Limited Edition Alpha'
]

Sets = {}

  if set = sets.pop()
    scrape set
  else
    # WTF
    od = sets.Odyssey.Rare
    bad = 'XXCall of the Herd (Call of the Herd)'
    good = 'Call of the Herd'
    i = od.indexOf(bad)
    if ~i
      od[i] = good
      Cards[good] = Cards[bad]
      Cards[good].name = good
      delete Cards[bad]

    fs.write 'cards/sets.json' , JSON.stringify(Sets) , 'w'
    fs.write 'cards/cards.json', JSON.stringify(Cards), 'w'
    phantom.exit()
