--MJTS-140914 
--Zz_MjTs_StadiumPack_zZ

local fileroot = ".\\Data\\MjTs-140914\\ms_demo"
local tid

function set_tournament_id(ctx, tournament_id)
    tid = tournament_id or nil
    return tournament_id
end

local function make_key(ctx, filename)
  if ctx.stadium == 1 then
     MjTs_Data = "Giuzepe Meaza"
  elseif ctx.stadium == 2 then
   	 MjTs_Data = "Camp Nou"
  elseif ctx.stadium == 4 then
   	 MjTs_Data = "Anfield Road"
  elseif ctx.stadium == 5 then
   	 MjTs_Data = "Wembley Stadium"
  elseif ctx.stadium == 6 then
   	 MjTs_Data = "Olympico" 
  elseif ctx.stadium == 7 then
   	 MjTs_Data = "Old Traford"
  elseif ctx.stadium == 8 then
     MjTs_Data = "Estadio Da Luz"
  elseif ctx.stadium == 9 then
     MjTs_Data = "Stamford"
  elseif ctx.stadium == 10 then
     MjTs_Data = "Parc De Princes"
  elseif ctx.stadium == 34 then
     MjTs_Data = "Alliaz Arena"
  elseif ctx.stadium == 32 then
     MjTs_Data = "Etihad"
  elseif ctx.stadium == 14 then
     MjTs_Data = "Morumbi"
  elseif ctx.stadium == 15 then
     MjTs_Data = "Emirates Stadium"
  elseif ctx.stadium == 19 then
     MjTs_Data = "Bernabeu"
  elseif ctx.stadium == 22 then
     MjTs_Data = "Allianz Stadium"
  elseif ctx.stadium == 24 then
     MjTs_Data = "Maracana"
  elseif ctx.stadium == 30 then
     MjTs_Data = "San Siro"
  elseif ctx.stadium == 56 then
     MjTs_Data = "Wanda"
  elseif ctx.stadium == 21 then
     MjTs_Data = "San Paolo"
  elseif ctx.stadium == 12 then
     MjTs_Data = "Stade France"
  elseif ctx.stadium == 51 then
     MjTs_Data = "Signal Iduna Park"
  else
     MjTs_Data = nil
  end
    if tid then
        return string.format("%s:%s", MjTs_Data, filename)
    end
  end

local function get_filepath(ctx, filename, key)
    if tid then
        return string.format("%s\\%s\\%s", fileroot, MjTs_Data, filename)
    end
end

local function init(ctx)
    if fileroot:sub(1,1)=='.' then
        fileroot = ctx.sider_dir .. fileroot
    end
    ctx.register("set_tournament_id", set_tournament_id)
    ctx.register("livecpk_make_key", make_key)
    ctx.register("livecpk_get_filepath", get_filepath)
end

return { init = init }