120 lines
3.8 KiB
Go
Raw Normal View History

2025-06-06 20:02:58 +08:00
package config
import (
2025-06-07 22:53:54 +08:00
"context"
"encoding/json"
2025-06-06 20:02:58 +08:00
"game/common/config"
2025-06-07 22:53:54 +08:00
"game/common/config/game"
2025-06-06 20:02:58 +08:00
"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"
)
2025-06-06 20:02:58 +08:00
var Command *config.Command
2025-06-07 22:53:54 +08:00
var Cfg *config.Common[game.ColorConfig]
2025-06-06 20:02:58 +08:00
func InitLog() {
2025-06-07 22:53:54 +08:00
log.Open("./log/color.log", log.DebugL)
2025-06-06 20:02:58 +08:00
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 22:53:54 +08:00
Cfg, err = config.LoadCommonConfig[game.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) {
2025-06-07 22:53:54 +08:00
if err := config.LoadSpecialConfig[game.ColorConfig](rdb, game.ColorKey, Cfg); err == nil {
2025-06-07 01:58:14 +08:00
return
}
2025-06-07 22:53:54 +08:00
Cfg.Special = &game.ColorConfig{}
Cfg.Special.GameTiming = &game.ColorGameTiming{
2025-06-07 01:58:14 +08:00
//Ready: 100, // 倒计时321
Start: 2000,
Betting: 15000,
EndBetting: 3000,
OpenThreeDice: 3000,
Settle: 7000,
//Ranking: 1000,
}
WinSingleColorWeight := [3]int{50, 25, 25}
2025-06-07 22:53:54 +08:00
WinSingleColorMul := [3][]*game.ColorMulRate{
2025-06-07 01:58:14 +08:00
{{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}},
}
2025-06-07 22:53:54 +08:00
WinDoubleColorMul := []*game.ColorMulRate{{Mul: 8 * 100, Rate: 66 * 100}, {Mul: 11 * 100, Rate: 17 * 100},
2025-06-07 01:58:14 +08:00
{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}}
2025-06-07 22:53:54 +08:00
WinThreeColorMul := []*game.ColorMulRate{{Mul: 150 * 100, Rate: 84.5 * 100}, {Mul: 199 * 100, Rate: 5.5 * 100},
2025-06-07 01:58:14 +08:00
{Mul: 299 * 100, Rate: 4 * 100}, {Mul: 599 * 100, Rate: 3 * 100},
{Mul: 799 * 100, Rate: 2 * 100}, {Mul: 999 * 100, Rate: 1 * 100}}
2025-06-07 22:53:54 +08:00
rmConfig := &game.ColorRoomConfig{
2025-06-07 01:58:14 +08:00
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-07 22:53:54 +08:00
if bs, err := json.Marshal(&Cfg.Special); err == nil {
err = rdb.Set(context.Background(), game.ColorKey, string(bs), 0).Err()
}
2025-06-06 20:02:58 +08:00
}