QGConversions = {}

function QGConversions:initialise()

end

function QGConversions:new(player)
	local o = {}
	setmetatable(o, self)
    self.__index = self
	o.convertAction = nil;
	o.convertableable = nil;
	o.playerid = player;
	o.lastClickTime = 0
    return o;
end

function QGConversions:StartConvertfromUi(item)
	self.convertitem = item;
	self.converttype = self.convertitem:getType()
	self.convertindex = QGConversions:QGindexfinder(self.converttype, ConversionIndexTable);
	self.resultitem = ConversionWeaponTable[self.convertindex];
	self:startConversion();
end

function QGConversions:startConversion()
	local player = getPlayer()
	local moodles = player:getMoodles();
	local panicLevel = moodles:getMoodleLevel(MoodleType.Panic);
	self.convertmoddata = self.convertitem:getModData();
	if self.convertmoddata.roundChambered ~= nil then
		chambered = self.convertmoddata.roundChambered
	else
		chambered = 0
	end
	if self.convertmoddata.currentCapacity ~= nil then
		capacity = self.convertmoddata.currentCapacity
	else 
		capacity = 0
	end
	remainingammo = chambered + capacity;
	if remainingammo == 0 then
		converttime = 1
	else
		converttime = (10*player:getReloadingMod())+(panicLevel*30)
	end
	self.convertAction = QGConvertAction:new(self, getPlayer(), converttime);
	self.counter = remainingammo + 1;
	while self.counter ~= 0 do
	ISTimedActionQueue.add(self.convertAction)
	self.counter = self.counter - 1
	end
end

function QGConversions:QGindexfinder(key, list)
	for i, obj in ipairs(list) do
		if obj == key then
			return i;
		end
	end
	return -1;
