--MJTS-140914 
--PTE 6.5.3

local fileroot = ".\\Data\\MjTs-140914\\ms_data"
local inifile = ".\\modules\\ms_settings.ini"
local tid

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

local function pte_patch_653(ctx)
	if tid == 39 then
	   MjTs_Data = "Premier League"
  	elseif tid == 72 then
	    MjTs_Data = "Bundes Liga"
  	elseif tid == 40 then
	    MjTs_Data = "SkyBET Championship"
  	elseif tid == 43 then
	    MjTs_Data = "Laliga Santander"
  	elseif tid == 44 then
	    MjTs_Data = "Laliga 123"
  	elseif tid == 48 then
	    MjTs_Data = "Serie BKT"
   	elseif tid == 51 then
	    MjTs_Data = "Ligue 1"
  	elseif tid == 54 then
	   MjTs_Data = "Liga NOS"
  	elseif tid == 47 then
	    MjTs_Data = "Serie A"
	elseif tid == 77 then
	   MjTs_Data = "Gojek Liga1"
  	elseif tid == 85 then
	    MjTs_Data = "Copa Del Rey"
  	elseif tid == 86 then
	   MjTs_Data = "Tim CUP"
  	elseif tid == 120 or tid == 122 or tid == 123 or tid == 123 or tid == 124 or tid == 129 or tid == 134 or tid == 135 then
	   MjTs_Data = "World Cup 2018"
  	elseif tid == 145 then
	    MjTs_Data = "Copa America"
  	elseif tid == 138 or tid == 139 then
	    MjTs_Data = "EURO 2020"
  	elseif tid == 84 then
	   MjTs_Data = "The FA CUP"
    elseif tid == 101 then
       MjTs_Data = "The FA Comunnity Shield"
  	elseif tid == 53 then
	    MjTs_Data = "Eredivisie"
    elseif tid == 2 or tid == 19 or tid == 20 then
	    MjTs_Data = "UEL"
    elseif tid == 0 or tid == 83 or tid == 154 or tid == 155 then
		--Premier League
	    if (home == 101 or home == 4071 or home == 377 or home == 378 or home == 379 or home == 102 or home == 382 or home == 177 or home == 178 or home == 2610 or home == 204 or home == 103 or home == 173 or home == 100 or home == 106 or home == 207 or home == 179 or home == 398 or home == 105 or home == 208) and (away == 101 or away == 4071 or away == 377 or away == 378 or away == 379 or away == 102 or away == 382 or away == 177 or away == 178 or away == 2610 or away == 204 or away == 103 or away == 173 or away == 100 or away == 106 or away == 207 or away == 179 or away == 398 or away == 105 or away == 208) then
	       MjTs_Data = "Premier League"
		--SkyBet Championship
		elseif (home == 107 or home == 201 or home == 176 or home == 202 or home == 4180 or home == 1760 or home == 383 or home == 1589 or home == 386 or home == 104 or home == 205 or home == 387 or home == 388 or home == 389 or home == 4192 or home == 1327 or home == 391 or home == 4193 or home == 4194 or home == 394 or home == 395 or home == 1909 or home == 399 or home == 400) and (away == 107 or away == 201 or away == 176 or away == 202 or away == 4180 or away == 1760 or away == 383 or away == 1589 or away == 386 or away == 104 or away == 205 or away == 387 or away == 388 or away == 389 or away == 4192 or away == 1327 or away == 391 or away == 4193 or away == 4194 or away == 394 or away == 395 or away == 1909 or away == 399 or away == 400) then
		 MjTs_Data = "SkyBET Championship"
		--Ligue 1
	    elseif (home == 4200 or home == 403 or home == 115 or home == 405 or home == 1328 or home == 211 or home == 213 or home == 112 or home == 215 or home == 216 or home == 217 or home == 1910 or home == 181 or home == 113 or home == 114 or home == 1330 or home == 218 or home == 418 or home == 4213 or home == 221) and (away == 4200 or away == 403 or away == 115 or away == 405 or away == 1328 or away == 211 or away == 213 or away == 112 or away == 215 or away == 216 or away == 217 or away == 1910 or away == 181 or away == 113 or away == 114 or away == 1330 or away == 218 or away == 418 or away == 4213 or away == 221) then
	        MjTs_Data = "Ligue 1"
		--Serie A
        elseif (home == 234 or home == 186 or home == 320 or home == 188 or home == 235 or home == 124 or home == 4234 or home == 323 or home == 119 or home == 120 or home == 122 or home == 121 or home == 327 or home == 123 or home == 125 or home == 4923 or home == 240 or home == 1919 or home == 333 or home == 190) and (away == 234 or away == 186 or away == 320 or away == 188 or away == 235 or away == 124 or away == 4234 or away == 323 or away == 119 or away == 120 or away == 122 or away == 121 or away == 327 or away == 123 or away == 125 or away == 4923 or away == 240 or away == 1919 or away == 333 or away == 190) then
            MjTs_Data = "Serie A"
		--Serie BKT
		elseif (home == 317 or home == 4232 or home == 187 or home == 4075 or home == 1920 or home == 4925 or home == 4220 or home == 1363 or home == 4929 or home == 336 or home == 236 or home == 325 or home == 2319 or home == 238 or home == 4240 or home == 328 or home == 4244 or home == 1600 or home == 4229) and (away == 317 or away == 4232 or away == 187 or away == 4075 or away == 1920 or away == 4925 or away == 4220 or away == 1363 or away == 4929 or away == 336 or away == 236 or away == 325 or away == 2319 or away == 238 or away == 4240 or away == 328 or away == 4244 or away == 1600 or away == 4229) then
		MjTs_Data = "Serie BKT"
		--Laliga Santander
        elseif (home == 258 or home == 172 or home == 108 or home == 195 or home == 4145 or home == 4146 or home == 259 or home == 362 or home == 2187 or home == 2188 or home == 4272 or home == 366 or home == 370 or home == 194 or home == 109 or home == 196 or home == 266 or home == 265 or home == 110 or home == 267) and (away == 258 or away == 172 or away == 108 or away == 195 or away == 4145 or away == 4146 or away == 259 or away == 362 or away == 2187 or away == 2188 or away == 4272 or away == 366 or away == 370 or away == 194 or away == 109 or away == 196 or away == 266 or away == 265 or away == 110 or away == 267) then
            MjTs_Data = "Laliga Santander"
		--Laliga 123
		elseif (home == 4302 or home == 2393 or home == 357 or home == 4308 or home == 359 or home == 111 or home == 361 or home == 4993 or home == 4288 or home == 1765 or home == 364 or home == 2615 or home == 261 or home == 260 or home == 368 or home == 263 or home == 4994 or home == 4260 or home == 268 or home == 4298 or home == 363 or home == 4147) and (away == 4302 or away == 2393 or away == 357 or away == 4308 or away == 359 or away == 111 or away == 361 or away == 4993 or away == 4288 or away == 1765 or away == 364 or away == 2615 or away == 261 or away == 260 or away == 368 or away == 263 or away == 4994 or away == 4260 or away == 268 or away == 4298 or away == 363 or away == 4147) then
		 MjTs_Data = "Laliga 123"
		--Liga Nos
        elseif (home == 2382 or home == 1973 or home == 191 or home == 4323 or home == 1974 or home == 4085 or home == 2385 or home == 1976 or home == 2388 or home == 1944 or home == 192 or home == 2369 or home == 1979 or home == 5020 or home == 193 or home == 2614 or home == 1804 or home == 1981) and (away == 2382 or away == 1973 or away == 191 or away == 4323 or away == 1974 or away == 4085 or away == 2385 or away == 1976 or away == 2388 or away == 1944 or away == 192 or away == 2369 or away == 1979 or away == 5020 or away == 193 or away == 2614 or away == 1804 or away == 1981) then
            MjTs_Data = "Liga NOS"
		--Bundes Liga
	   elseif (home == 2300 or home == 127 or home == 126 or home == 2293 or home == 2298 or home == 2347 or home == 431 or home == 2345 or home == 2346 or home == 2349 or home == 5010 or home == 128 or home == 2355 or home == 437 or home == 184 or home == 2352 or home == 2348 or home == 2353) and (away == 2300 or away == 127 or away == 126 or away == 2293 or away == 2298 or away == 2347 or away == 431 or away == 2345 or away == 2346 or away == 2349 or away == 5010 or away == 128 or away == 2355 or away == 437 or away == 184 or away == 2352 or away == 2348 or away == 2353) then
     	    MjTs_Data = "Bundes Liga"
		--Eredevisie
     	elseif (home == 243 or home == 116 or home == 242 or home == 339 or home == 342 or home == 344 or home == 117 or home == 1599 or home == 244 or home == 245 or home == 349 or home == 246 or home == 256 or home == 118 or home == 251 or home == 355 or home == 252 or home == 255) and (away == 243 or away == 116 or away == 242 or away == 339 or away == 342 or away == 344 or away == 117 or away == 1599 or away == 244 or away == 245 or away == 349 or away == 246 or away == 256 or away == 118 or away == 251 or away == 355 or away == 252 or away == 255) then
     	  MjTs_Data = "Eredivisie" 	
        --National Team
        elseif (home == 1165 or home == 21 or home == 9 or home == 1170 or home == 27 or home == 24 or home == 13 or home == 15 or home == 5 or home == 8 or home == 14 or home == 28 or home == 22 or home == 1175 or home == 1 or home == 1164 or home == 12 or home == 10 or home == 2 or home == 16 or home == 19 or home == 6 or home == 26 or home == 31 or home == 3 or home == 1550 or home == 20 or home == 23 or home == 7 or home == 17 or home == 11 or home == 29 or home == 30 or home == 4 or home == 1040 or home == 1044 or home == 36 or home == 1051 or home == 34 or home == 1058 or home == 1059 or home == 1067 or home == 32 or home == 35 or home == 38 or home == 37 or home == 33 or home == 1083 or home == 42 or home == 43 or home == 41 or home == 40 or home == 1113 or home == 39 or home == 50 or home == 1128 or home == 45 or home == 47 or home == 44 or home == 51 or home == 48 or home == 46 or home == 49 or home == 1129 or home == 57 or home == 54 or home == 55 or home == 4025 or home == 1010 or home == 52 or home == 1011 or home == 1012 or home == 1013 or home == 1015 or home == 4020 or home == 1022 or home == 1026 or home == 53 or home == 56 or home == 1031 or home == 1032 or home == 1184 or home == 1141 or home == 4021 or home == 91420 or home == 107304 or home == 107307 or home == 107306 or home == 107305 or home == 2703 or home == 2704) and (away == 1165 or away == 21 or away == 9 or away == 1170 or away == 27 or away == 24 or away == 13 or away == 15 or away == 5 or away == 8 or away == 14 or away == 28 or away == 22 or away == 1175 or away == 1 or away == 1164 or away == 12 or away == 10 or away == 2 or away == 16 or away == 19 or away == 6 or away == 26 or away == 31 or away == 3 or away == 1550 or away == 20 or away == 23 or away == 7 or away == 17 or away == 11 or away == 29 or away == 30 or away == 4 or away == 1040 or away == 1044 or away == 36 or away == 1051 or away == 34 or away == 1058 or away == 1059 or away == 1067 or away == 32 or away == 35 or away == 38 or away == 37 or away == 33 or away == 1083 or away == 42 or away == 43 or away == 41 or away == 40 or away == 1113 or away == 39 or away == 50 or away == 1128 or away == 45 or away == 47 or away == 44 or away == 51 or away == 48 or away == 46 or away == 49 or away == 1129 or away == 57 or away == 54 or away == 55 or away == 4025 or away == 1010 or away == 52 or away == 1011 or away == 1012 or away == 1013 or away == 1015 or away == 4020 or away == 1022 or away == 1026 or away == 53 or away == 56 or away == 1031 or away == 1032 or away == 1184 or away == 1141 or away == 4021 or away == 91420 or away == 107304 or away == 107307 or away == 107306 or away == 107305 or away == 2703 or away == 2704) then
           MjTs_Data = "World Cup 2018" 
       	else
     	    if rdm then
     	        MjTs_Data = string.format("Random Data %s", rdm)
            end
      end
    else
     	if rdm then
     	    MjTs_Data = string.format("Random Data %s", rdm)
        end
    end
