local VersionCompatible = {}

local CLIENT_VERSION = CS.BF.BFMain.CLIENT_VERSION or 0
local PACKAGE_NAME = "com.gearpaw.defenders.td.game"
local PACKAGE_NAME_RU = "com.gearpaw.defenders.td.game.ru"
local PACKAGE_NAME_RUSTORE = "com.fortune.td.game.rustore"
local PACKAGE_NAME_RUHW = "com.fortune.td.game.ru.hw"

--@region 版本相关
function VersionCompatible:canUpdateMailVersion()
	return CLIENT_VERSION > 1
end

function VersionCompatible:supportDataEncryptVersion()
	return CLIENT_VERSION > 1
end

function VersionCompatible:supportMonsterMoveReturnVersion()
	return CLIENT_VERSION > 2
end

function VersionCompatible:supportDeepLink()
	return CLIENT_VERSION > 3
end
--@endregion

--@region 包相关
function VersionCompatible:getIsGlobalPackage()
	return Platform:getIdentifier() == PACKAGE_NAME
end

function VersionCompatible:getIsRUPackage()
	return self:getIsPackageRU() or self:getIsPackageRUStore() or self:getIsPackageRUHW()
end

function VersionCompatible:getIsPackageRU()
	return Platform:getIdentifier() == PACKAGE_NAME_RU
end

function VersionCompatible:getIsPackageRUStore()
	return Platform:getIdentifier() == PACKAGE_NAME_RUSTORE
end

function VersionCompatible:getIsPackageRUHW()
	return Platform:getIdentifier() == PACKAGE_NAME_RUHW
end
--@endregion

--@region 跳转相关
function VersionCompatible:getDiscordUrl()
	return GConst.GameSettingConst.DISCORD_URL
end

function VersionCompatible:getDiscordUrlVN()
	return GConst.GameSettingConst.DISCORD_URL_VN
end

function VersionCompatible:getFacebookUrl()
	local currLanguage = I18N:getCurLanguage()
	if currLanguage == GConst.LANGUAGE.CHINESE_TC or
		currLanguage == GConst.LANGUAGE.CHINESE then
		return GConst.GameSettingConst.FACEBOOK_URL_TW
	else
		return GConst.GameSettingConst.FACEBOOK_URL
	end
end

function VersionCompatible:getVKUrl()
	return GConst.GameSettingConst.VK_URL
end
--@endregion

--@region 支付相关
function VersionCompatible:getRechargePayId()
	if self:getIsRUPackage() then
		return "payId_ru"
	end
	return "payId_tw"
end

-- 获取支付渠道
function VersionCompatible:getPayPlatform()
	if Platform:isAndroidPlatform() then
		if self:getIsPackageRU() then
			return "dukpay"
		elseif self:getIsPackageRUStore() then
			return "rustore"
		elseif self:getIsPackageRUHW() then
			return "hw"
		end
	end
	return nil
end
--@endregion

--@region fb支持
function VersionCompatible:supportFb()
	if self:getIsRUPackage() then
		return false
	end
	return true
end
--@endregion

--@region AppsFlyerAdRevenue
function VersionCompatible:getIsSupportAFAdRevenue()
	if self:getIsPackageRU()
		or self:getIsPackageRUStore()
		-- or Platform:getIdentifier() == PACKAGE_NAME_US
		-- or Platform:getIdentifier() == PACKAGE_NAME_VN
													then
		return false
	end
	return true
end
--@endregion

--@region Firebase支持
function VersionCompatible:getIsSupportFirebase()
	if self:getIsRUPackage() then
		return false
	end
	return true
end
--@endregion

--@region VK支持
function VersionCompatible:getIsSupportVKBind()
	if self:getIsRUPackage() then
		return true
	end
	return false
end

function VersionCompatible:supportVK()
	if self:getIsRUPackage() then
		return true
	end
	return false
end
--@endregion

--@region Google支持
function VersionCompatible:getIsSupportGoogle()
	if self:getIsRUPackage() then
		return false
	end
	return true
end
--@endregion

function VersionCompatible:supportDiscord()
	if self:getIsRUPackage() then
		return false
	end
	return true
end

--@region 渠道分成
-- 不同渠道的支付上报分成比例
function VersionCompatible:getAFPayProportion()
	-- rustore的分成比例
	if self:getIsPackageRUStore() and Platform:isAndroidPlatform() then
		return 0.62976
	end
	return 1
end
--@endregion

--@region 俄罗斯相关
function VersionCompatible:getIsSupportGDPR()
	if self:getIsRUPackage() then
		return false
	end
	return true
end

--@region dakpay
function VersionCompatible:supportRuDukpay()
	if self:getIsPackageRU() and Platform:isAndroidPlatform() then
		return true
	end
	return false
end
--@endregion

--@region rustore
function VersionCompatible:supportRuStorePay()
	if self:getIsPackageRUStore() then
		return true
	end
	return false
end

-- android 俄罗斯商店好评
function VersionCompatible:supportRuStoreReview()
	if self:getIsPackageRUStore() and Platform:isAndroidPlatform() then
		return true
	end
	return false
end
--@endregion

--@region hw支付
function VersionCompatible:supportRuHW()
	if self:getIsPackageRUHW() and Platform:isAndroidPlatform() then
		return true
	end
	return false
end
--@endregion
--@endregion

--@region 渠道相关
-- 是否有俄语
function VersionCompatible:getIsSupportRussian()
	if EDITOR_MODE then
		return true
	end
	return self:getIsRUPackage()
end

function VersionCompatible:getIsVnChannel()
	return I18N:getCurLanguage() == GConst.LANGUAGE.VIETNAMESE
end
--@endregion

function VersionCompatible:getServiceUrl()
    return GConst.GameSettingConst.SERVICE_URL
end

function VersionCompatible:getPrivacyUrl()
    return GConst.GameSettingConst.PRIVACY_URL
end

--@region 深度链接相关

-- 支持日志
function VersionCompatible:supportLogInReleaseEnv()
	if self:supportDeepLink() then
		return CS.BF.BFMain.DPSupportLog
	end

	return false
end

-- 支持GM
function VersionCompatible:supportGMInReleaseEnv()
	if self:supportDeepLink() then
		return CS.BF.BFMain.DPSupportGM
	end

	return false
end

-- 支持修改包名
function VersionCompatible:supportSimulatedPackageName()
	if self._supportSimulatedPackageName == nil then
		if CS.BF.BFMain.DPPackageName == GConst.EMPTY_STRING then
			self._supportSimulatedPackageName = false
		else
			if CS.BF.BFMain.DPPackageName == PACKAGE_NAME or
				CS.BF.BFMain.DPPackageName == PACKAGE_NAME_RU then
				self._supportSimulatedPackageName = true
			else
				self._supportSimulatedPackageName = false
			end
		end
	end
	return self._supportSimulatedPackageName
end
--#endregion

return VersionCompatible