end

	ConversionIndexTable = {
			"BenelliM3",
			"BenelliM3Sl",
			"BenelliM3SO",
			"BenelliM3SOSl",
			"BenelliM3PA",
			"BenelliM3PASl",
			"BenelliM3PASO",
			"BenelliM3PASOSl",
			"Spas12",
			"Spas12Sl",
			"Spas12PA",
			"Spas12PASl",
			"Ithaca37",
			"Ithaca37Sl",
			"Ithaca37SO",
			"Ithaca37SOSl",
			"Moss590",
			"Moss590Sl",
			"Moss590SO",
			"Moss590SOSl",
			"Rem870",
			"Rem870Sl",
			"Rem870SO",
			"Rem870SOSl",
			"Win1887",
			"Win1887Sl",
			"Win1887SO",
			"Win1887SOSl",
			"Silverhawk",
			"SilverhawkSl",
			"SilverhawkSO",
			"SilverhawkSOSl",
			"Stevens320",
			"Stevens320Sl",
			"VEPR12",
			"VEPR12Sl",
			"VEPR12Mag",
			"VEPR12SlMag",
			"M1216",
			"M1216Sl",
			"M1216Mag",
			"M1216MagSl",
			"Hawk982",
			"Hawk982Sl",
			"Striker",
			"StrikerSl",
			"AR15",
			"AR15556",
			"M16",
			"M16223",
			"M16SA",
			"M16SA223",
			"M4C",
			"M4C223",
			"M4CSA",
			"M4CSA223",
			"SA80",
			"SA80223",
			"SA80SA",
			"SA80SA223",
			"SIG550",
			"SIG550223",
			"SIG550SA",
			"SIG550SA223",
			"SIG551",
			"SIG551223",
			"SIG551SA",
			"SIG551SA223",
			"SIG550Mag",
			"SIG550223Mag",
			"KTPLR",
			"KTPLR556",
			"STANAGMag",
			"STANAG223Mag",
			"AIAW308Mag",
			"L96Mag",
			"AIAW308",
			"AIAW308762",
			"L96",
			"L96308",
			"M21",
			"M21308",
			"M21Mag",
			"M21308Mag",
			"SR25",
			"SR25308",
			"SR25Mag",
			"SR25308Mag",
			"R25",
			"R25762",
			"R25Mag",
			"R25762Mag",
			"BLR",
			"BLR762",
			"HKSL8",
			"HKSL8556",
			"HKSL8Mag",
			"HKSL8556Mag",
			"LENo4",
			"LENo4308",
			"LENo4Mag",
			"LENo4308Mag",
			"Mini14",
			"Mini14556",
			"Mini14Mag",
			"Mini14556Mag",
			"AR10",
			"AR10308",
			"AR10Mag",
			"AR10308Mag",
			"AR10SA",
			"AR10308SA",
			"FNFAL",
			"FNFAL762",
			"FNFALA",
			"FNFALA308",
			"FNFALSA",
			"FNFALSA308",
			"FNFALMag",
			"FNFALAMag",
			"HK91",
			"HK91762",
			"HKG3",
			"HKG3308",
			"HKG3SA",
			"HKG3SA308",
			"HKG3Mag",
			"HK91Mag",
			"M249",
			"M249223",
			"M249Belt",
			"M249223Belt",
			"SpeedLoader3576",
			"SpeedLoader386",
			"SpeedLoader4546",
			"SpeedLoader45C6",
			"ColtPyth",
			"ColtPyth38",
			"RugBH",
			"RugBH38",
			"SWM19",
			"SWM1938",
			"RugerGP100",
			"RugerGP10038",
			"Taurus454",
			"Taurus45445C",
			"RugAlas",
			"RugAlas45C",
			"BenelliXM1014",
			"BenelliXM1014Sl",
			};
			
	ConversionWeaponTable = {
			"BenelliM3Sl",
			"BenelliM3",
			"BenelliM3SOSl",
			"BenelliM3SO",
			"BenelliM3PASL",
			"BenelliM3PA",
			"BenelliM3PASOSl",
			"BenelliM3PASO",
			"Spas12Sl",
			"Spas12",
			"Spas12PASl",
			"Spas12PA",
			"Ithaca37Sl",
			"Ithaca37",
			"Ithaca37SOSl",
			"Ithaca37SO",
			"Moss590Sl",
			"Moss590",
			"Moss590SOSl",
			"Moss590SO",
			"Rem870Sl",
			"Rem870",
			"Rem870SOSl",
			"Rem870SO",
			"Win1887Sl",
			"Win1887",
			"Win1887SOSl",
			"Win1887SO",
			"SilverhawkSl",
			"Silverhawk",
			"SilverhawkSOSl",
			"SilverhawkSO",
			"Stevens320Sl",
			"Stevens320",
			"VEPR12Sl",
			"VEPR12",
			"VEPR12SlMag",
			"VEPR12Mag",
			"M1216Sl",
			"M1216",
			"M1216MagSl",
			"M1216Mag",
			"Hawk982Sl",
			"Hawk982",
			"StrikerSl",
			"Striker",
			"AR15556",
			"AR15",
			"M16223",
			"M16",
			"M16SA223",
			"M16SA",
			"M4C223",
			"M4C",
			"M4CSA223",
			"M4CSA",
			"SA80223",
			"SA80",
			"SA80SA223",
			"SA80SA",
			"SIG550223",
			"SIG550",
			"SIG550SA223",
			"SIG550SA",
			"SIG551223",
			"SIG551",
			"SIG551SA223",
			"SIG551SA",
			"SIG550223Mag",
			"SIG550Mag",
			"KTPLR556",
			"KTPLR",
			"STANAG223Mag",
			"STANAGMag",
			"L96Mag",
			"AIAW308Mag",
			"AIAW308762",
			"AIAW308",
			"L96308",
			"L96",
			"M21308",
			"M21",
			"M21308Mag",
			"M21Mag",
			"SR25308",
			"SR25",
			"SR25308Mag",
			"SR25Mag",
			"R25762",
			"R25",
			"R25762Mag",
			"R25Mag",
			"BLR762",
			"BLR",
			"HKSL8556",
			"HKSL8",
			"HKSL8556Mag",
			"HKSL8Mag",
			"LENo4308",
			"LENo4",
			"LENo4308Mag",
			"LENo4Mag",
			"Mini14556",
			"Mini14",
			"Mini14556Mag",
			"Mini14Mag",
			"AR10308",
			"AR10",
			"AR10308Mag",
			"AR10Mag",
			"AR10308SA",
			"AR10SA",
			"FNFAL762",
			"FNFAL",
			"FNFALA308",
			"FNFALA",
			"FNFALSA308",
			"FNFALSA",
			"FNFALAMag",
			"FNFALMag",
			"HK91762",
			"HK91",
			"HKG3308",
			"HKG3",
			"HKG3SA308",
			"HKG3SA",
			"HK91Mag",
			"HKG3Mag",
			"M249223",
			"M249",
			"M249223Belt",
			"M249Belt",
			"SpeedLoader386",
			"SpeedLoader3576",
			"SpeedLoader45C6",
			"SpeedLoader4546",
			"ColtPyth38",
			"ColtPyth",
			"RugBH38",
			"RugBH",
			"SWM1938",
			"SWM19",
			"RugerGP10038",
			"RugerGP100",
			"Taurus45445C",
			"Taurus454",
			"RugAlas45C",
			"RugAlas",
			"BenelliXM1014Sl",
			"BenelliXM1014",
			};
			
	ConversionContextTable = {
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .308 Winchester",
			"Use for 7.62x51mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .223 Remington",
			"Use for 5.56x45mm",
			"Use for .38 Special",
			"Use for .357 Magnum",
			"Use for .45 Colt",
			"Use for .454 Casull",
			"Use for .38 Special",
			"Use for .357 Magnum",
			"Use for .38 Special",
			"Use for .357 Magnum",
			"Use for .38 Special",
			"Use for .357 Magnum",
			"Use for .38 Special",
			"Use for .357 Magnum",
			"Use for .45 Colt",
			"Use for .454 Casull",
			"Use for .45 Colt",
			"Use for .454 Casull",
			"Use for 12 gauge Slugs",
			"Use for 00 12 gauge Buck",
			};
			