end

local function ipatch_v3(ctx)
	if tid == 39 then
	   MjTs_Data = "Premier League"
  	elseif tid == 72 then
	    MjTs_Data = "Bundes Liga"
  	elseif tid == 40 then
	    MjTs_Data = "SkyBET Championship"
  	elseif tid == 43 then
	    MjTs_Data = "Laliga Santander"
  	elseif tid == 44 then
	    MjTs_Data = "Laliga 123"
  	elseif tid == 48 then
	    MjTs_Data = "Serie BKT"
   	elseif tid == 51 then
	    MjTs_Data = "Ligue 1"
  	elseif tid == 54 then
	   MjTs_Data = "Liga NOS"
  	elseif tid == 47 then
	    MjTs_Data = "Serie A"
	elseif tid == 77 then
	   MjTs_Data = "Gojek Liga1"
  	elseif tid == 85 then
	    MjTs_Data = "Copa Del Rey"
  	elseif tid == 86 then
	   MjTs_Data = "Tim CUP"
  	elseif tid == 120 or tid == 122 or tid == 123 or tid == 123 or tid == 124 or tid == 129 or tid == 134 or tid == 135 then
	   MjTs_Data = "World Cup 2018"
  	elseif tid == 145 then
	    MjTs_Data = "Copa America"
  	elseif tid == 138 or tid == 139 then
	    MjTs_Data = "EURO 2020"
  	elseif tid == 84 then
	   MjTs_Data = "The FA CUP"
    elseif tid == 101 then
       MjTs_Data = "The FA Comunnity Shield"
  	elseif tid == 53 then
	    MjTs_Data = "Eredivisie"
    elseif tid == 2 or tid == 19 or tid == 20 then
	    MjTs_Data = "UEL"
    elseif tid == 0 or tid == 83 or tid == 154 or tid == 155 then
		--Premier League
	    if (home == 101 or home == 4071 or home == 377 or home == 378 or home == 379 or home == 102 or home == 382 or home == 177 or home == 178 or home == 2610 or home == 204 or home == 103 or home == 173 or home == 100 or home == 106 or home == 207 or home == 179 or home == 398 or home == 105 or home == 208) and (away == 101 or away == 4071 or away == 377 or away == 378 or away == 379 or away == 102 or away == 382 or away == 177 or away == 178 or away == 2610 or away == 204 or away == 103 or away == 173 or away == 100 or away == 106 or away == 207 or away == 179 or away == 398 or away == 105 or away == 208) then
	       MjTs_Data = "Premier League"
		--SkyBet Championship
		elseif (home == 107 or home == 201 or home == 202 or home == 176 or home == 4180 or home == 1760 or home == 383 or home == 1589 or home == 386 or home == 104 or home == 205 or home == 387 or home == 388 or home == 389 or home == 4192 or home == 1327 or home == 391 or home == 4193 or home == 4194 or home == 394 or home == 395 or home == 1909 or home == 399 or home == 400) and (away == 107 or away == 201 or away == 202 or away == 176 or away == 4180 or away == 1760 or away == 383 or away == 1589 or away == 386 or away == 104 or away == 205 or away == 387 or away == 388 or away == 389 or away == 4192 or away == 1327 or away == 391 or away == 4193 or away == 4194 or away == 394 or away == 395 or away == 1909 or away == 399 or away == 400) then
		 MjTs_Data = "SkyBET Championship"
		--Ligue 1
	    elseif (home == 4200 or home == 403 or home == 112 or home == 418 or home == 1328 or home == 211 or home == 216 or home == 115 or home == 213 or home == 215 or home == 1910 or home == 217 or home == 113 or home == 181 or home == 114 or home == 4213 or home == 405 or home == 1330 or home == 218 or home == 221) and (away == 4200 or away == 403 or away == 112 or away == 418 or away == 1328 or away == 211 or away == 216 or away == 115 or away == 213 or away == 215 or away == 1910 or away == 217 or away == 113 or away == 181 or away == 114 or away == 4213 or away == 405 or away == 1330 or away == 218 or away == 221) then
	        MjTs_Data = "Ligue 1"
		--Serie A
        elseif (home == 234 or home == 186 or home == 320 or home == 188 or home == 124 or home == 235 or home == 4234 or home == 323 or home == 119 or home == 120 or home == 122 or home == 121 or home == 327 or home == 123 or home == 125 or home == 240 or home == 1919 or home == 4923 or home == 333 or home == 190) and (away == 234 or away == 186 or away == 320 or away == 188 or away == 124 or away == 235 or away == 4234 or away == 323 or away == 119 or away == 120 or away == 122 or away == 121 or away == 327 or away == 123 or away == 125 or away == 240 or away == 1919 or away == 4923 or away == 333 or away == 190) then
            MjTs_Data = "Serie A"
		--Serie BKT
		elseif (home == 317 or home == 4232 or home == 187 or home == 4075 or home == 1920 or home == 4928 or home == 4220 or home == 1363 or home == 336 or home == 4237 or home == 325 or home == 2320 or home == 238 or home == 4240 or home == 328 or home == 4244 or home == 1600 or home == 4229 or home == 4929) and (away == 317 or away == 4232 or away == 187 or away == 4075 or away == 1920 or away == 4928 or away == 4220 or away == 1363 or away == 336 or away == 4237 or away == 325 or away == 2320 or away == 238 or away == 4240 or away == 328 or away == 4244 or away == 1600 or away == 4229 or away == 4929) then
		MjTs_Data = "Serie BKT"
		--Laliga Santander
        elseif (home == 258 or home == 172 or home == 108 or home == 195 or home == 4145 or home == 4146 or home == 259 or home == 362 or home == 2187 or home == 2188 or home == 4272 or home == 366 or home == 370 or home == 194 or home == 109 or home == 196 or home == 266 or home == 265 or home == 110 or home == 267) and (away == 258 or away == 172 or away == 108 or away == 195 or away == 4145 or away == 4146 or away == 259 or away == 362 or away == 2187 or away == 2188 or away == 4272 or away == 366 or away == 370 or away == 194 or away == 109 or away == 196 or away == 266 or away == 265 or away == 110 or away == 267) then
            MjTs_Data = "Laliga Santander"
		--Laliga 123
		elseif (home == 4302 or home == 2393 or home == 357 or home == 4308 or home == 359 or home == 111 or home == 361 or home == 4993 or home == 4288 or home == 1765 or home == 364 or home == 2615 or home == 261 or home == 260 or home == 368 or home == 263 or home == 4994 or home == 4260 or home == 268 or home == 4298 or home == 363 or home == 4147) and (away == 4302 or away == 2393 or away == 357 or away == 4308 or away == 359 or away == 111 or away == 361 or away == 4993 or away == 4288 or away == 1765 or away == 364 or away == 2615 or away == 261 or away == 260 or away == 368 or away == 263 or away == 4994 or away == 4260 or away == 268 or away == 4298 or away == 363 or away == 4147) then
		 MjTs_Data = "Laliga 123"
		--Liga Nos
        elseif (home == 2382 or home == 1973 or home == 191 or home == 4323 or home == 1974 or home == 4085 or home == 2385 or home == 1976 or home == 2388 or home == 1944 or home == 192 or home == 2369 or home == 1979 or home == 5020 or home == 193 or home == 2614 or home == 1804 or home == 1981) and (away == 2382 or away == 1973 or away == 191 or away == 4323 or away == 1974 or away == 4085 or away == 2385 or away == 1976 or away == 2388 or away == 1944 or away == 192 or away == 2369 or away == 1979 or away == 5020 or away == 193 or away == 2614 or away == 1804 or away == 1981) then
            MjTs_Data = "Liga NOS"
		--Bundes Liga
	   elseif (home == 2300 or home == 127 or home == 126 or home == 2293 or home == 2298 or home == 2347 or home == 431 or home == 2345 or home == 2346 or home == 2349 or home == 5010 or home == 128 or home == 2355 or home == 437 or home == 184 or home == 2352 or home == 2348 or home == 2353) and (away == 2300 or away == 127 or away == 126 or away == 2293 or away == 2298 or away == 2347 or away == 431 or away == 2345 or away == 2346 or away == 2349 or away == 5010 or away == 128 or away == 2355 or away == 437 or away == 184 or away == 2352 or away == 2348 or away == 2353) then
     	    MjTs_Data = "Bundes Liga"
		--Eredevisie
     	elseif (home == 243 or home == 116 or home == 242 or home == 339 or home == 342 or home == 344 or home == 117 or home == 1599 or home == 244 or home == 245 or home == 349 or home == 246 or home == 256 or home == 118 or home == 251 or home == 355 or home == 252 or home == 255) and (away == 243 or away == 116 or away == 242 or away == 339 or away == 342 or away == 344 or away == 117 or away == 1599 or away == 244 or away == 245 or away == 349 or away == 246 or away == 256 or away == 118 or away == 251 or away == 355 or away == 252 or away == 255) then
     	  MjTs_Data = "Eredivisie" 	
		 --Liga 1 Gojek
		elseif (home == 1480 or home == 2398 or home == 2399 or home == 2697 or home == 2692 or home == 2690 or home == 2402 or home == 5557 or home == 2689 or home == 2698 or home == 4945 or home == 2405 or home == 1481 or home == 2400 or home == 5563 or home == 1338 or home == 5558 or home == 2408) and (away == 1480 or away == 2398 or away == 2399 or away == 2697 or away == 2692 or away == 2690 or away == 2402 or away == 5557 or away == 2689 or away == 2698 or away == 4945 or away == 2405 or away == 1481 or away == 2400 or away == 5563 or away == 1338 or away == 5558 or away == 2408) then
     	    MjTs_Data = "Gojek Liga1"
        --National Team
        elseif (home == 1165 or home == 21 or home == 9 or home == 1170 or home == 27 or home == 24 or home == 13 or home == 15 or home == 5 or home == 8 or home == 14 or home == 28 or home == 22 or home == 1175 or home == 1 or home == 1164 or home == 12 or home == 10 or home == 2 or home == 16 or home == 19 or home == 6 or home == 26 or home == 31 or home == 3 or home == 1550 or home == 20 or home == 23 or home == 7 or home == 17 or home == 11 or home == 29 or home == 30 or home == 4 or home == 1040 or home == 1044 or home == 36 or home == 1051 or home == 34 or home == 1058 or home == 1059 or home == 1067 or home == 32 or home == 35 or home == 38 or home == 37 or home == 33 or home == 1083 or home == 42 or home == 43 or home == 41 or home == 40 or home == 1113 or home == 39 or home == 50 or home == 1128 or home == 45 or home == 47 or home == 44 or home == 51 or home == 48 or home == 46 or home == 49 or home == 1129 or home == 57 or home == 54 or home == 55 or home == 4025 or home == 1010 or home == 52 or home == 1011 or home == 1012 or home == 1013 or home == 1015 or home == 4020 or home == 1022 or home == 1026 or home == 53 or home == 56 or home == 1031 or home == 1032 or home == 1184 or home == 1141 or home == 4021 or home == 91420 or home == 107304 or home == 107307 or home == 107306 or home == 107305 or home == 2703 or home == 2704) and (away == 1165 or away == 21 or away == 9 or away == 1170 or away == 27 or away == 24 or away == 13 or away == 15 or away == 5 or away == 8 or away == 14 or away == 28 or away == 22 or away == 1175 or away == 1 or away == 1164 or away == 12 or away == 10 or away == 2 or away == 16 or away == 19 or away == 6 or away == 26 or away == 31 or away == 3 or away == 1550 or away == 20 or away == 23 or away == 7 or away == 17 or away == 11 or away == 29 or away == 30 or away == 4 or away == 1040 or away == 1044 or away == 36 or away == 1051 or away == 34 or away == 1058 or away == 1059 or away == 1067 or away == 32 or away == 35 or away == 38 or away == 37 or away == 33 or away == 1083 or away == 42 or away == 43 or away == 41 or away == 40 or away == 1113 or away == 39 or away == 50 or away == 1128 or away == 45 or away == 47 or away == 44 or away == 51 or away == 48 or away == 46 or away == 49 or away == 1129 or away == 57 or away == 54 or away == 55 or away == 4025 or away == 1010 or away == 52 or away == 1011 or away == 1012 or away == 1013 or away == 1015 or away == 4020 or away == 1022 or away == 1026 or away == 53 or away == 56 or away == 1031 or away == 1032 or away == 1184 or away == 1141 or away == 4021 or away == 91420 or away == 107304 or away == 107307 or away == 107306 or away == 107305 or away == 2703 or away == 2704) then
           MjTs_Data = "World Cup 2018" 
       	else
     	    if rdm then
     	        MjTs_Data = string.format("Random Data %s", rdm)
            end
      end
    else
     	if rdm then
     	    MjTs_Data = string.format("Random Data %s", rdm)
        end
    end
