120 lines
3.8 KiB
Go
120 lines
3.8 KiB
Go
package config
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"game/common/config"
|
|
"game/common/config/game"
|
|
"game/common/constant"
|
|
"github.com/fox/fox/db"
|
|
"github.com/fox/fox/log"
|
|
"github.com/go-redis/redis/v8"
|
|
)
|
|
|
|
var Command *config.Command
|
|
var Cfg *config.Common[game.ColorConfig]
|
|
|
|
func InitLog() {
|
|
log.Open("./log/color.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() }()
|
|
Cfg, err = config.LoadCommonConfig[game.ColorConfig](rdb, GitCommit, GitBranch, BuildDate)
|
|
if err != nil {
|
|
log.Error(err.Error())
|
|
return
|
|
}
|
|
log.DebugF("load common config success")
|
|
LoadColorConfig(rdb)
|
|
}
|
|
|
|
func LoadColorConfig(rdb *redis.Client) {
|
|
if err := config.LoadSpecialConfig[game.ColorConfig](rdb, game.ColorKey, Cfg); err == nil {
|
|
return
|
|
}
|
|
Cfg.Special = &game.ColorConfig{}
|
|
Cfg.Special.GameTiming = &game.ColorGameTiming{
|
|
//Ready: 100, // 倒计时321
|
|
Start: 2000,
|
|
Betting: 15000,
|
|
EndBetting: 3000,
|
|
OpenThreeDice: 3000,
|
|
Settle: 7000,
|
|
//Ranking: 1000,
|
|
}
|
|
|
|
WinSingleColorWeight := [3]int{50, 25, 25}
|
|
WinSingleColorMul := [3][]*game.ColorMulRate{
|
|
{{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 := []*game.ColorMulRate{{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 := []*game.ColorMulRate{{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 := &game.ColorRoomConfig{
|
|
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)
|
|
|
|
if bs, err := json.Marshal(&Cfg.Special); err == nil {
|
|
err = rdb.Set(context.Background(), game.ColorKey, string(bs), 0).Err()
|
|
}
|
|
}
|