diff --git a/src/server/game/activity_mgr.go b/src/server/game/activity_mgr.go new file mode 100644 index 00000000..df6c2c82 --- /dev/null +++ b/src/server/game/activity_mgr.go @@ -0,0 +1,60 @@ +package game + +import ( + "server/game/mod/msg" + "sync" +) + +type ActivityMgr struct { + *ServerMod +} + +type ActivityData struct { + List map[int]*ActivityCfg // 玩家排行榜 + mu sync.Mutex +} + +type ActivityCfg struct { + Id int + Type int + Strartime int64 + Endtime int64 + Level int + Title string + MailTitle string + MailContent string + RewardItem map[string]interface{} + Extra map[string]interface{} +} + +const () + +func (r *ActivityMgr) Init() { + r.key = RANK_MGR_KEY + r.data = &ActivityData{ + List: make(map[int]*ActivityCfg, 0), + } + // 注册处理函数 + r.init() +} + +func (r *ActivityMgr) getData() *ActivityData { + return r.data.(*ActivityData) +} + +// 零点更新 重置榜单 +func (r *ActivityMgr) ZeroUpdate(m *msg.Msg) (interface{}, error) { + return nil, nil +} + +func (r ActivityMgr) GetActivityCfg(Id int) ActivityCfg { + // 获取活动配置 + data := r.getData() + data.mu.Lock() + defer data.mu.Unlock() + cfg, ok := data.List[Id] + if !ok { + return ActivityCfg{} + } + return *cfg +} diff --git a/src/server/game/server_mod.go b/src/server/game/server_mod.go index 43757e59..374f03d1 100644 --- a/src/server/game/server_mod.go +++ b/src/server/game/server_mod.go @@ -22,6 +22,7 @@ const ( BAN_MGR_KEY = "BAN_MGR" PER_SAVE_TIME = 60 MESSAGE_MGR_KEY = "MESSAGE_MGR" + ACTIVITY_MGR_KEY = "ACTIVITY_MGR" ) type ServerMod struct {