local BacCarRat = {};

BacCarRat.MACHINE_MONEY = 3;
BacCarRat.MACHINE_EMONEY = 4;
BacCarRat.MONEY = 0;
BacCarRat.EMONEY = 1;
-- 机器ID -> 币种
BacCarRat.MACHINE = {
	[BacCarRat.MACHINE_MONEY] = { money_type = BacCarRat.MONEY, },
	[BacCarRat.MACHINE_EMONEY] = { money_type = BacCarRat.EMONEY, },
}

-- 币种->机器ID
BacCarRat.Machine = {
	[BacCarRat.MONEY] = BacCarRat.MACHINE_MONEY,
	[BacCarRat.EMONEY] = BacCarRat.MACHINE_EMONEY,
}

-- 发牌间隔(单张)
BacCarRat.DealTime = 0.6;
-- 眯牌
BacCarRat.DrawTime = 1;
BacCarRat.DrawDelay = 0.35;

-- 发牌音效.10秒内相同音效路径只播放一次.
-- 建议庄闲的Draw1设置为不相同的路径.避免音效被去重
BacCarRat.Sound = {
	["Banker"] = {
		["Deal1"] = "sound/cop_baccarat_poker_01.mp3",
		["Deal2"] = "sound/cop_baccarat_poker_01.mp3",
		["Draw1"] = "sound/cop_baccarat_poker_01.mp3",
	},
	["Player"] = {
		["Deal1"] = "sound/cop_baccarat_poker_01.mp3",
		["Deal2"] = "sound/cop_baccarat_poker_01.mp3",
		["Draw1"] = "sound/cop_baccarat_poker_01.mp3",
	},
}
BacCarRat.Dealer = {
	--准备(常驻)
	["idle"] = {
		Time = 0,
	},
	--发牌
	["fapai"] = {
		Time = 1.5,
	},
	--下注
	["happy"] = {
		Time = 1,
	},
}

BacCarRat.CHIP = {
	CHIP_RATE_1 = 1, -- 倍率1
	CHIP_RATE_2 = 2, -- 倍率2
	CHIP_RATE_3 = 3, -- 倍率3
	CHIP_RATE_4 = 4, -- 倍率4
	CHIP_RATE_5 = 5, -- 倍率4
	CHIP_RATE_END = 6,
};

BacCarRat.BET_AREA = {
	B_PAIR = 1, -- 庄对
    P_PAIR = 2, -- 闲对
    BANKER = 3, -- 庄赢
    PLAYER = 4, -- 闲赢
    TIE = 5,    -- 平局
    SMALL = 6,  -- 开小(总牌<=4)
    BIG = 7,    -- 开大(总牌>4)
    LUCKY = 8,  -- 庄家以6点赢
};

BacCarRat.BetOdds = {
	[BacCarRat.MACHINE_MONEY] = {
		[BacCarRat.BET_AREA.B_PAIR] = 16,
		[BacCarRat.BET_AREA.P_PAIR] = 16,
		[BacCarRat.BET_AREA.BANKER] = 2.1,
		[BacCarRat.BET_AREA.PLAYER] = 2.2,
		[BacCarRat.BET_AREA.TIE] = 10,
		[BacCarRat.BET_AREA.SMALL] = 2.6,
		[BacCarRat.BET_AREA.BIG] = 1.6,
		[BacCarRat.BET_AREA.LUCKY] = 18,
	},

	[BacCarRat.MACHINE_EMONEY] = {
		[BacCarRat.BET_AREA.B_PAIR] = 16,
		[BacCarRat.BET_AREA.P_PAIR] = 16,
		[BacCarRat.BET_AREA.BANKER] = 2.1,
		[BacCarRat.BET_AREA.PLAYER] = 2.2,
		[BacCarRat.BET_AREA.TIE] = 10,
		[BacCarRat.BET_AREA.SMALL] = 2.6,
		[BacCarRat.BET_AREA.BIG] = 1.6,
		[BacCarRat.BET_AREA.LUCKY] = 18,
	},
}


--筹码类型
--[Machineid]
BacCarRat.Bet = {
	[BacCarRat.MACHINE_MONEY] = {
		[BacCarRat.CHIP.CHIP_RATE_1] = 10000,
		[BacCarRat.CHIP.CHIP_RATE_2] = 100000,
		[BacCarRat.CHIP.CHIP_RATE_3] = 1000000,
		[BacCarRat.CHIP.CHIP_RATE_4] = 10000000,
		[BacCarRat.CHIP.CHIP_RATE_5] = 100000000,
	},

	[BacCarRat.MACHINE_EMONEY] = {
		[BacCarRat.CHIP.CHIP_RATE_1] = 10,
		[BacCarRat.CHIP.CHIP_RATE_2] = 30,
		[BacCarRat.CHIP.CHIP_RATE_3] = 100,
		[BacCarRat.CHIP.CHIP_RATE_4] = 300,
		[BacCarRat.CHIP.CHIP_RATE_5] = 1000,
	},
}

BacCarRat.Machine = {
	[BacCarRat.MONEY] = BacCarRat.MACHINE_MONEY,
	[BacCarRat.EMONEY] = BacCarRat.MACHINE_EMONEY,
}

--下注筹码上限
--[Machineid]
BacCarRat.BetMax = {
	[BacCarRat.MACHINE_MONEY] = 100000000000,
	[BacCarRat.MACHINE_EMONEY] = 1000000,
}

