You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
2.6 KiB
Go
118 lines
2.6 KiB
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"git.noahlan.cn/northlan/ntools-go/logger"
|
|
c "github.com/gookit/config/v2"
|
|
"github.com/gookit/config/v2/yaml"
|
|
"github.com/zeromicro/go-zero/zrpc"
|
|
)
|
|
|
|
var Config config
|
|
|
|
type (
|
|
Kafka struct {
|
|
Addr []string
|
|
Topic string
|
|
ConsumerGroup string
|
|
}
|
|
|
|
config struct {
|
|
// Log 日志配置
|
|
Log struct {
|
|
File logger.FileConfig
|
|
Console logger.ConsoleConfig
|
|
}
|
|
Server struct {
|
|
Debug bool
|
|
Listen string
|
|
}
|
|
// Kafka 队列配置
|
|
Kafka struct {
|
|
Danmaku Kafka // 发送弹幕
|
|
Gift Kafka // 赠送礼物
|
|
GuardBuy Kafka // TODO 购买贵族 改名
|
|
RewardPool Kafka // 奖池消息
|
|
}
|
|
Game struct {
|
|
ModeDict map[int64]int32 // 直播间对应模式(临时)
|
|
// 通用模式
|
|
Common struct {
|
|
Commands []string
|
|
}
|
|
// Zhg 指挥官PvP模式
|
|
Zhg struct {
|
|
Commands []string // 指令集
|
|
OutbreakCount int64 // 每次暴兵数量
|
|
OutbreakBaseCost int64 // 默认每次暴兵消耗积分(不限兵种)
|
|
OutbreakCostDict map[int]int64 // 暴兵消耗积分表
|
|
}
|
|
// Zhghz 指挥官海战模式
|
|
Zhghz struct {
|
|
Commands []string
|
|
}
|
|
// Zhgfb 指挥官副本模式
|
|
Zhgfb struct {
|
|
Commands []string
|
|
}
|
|
// Zhgzd 指挥官阵地模式
|
|
Zhgzd struct {
|
|
Commands []string // 指令集
|
|
|
|
// CommandUnitDict 命令单位ID字典
|
|
CommandUnitDict map[string]string
|
|
|
|
// CommandCostDict 命令战略点消耗
|
|
CommandCostDict map[string]struct {
|
|
Common int32 // 通用消耗
|
|
Units map[string]int32 // 单位消耗
|
|
}
|
|
|
|
// 战略暴兵数量(兵种相关)
|
|
DispatchCountDict map[string]int32
|
|
|
|
// 礼物效果配置
|
|
GiftEffect struct {
|
|
// StrategicMaximal 战略点上限配置
|
|
StrategicMaximal struct {
|
|
GiftIds []int64 // 对应礼物ID列表
|
|
Addon int32 // 增加上限值
|
|
Limit int32 // 次数限制
|
|
}
|
|
// StrategicRecover 战略点回复速度
|
|
StrategicRecover struct {
|
|
GiftIds []int64 // 对应礼物ID
|
|
Addon int32 // 增加速度值 x每秒
|
|
Duration int32 // 持续时间 秒
|
|
Limit int32 // 次数限制
|
|
}
|
|
// SupportSkill
|
|
SupportSkill []struct {
|
|
GiftIds []int64 // 对应礼物ID列表 (每次匹配一个)
|
|
SkillIds []string // 技能ID列表
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// RPC
|
|
UserCenterRpc zrpc.RpcClientConf
|
|
}
|
|
)
|
|
|
|
func Init(filepath string) {
|
|
var err error
|
|
c.AddDriver(yaml.Driver)
|
|
|
|
err = c.LoadFiles(filepath)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
err = c.BindStruct("", &Config)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
fmt.Printf("%+v\n", Config)
|
|
}
|