2025-06-06 20:02:58 +08:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"game/common/config"
|
|
|
|
"game/common/constant"
|
|
|
|
"github.com/fox/fox/db"
|
|
|
|
"github.com/fox/fox/log"
|
2025-06-07 01:58:14 +08:00
|
|
|
"github.com/go-redis/redis/v8"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
specialKey = "color_config"
|
2025-06-06 20:02:58 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var Command *config.Command
|
2025-06-07 01:58:14 +08:00
|
|
|
var Cfg *config.Common[ColorConfig]
|
|
|
|
|
|
|
|
type MulRate struct {
|
|
|
|
Mul int64 `json:"mul"` // 赔率
|
|
|
|
Rate int `json:"rate"` // 概率
|
|
|
|
}
|
|
|
|
type RoomConfig struct {
|
|
|
|
RoomType int `json:"room_type"` // 房间类型:初级,低级,中级,高级
|
|
|
|
Name string `json:"name"` // 游戏房间名称
|
|
|
|
Blind int64 `json:"blind"` // 底注
|
|
|
|
Rate int64 `json:"rate"` // 房间明税率
|
|
|
|
|
|
|
|
WinSingleColorWeight []int `json:"win_single_color_weight"` // 胜利单色奖励三个权重
|
|
|
|
WinSingleColorMul [][]*MulRate `json:"win_single_color_mul"` // 胜利单色奖励赔率 (1个同色,2个同色,3个同色)
|
|
|
|
WinDoubleColorMul []*MulRate `json:"win_double_color_mul"` // 胜利双色奖励赔率
|
|
|
|
WinThreeColorMul []*MulRate `json:"win_three_color_mul"` // 胜利三色奖励赔率
|
|
|
|
InitJackpot int64 `json:"init_jackpot"` // 初始jackpot值
|
|
|
|
JackpotRate int `json:"jackpot_rate"` // 单色投注区域每个颜色出现jackpot的概率
|
|
|
|
JpXRate int `json:"jp_x_rate"` // jp池赎回比例
|
|
|
|
JpYRate int `json:"jp_y_rate"` // jp池追加比例
|
|
|
|
JpXYRate int `json:"jp_xy_rate"` // 系统池为正时jackpot追加比例
|
|
|
|
|
|
|
|
AreaBetLimit int64 `json:"area_bet_limit"` // 下注区域自己的下注限制
|
2025-06-06 20:02:58 +08:00
|
|
|
|
2025-06-07 01:58:14 +08:00
|
|
|
NoBetCountMax int `json:"no_bet_count_max"` // 未操作回合踢出房间
|
|
|
|
BetList [][]int64 `json:"bet_list"` // 筹码
|
|
|
|
BetLevel []int64 `json:"bet_level"` // 筹码等级
|
|
|
|
OneCreateMin int32 `json:"one_create_min"` // 一次创建机器最少数
|
|
|
|
OneCreateMax int32 `json:"one_create_max"` // 一次创建机器人最大数
|
|
|
|
UserAddRobotNum int32 `json:"user_add_robot_num"` // 真人+机器人最小数
|
|
|
|
UserAddRobotNumMax int32 `json:"user_add_robot_num_max"` // 真人+机器人最大数
|
|
|
|
OneDeleteNum int32 `json:"one_delete_num"` // 一次删除机器人数量
|
|
|
|
BalanceMin int64 `json:"balance_min"` // 机器人生成最小金币
|
|
|
|
BalanceMax int64 `json:"balance_max"` // 机器人生成最大金币
|
|
|
|
BalanceMinDelete int64 `json:"balance_min_delete"` // 机器人低于多少金币删除
|
|
|
|
RobotCreateTime int32 `json:"robot_create_time"` // 多少时间创建机器人
|
|
|
|
RobotDeleteTime int32 `json:"robot_delete_time"` // 多少时间删除机器人
|
|
|
|
RobotBetNumMin int32 `json:"robot_bet_num_min"` // 机器人每轮下注最少次数
|
|
|
|
RobotBetNumMax int32 `json:"robot_bet_num_max"` // 机器人每轮下注最大次数
|
|
|
|
OpenRobot bool `json:"open_robot"` // 机器人开关
|
|
|
|
BetMap map[int64][]int32
|
|
|
|
TotalBetLimit int64 `json:"total_bet_limit"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type GameTiming struct {
|
|
|
|
//Ready int64 // 准备倒计时
|
|
|
|
Start int64 // 开始
|
|
|
|
Betting int64 // 下注
|
|
|
|
EndBetting int64 // 结束下注
|
|
|
|
OpenThreeDice int64 // 开普通3个骰子
|
|
|
|
Settle int64 // 结算
|
|
|
|
//Ranking int64 // 排行榜
|
|
|
|
}
|
|
|
|
|
|
|
|
type ColorConfig struct {
|
|
|
|
Rooms []*RoomConfig `json:"rooms"` // 房间信息
|
|
|
|
GameTiming *GameTiming `json:"game_timing"`
|
2025-06-06 20:02:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func InitLog() {
|
|
|
|
log.Open("./log/login.log", log.DebugL)
|
|
|
|
log.Info("")
|
|
|
|
log.Info("")
|
|
|
|
log.Info("")
|
|
|
|
log.Info("-----init log success-----")
|
|
|
|
}
|
|
|
|
|
|
|
|
func LoadConfig(GitCommit, GitBranch, BuildDate string) {
|
|
|
|
Command = config.ParseCommand()
|
|
|
|
rdb, err := db.InitRedis(Command.RedisPassword, Command.RedisHost, Command.RedisPort, constant.Redis0Config)
|
|
|
|
if err != nil {
|
|
|
|
log.Error(err.Error())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer func() { _ = rdb.Close() }()
|
2025-06-07 01:58:14 +08:00
|
|
|
Cfg, err = config.LoadCommonConfig[ColorConfig](rdb, GitCommit, GitBranch, BuildDate)
|
2025-06-06 20:02:58 +08:00
|
|
|
if err != nil {
|
|
|
|
log.Error(err.Error())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.DebugF("load common config success")
|
2025-06-07 01:58:14 +08:00
|
|
|
LoadColorConfig(rdb)
|
|
|
|
}
|
|
|
|
|
|
|
|
func LoadColorConfig(rdb *redis.Client) {
|
|
|
|
if err := config.LoadSpecialConfig[ColorConfig](rdb, specialKey, Cfg); err == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
Cfg.Special = &ColorConfig{}
|
|
|
|
Cfg.Special.GameTiming = &GameTiming{
|
|
|
|
//Ready: 100, // 倒计时321
|
|
|
|
Start: 2000,
|
|
|
|
Betting: 15000,
|
|
|
|
EndBetting: 3000,
|
|
|
|
OpenThreeDice: 3000,
|
|
|
|
Settle: 7000,
|
|
|
|
//Ranking: 1000,
|
|
|
|
}
|
|
|
|
|
|
|
|
WinSingleColorWeight := [3]int{50, 25, 25}
|
|
|
|
WinSingleColorMul := [3][]*MulRate{
|
|
|
|
{{Mul: 0.6 * 100, Rate: 75 * 100}, {Mul: 1 * 100, Rate: 12 * 100},
|
|
|
|
{Mul: 1.5 * 100, Rate: 7.5 * 100}, {Mul: 2 * 100, Rate: 5.5 * 100}},
|
|
|
|
|
|
|
|
{{Mul: 2 * 100, Rate: 82.5 * 100}, {Mul: 3 * 100, Rate: 4 * 100},
|
|
|
|
{Mul: 4 * 100, Rate: 3.5 * 100}, {Mul: 5 * 100, Rate: 3.2 * 100},
|
|
|
|
{Mul: 6 * 100, Rate: 230}, {Mul: 7 * 100, Rate: 1.8 * 100},
|
|
|
|
{Mul: 8 * 100, Rate: 1.5 * 100}, {Mul: 9 * 100, Rate: 1.2 * 100}},
|
|
|
|
|
|
|
|
{{Mul: 3 * 100, Rate: 94 * 100}, {Mul: 9 * 100, Rate: 1.4 * 100},
|
|
|
|
{Mul: 14 * 100, Rate: 110}, {Mul: 19 * 100, Rate: 0.9 * 100},
|
|
|
|
{Mul: 29 * 100, Rate: 0.8 * 100}, {Mul: 49 * 100, Rate: 0.7 * 100},
|
|
|
|
{Mul: 99 * 100, Rate: 0.6 * 100}, {Mul: 9 * 100, Rate: 0.5 * 100}},
|
|
|
|
}
|
|
|
|
WinDoubleColorMul := []*MulRate{{Mul: 8 * 100, Rate: 66 * 100}, {Mul: 11 * 100, Rate: 17 * 100},
|
|
|
|
{Mul: 14 * 100, Rate: 9 * 100}, {Mul: 19 * 100, Rate: 3.5 * 100},
|
|
|
|
{Mul: 24 * 100, Rate: 1.9 * 100}, {Mul: 54 * 100, Rate: 1.5 * 100},
|
|
|
|
{Mul: 74 * 100, Rate: 1.05 * 100}, {Mul: 99 * 100, Rate: 0.05 * 100}}
|
|
|
|
|
|
|
|
WinThreeColorMul := []*MulRate{{Mul: 150 * 100, Rate: 84.5 * 100}, {Mul: 199 * 100, Rate: 5.5 * 100},
|
|
|
|
{Mul: 299 * 100, Rate: 4 * 100}, {Mul: 599 * 100, Rate: 3 * 100},
|
|
|
|
{Mul: 799 * 100, Rate: 2 * 100}, {Mul: 999 * 100, Rate: 1 * 100}}
|
|
|
|
|
|
|
|
rmConfig := &RoomConfig{
|
|
|
|
BetList: [][]int64{
|
|
|
|
{1000, 2000, 3000, 5000, 10000, 20000},
|
|
|
|
{5000, 20000, 30000, 40000, 50000, 800000},
|
|
|
|
{10000, 20000, 30000, 50000, 80000, 100000},
|
|
|
|
},
|
|
|
|
BetLevel: []int64{0, 10000, 20000},
|
|
|
|
WinSingleColorWeight: WinSingleColorWeight[:],
|
|
|
|
WinSingleColorMul: WinSingleColorMul[:],
|
|
|
|
WinDoubleColorMul: WinDoubleColorMul,
|
|
|
|
WinThreeColorMul: WinThreeColorMul,
|
|
|
|
InitJackpot: 2000000 * 100,
|
|
|
|
JackpotRate: 0.05 * 100,
|
|
|
|
JpXRate: 2 * 100,
|
|
|
|
JpYRate: 1 * 100,
|
|
|
|
JpXYRate: 1.5 * 100,
|
|
|
|
|
|
|
|
AreaBetLimit: 500000,
|
|
|
|
NoBetCountMax: 10,
|
|
|
|
OpenRobot: false,
|
|
|
|
OneCreateMin: 3,
|
|
|
|
OneCreateMax: 5,
|
|
|
|
UserAddRobotNum: 80,
|
|
|
|
UserAddRobotNumMax: 100,
|
|
|
|
OneDeleteNum: 1,
|
|
|
|
BalanceMinDelete: 4000,
|
|
|
|
BalanceMin: 100000,
|
|
|
|
BalanceMax: 500000,
|
|
|
|
RobotCreateTime: 8000,
|
|
|
|
RobotDeleteTime: 5000,
|
|
|
|
RobotBetNumMin: 2,
|
|
|
|
RobotBetNumMax: 4,
|
|
|
|
}
|
|
|
|
Cfg.Special.Rooms = append(Cfg.Special.Rooms, rmConfig)
|
2025-06-06 20:02:58 +08:00
|
|
|
}
|