Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: e023251e9d
Fetching contributors…

Cannot retrieve contributors at this time

file 45 lines (44 sloc) 1.319 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
id_to_canonical_card = {}
name_to_ids = {}

function cards_init()
  local file = love.filesystem.newFile("swogi.json")
  file:open("r")
  local teh_json = file:read(file:getSize())
  decoded = json.decode(teh_json)
  decoded.id_to_card.ID = nil
  decoded.name_to_ids.NAME = nil
  decoded.name_to_ids["KR NAME"] = nil
  cards = decoded.id_to_card
  for id,in_card in pairs(cards) do
    id = id + 0
    print("LOADING "..id)
    card = {}
    id_to_canonical_card[id] = card
    card.type = in_card.type:lower()
    card.faction = in_card.faction[1]
    card.name = in_card.name
    card.id = in_card.id + 0
    if card.type == "follower" then
      card.atk = in_card.attack + 0
      card.def = in_card.defense + 0
      card.sta = in_card.stamina + 0
      card.size = in_card.size + 0
    elseif card.type == "spell" then
      card.size = in_card.size + 0
    elseif card.type == "character" then
      card.life = in_card.life + 0
    else
      print("Got card "..in_card.name.." with id "..in_card.id..
        " and unexpected type "..card.type)
    end
  end
  for name,ids in pairs(decoded.name_to_ids) do
    for i=1,#ids do
      ids[i] = ids[i] + 0
    end
  end
  for id,skills in pairs(decoded.id_to_skills) do
    id_to_canonical_card[id+0].skills = skills
  end
  name_to_ids = decoded.name_to_ids
end
Something went wrong with that request. Please try again.