end

function read_ini(ctx)
    if inifile:sub(1,1) == "." then
        inifile = ctx.sider_dir .. inifile
    end
    local t = {}
    for line in io.lines(inifile) do
        local name, value = string.match(line, "^(selected.patch)%s*=%s*([-%d.]+)")
        if name and value then
            t[name] = tonumber(value) or value
			patch_select = t[name]
        end
    end
    return t
end	

local function set_team_random_data(ctx, options)
	rdm = math.random(1,4)
   	home = ctx.home_team
	away = ctx.away_team
	read_ini(ctx)
    if patch_select == 0 then
       pte_patch_653(ctx)
	   patch = 1
	   log("selected patch is: PTE 6.5.3")	 
	elseif patch_select == 1 then
       ipatch_v3(ctx)
	   patch = 1
	   log("selected patch is: iPatch v3")	
	else
	   patch = 0
	   log("patch is not selected.")	
    end
	if tid and patch == 1 then
	   log(string.format("multi switcher data switching to: (tournament_id: %s)--> (home_team: %s) and (away_team: %s) is (%s).", tid, home, away, MjTs_Data))
	end
end
local function make_key(ctx, filename)
    if tid and patch == 1 then
        return string.format("%s:%s", MjTs_Data, filename)
    end
end

local function get_filepath(ctx, filename, key)
    if tid and patch == 1 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
	math.randomseed(os.time())
	ctx.register("set_conditions", set_team_random_data)
    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 }