--筹码Icon
--[Machineid]
BacCarRat.BetIcon = {
	[BacCarRat.MACHINE_MONEY] = {
		[10000] = "tbmain_iconcm1",
		[100000] = "tbmain_iconcm2",
		[1000000] = "tbmain_iconcm3",
		[10000000] = "tbmain_iconcm4",
		[100000000] = "tbmain_iconcm5",
	},

	[BacCarRat.MACHINE_EMONEY] = {
		[10] = "tbmain_choumat1",
		[30] = "tbmain_choumat2",
		[100] = "tbmain_choumat3",
		[300] = "tbmain_choumat4",
		[1000] = "tbmain_choumat5",
	},
}

--按钮特效
BacCarRat.Transition = {
	[1] = "act_kapaichouma10k",
	[2] = "act_kapaichouma100k",
	[3] = "act_kapaichouma1M",
	[4] = "act_kapaichouma10M",
	[5] = "act_kapaichouma100M",
}

--推荐下注筹码
--[Machineid]
BacCarRat.Rate = {
	[BacCarRat.MACHINE_MONEY] = {
		[BacCarRat.CHIP.CHIP_RATE_1] = 11000000,
		[BacCarRat.CHIP.CHIP_RATE_2] = 110000000,
		[BacCarRat.CHIP.CHIP_RATE_3] = 1100000000,
		[BacCarRat.CHIP.CHIP_RATE_4] = 11000000000,
		[BacCarRat.CHIP.CHIP_RATE_5] = 110000000000,
	},

	[BacCarRat.MACHINE_EMONEY] = {
		[BacCarRat.CHIP.CHIP_RATE_1] = 1000,
		[BacCarRat.CHIP.CHIP_RATE_2] = 5000,
		[BacCarRat.CHIP.CHIP_RATE_3] = 10000,
		[BacCarRat.CHIP.CHIP_RATE_4] = 50000,
		[BacCarRat.CHIP.CHIP_RATE_5] = 50001,
	},
}

--Spine
BacCarRat.Spine = {
	[0] = {
		[1] = "hongxinA",
		[2] = "hongxin2",
		[3] = "hongxin3",
		[4] = "hongxin4",
		[5] = "hongxin5",
		[6] = "hongxin6",
		[7] = "hongxin7",
		[8] = "hongxin8",
		[9] = "hongxin9",
		[10] = "hongxin10",
		[11] = "hongxinJ",
		[12] = "hongxinQ",
		[13] = "hongxinK",
	},

	[1] = {
		[1] = "heitaoA",
		[2] = "heitao2",
		[3] = "heitao3",
		[4] = "heitao4",
		[5] = "heitao5",
		[6] = "heitao6",
		[7] = "heitao7",
		[8] = "heitao8",
		[9] = "heitao9",
		[10] = "heitao10",
		[11] = "heitaoJ",
		[12] = "heitaoQ",
		[13] = "heitaoK",
	},
	
	[2] = {
		[1] = "meihuaA",
		[2] = "meihua2",
		[3] = "meihua3",
		[4] = "meihua4",
		[5] = "meihua5",
		[6] = "meihua6",
		[7] = "meihua7",
		[8] = "meihua8",
		[9] = "meihua9",
		[10] = "meihua10",
		[11] = "meihuaJ",
		[12] = "meihuaQ",
		[13] = "meihuaK",
	},
	
	[3] = {
		[1] = "fangkuaiA",
		[2] = "fangkuai2",
		[3] = "fangkuai3",
		[4] = "fangkuai4",
		[5] = "fangkuai5",
		[6] = "fangkuai6",
		[7] = "fangkuai7",
		[8] = "fangkuai8",
		[9] = "fangkuai9",
		[10] = "fangkuai10",
		[11] = "fangkuaiJ",
		[12] = "fangkuaiQ",
		[13] = "fangkuaiK",
	},
}

--推荐下注筹码
BacCarRat.GetOddsShow = function(idMachine, eBetArea)
	if BacCarRat.BetOdds[idMachine] == nil then
		return "1:1"
	end

	if BacCarRat.BetOdds[idMachine][eBetArea] == nil then
		return "1:1"
	end
	return "1:"..BacCarRat.BetOdds[idMachine][eBetArea]
end

--推荐下注筹码
BacCarRat.GetRate = function(idMachine, HeroMoney)
	if BacCarRat.Rate[idMachine] == nil then
		return 1
	end
	
	for i = 1, #BacCarRat.Rate[idMachine] do
		if HeroMoney <= BacCarRat.Rate[idMachine][i] then 
			return i
		end
	end
	
    return BacCarRat.CHIP.CHIP_RATE_5
end

BacCarRat.GetChip = function(idMachine, nRate)
	if BacCarRat.Rate[idMachine] == nil then
		return 0
	end
	if BacCarRat.Rate[idMachine][nRate] == nil then
		return 0
	end

	return BacCarRat.Rate[idMachine][nRate]
end

--Money类型
BacCarRat.GetMoneyType = function(idMachine)
	for k, v in pairs(BacCarRat.Machine) do
		if v == idMachine then
			return k
		end
	end

	return BacCarRat.MONEY
end

--下注筹码筹码icon
BacCarRat.GetChipIcon = function(idMachine, Money)
	if BacCarRat.BetIcon[idMachine] == nil or BacCarRat.BetIcon[idMachine][Money] == nil then
		return ""
	end
	
    return BacCarRat.BetIcon[idMachine][Money]
end

--Jackpot图标
BacCarRat.GetJackpotIcon = function(idMachine)
	if BacCarRat.MACHINE_EMONEY == idMachine then
		return "tbmain_tianshi"
	end

	return "tbmain_jinbi"
end


--筹码选项图标
BacCarRat.GetBetRateIcon = function(idMachine, nIndex)
	if BacCarRat.MACHINE_EMONEY == idMachine then
		return "tbmain_choumat"..nIndex
	end

	return "tbmain_chouma"..nIndex
end

return BacCarRat;