Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
8e97e8d84e
@ -136,5 +136,17 @@
|
|||||||
"open": true,
|
"open": true,
|
||||||
"routrules": "~/worker",
|
"routrules": "~/worker",
|
||||||
"describe": "工会boos战"
|
"describe": "工会boos战"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "maincity",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "主城同屏"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "dcolor",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "猜颜色"
|
||||||
}
|
}
|
||||||
]
|
]
|
@ -117,6 +117,7 @@ const (
|
|||||||
ModuleDcolor core.M_Modules = "dcolor" //猜颜色
|
ModuleDcolor core.M_Modules = "dcolor" //猜颜色
|
||||||
ModuleMaincity core.M_Modules = "maincity" //主城同屏
|
ModuleMaincity core.M_Modules = "maincity" //主城同屏
|
||||||
ModuleMatchPool core.M_Modules = "matchpool" //匹配
|
ModuleMatchPool core.M_Modules = "matchpool" //匹配
|
||||||
|
ModuleTreasureMap core.M_Modules = "treasuremap" //藏宝图
|
||||||
)
|
)
|
||||||
|
|
||||||
// 数据表名定义处
|
// 数据表名定义处
|
||||||
|
@ -13,13 +13,19 @@ func (this *apiComp) OnlinePlayerCheck(session comm.IUserSession, req *pb.MainCi
|
|||||||
// 查看某一封邮件
|
// 查看某一封邮件
|
||||||
func (this *apiComp) OnlinePlayer(session comm.IUserSession, req *pb.MainCityOnlinePlayerReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) OnlinePlayer(session comm.IUserSession, req *pb.MainCityOnlinePlayerReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
friends []*pb.BaseUserInfo
|
friends []*pb.BaseUserInfo
|
||||||
uids []string
|
uids []string
|
||||||
|
onlineUsers []*pb.CacheUser
|
||||||
)
|
)
|
||||||
friends = this.module.model.getplayerPos(session.GetUserId())
|
friends = this.module.model.getplayerPos(session.GetUserId())
|
||||||
for _, v := range friends {
|
for _, v := range friends {
|
||||||
uids = append(uids, v.Uid)
|
uids = append(uids, v.Uid)
|
||||||
}
|
}
|
||||||
|
onlineUsers = this.module.ModuleUser.GetUserSessions(uids)
|
||||||
|
uids = make([]string, 0)
|
||||||
|
for _, v := range onlineUsers {
|
||||||
|
uids = append(uids, v.Uid)
|
||||||
|
}
|
||||||
|
session.SendMsg(string(this.module.GetType()), "onlineplayer", &pb.MainCityOnlinePlayerResp{Uids: uids})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
17
modules/treasuremap/api.go
Normal file
17
modules/treasuremap/api.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package treasuremap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
)
|
||||||
|
|
||||||
|
type apiComp struct {
|
||||||
|
modules.MCompGate
|
||||||
|
module *TreasureMap
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
|
_ = this.MCompGate.Init(service, module, comp, options)
|
||||||
|
this.module = module.(*TreasureMap)
|
||||||
|
return
|
||||||
|
}
|
132
modules/treasuremap/configure.go
Normal file
132
modules/treasuremap/configure.go
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
package treasuremap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
"go_dreamfactory/sys/configure"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
game_gcolorgetfraction = "game_gcolorgetfraction.json"
|
||||||
|
game_gcolorreward = "game_gcolorreward.json"
|
||||||
|
game_gcolorttmedecay = "game_gcolorttmedecay.json"
|
||||||
|
)
|
||||||
|
|
||||||
|
type configureComp struct {
|
||||||
|
modules.MCompConfigure
|
||||||
|
module *TreasureMap
|
||||||
|
lock sync.RWMutex
|
||||||
|
repeatMap map[int32][]*cfg.GameGColorGetfractionData
|
||||||
|
norepeatMap map[int32][]*cfg.GameGColorGetfractionData
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
|
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||||
|
this.module = module.(*TreasureMap)
|
||||||
|
this.repeatMap = make(map[int32][]*cfg.GameGColorGetfractionData)
|
||||||
|
err = this.LoadMultiConfigure(map[string]interface{}{
|
||||||
|
game_gcolorreward: cfg.NewGameGColorReward,
|
||||||
|
game_gcolorttmedecay: cfg.NewGameGColortTmedecay,
|
||||||
|
})
|
||||||
|
configure.RegisterConfigure(game_gcolorgetfraction, cfg.NewGameGColorGetfraction, this.updateconfigure)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新任务配置表
|
||||||
|
func (this *configureComp) updateconfigure() {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
conf *cfg.GameGColorGetfraction
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(game_gcolorgetfraction); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if conf, ok = v.(*cfg.GameGColorGetfraction); !ok {
|
||||||
|
this.module.Error("日常任务配置异常!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
repeatMap := map[int32][]*cfg.GameGColorGetfractionData{}
|
||||||
|
norepeatMap := map[int32][]*cfg.GameGColorGetfractionData{}
|
||||||
|
for _, v := range conf.GetDataList() {
|
||||||
|
if v.Repeat == 1 {
|
||||||
|
if _, ok = repeatMap[v.Difficulty]; !ok {
|
||||||
|
repeatMap[v.Difficulty] = make([]*cfg.GameGColorGetfractionData, 0)
|
||||||
|
}
|
||||||
|
repeatMap[v.Difficulty] = append(repeatMap[v.Difficulty], v)
|
||||||
|
} else {
|
||||||
|
if _, ok = norepeatMap[v.Difficulty]; !ok {
|
||||||
|
norepeatMap[v.Difficulty] = make([]*cfg.GameGColorGetfractionData, 0)
|
||||||
|
}
|
||||||
|
norepeatMap[v.Difficulty] = append(norepeatMap[v.Difficulty], v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.lock.Lock()
|
||||||
|
this.repeatMap = repeatMap
|
||||||
|
this.norepeatMap = norepeatMap
|
||||||
|
this.lock.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *configureComp) getGameGColorGetfractionData(dif int32, repeat bool, index int) (conf *cfg.GameGColorGetfractionData, err error) {
|
||||||
|
var (
|
||||||
|
confs map[int32][]*cfg.GameGColorGetfractionData
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
if repeat {
|
||||||
|
confs = this.repeatMap
|
||||||
|
} else {
|
||||||
|
confs = this.norepeatMap
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok = confs[dif]; ok {
|
||||||
|
if len(confs[dif]) > index {
|
||||||
|
conf = confs[dif][index]
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_gcolorgetfraction, fmt.Sprintf("dif:%d repeat:%v index:%d", dif, repeat, index))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取伤害对应的评分组
|
||||||
|
func (this *configureComp) getGameGColortTmedecayData(time int32) (conf *cfg.GameGColortTmedecayData, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
)
|
||||||
|
|
||||||
|
if v, err = this.GetConfigure(game_gcolorttmedecay); err != nil {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
for _, v := range v.(*cfg.GameGColortTmedecay).GetDataList() {
|
||||||
|
if (time >= v.Min || v.Min == -1) && (time <= v.Max || v.Max == -1) {
|
||||||
|
conf = v
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_gcolorttmedecay, time)
|
||||||
|
this.module.Errorf("err:%v", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取奖励列表
|
||||||
|
func (this *configureComp) getGameGColorRewardData(id int32) (conf *cfg.GameGColorRewardData, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(game_gcolorreward); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if conf, ok = v.(*cfg.GameGColorReward).GetDataMap()[id]; !ok {
|
||||||
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_gcolorreward, id)
|
||||||
|
this.module.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
45
modules/treasuremap/model.go
Normal file
45
modules/treasuremap/model.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package treasuremap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/sys/mgo"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
"go.mongodb.org/mongo-driver/x/bsonx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type modelComp struct {
|
||||||
|
modules.MCompModel
|
||||||
|
module *TreasureMap
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *modelComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
|
err = this.MCompModel.Init(service, module, comp, options)
|
||||||
|
this.TableName = comm.TablekfPushGiftbag
|
||||||
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||||
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户全部的埋点数据
|
||||||
|
func (this *modelComp) getModel(uid string) (info *pb.DBDColor, err error) {
|
||||||
|
info = &pb.DBDColor{}
|
||||||
|
if err = this.Get(uid, info); err != nil && err != mgo.MongodbNil {
|
||||||
|
this.module.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err == mgo.MongodbNil {
|
||||||
|
info = &pb.DBDColor{
|
||||||
|
Id: primitive.NewObjectID().Hex(),
|
||||||
|
Uid: uid,
|
||||||
|
Integral: 0,
|
||||||
|
}
|
||||||
|
err = this.Add(uid, info)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
41
modules/treasuremap/module.go
Normal file
41
modules/treasuremap/module.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package treasuremap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewModule() core.IModule {
|
||||||
|
m := new(TreasureMap)
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
模块名称:猜颜色
|
||||||
|
*/
|
||||||
|
type TreasureMap struct {
|
||||||
|
modules.ModuleBase
|
||||||
|
service comm.IService
|
||||||
|
api *apiComp
|
||||||
|
configure *configureComp
|
||||||
|
model *modelComp
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模块名
|
||||||
|
func (this *TreasureMap) GetType() core.M_Modules {
|
||||||
|
return comm.ModuleTreasureMap
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模块初始化接口 注册用户创建角色事件
|
||||||
|
func (this *TreasureMap) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||||
|
err = this.ModuleBase.Init(service, module, options)
|
||||||
|
this.service = service.(comm.IService)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (this *TreasureMap) OnInstallComp() {
|
||||||
|
this.ModuleBase.OnInstallComp()
|
||||||
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||||
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||||
|
this.model = this.RegisterComp(new(modelComp)).(*modelComp)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user