迷宫特权
This commit is contained in:
parent
3a632f0d28
commit
a32f369c6a
@ -350,6 +350,9 @@ const (
|
||||
|
||||
// 迷宫图鉴
|
||||
TableStonehengeBook = "stonehengebook"
|
||||
|
||||
// 迷宫特权
|
||||
TableStonehengePrivilege = "stonehengeprivilege"
|
||||
)
|
||||
|
||||
// RPC服务接口定义处
|
||||
|
@ -24,9 +24,10 @@ const (
|
||||
game_stonetalent = "game_stonetalent.json"
|
||||
game_storeconf = "game_stonestore.json" // 商店配置
|
||||
game_stoneillustrated = "game_stoneillustrated.json"
|
||||
game_storyconf = "game_stonestory.json" // 剧情表
|
||||
game_stoneweek = "game_stoneweek.json" //周长
|
||||
game_stonetask = "game_stonetask.json" //任务
|
||||
game_storyconf = "game_stonestory.json" // 剧情表
|
||||
game_stoneweek = "game_stoneweek.json" //周长
|
||||
game_stonetask = "game_stonetask.json" //任务
|
||||
game_stoneprivilege = "game_stoneprivilege.json" //特权
|
||||
)
|
||||
|
||||
///背包配置管理组件
|
||||
@ -95,7 +96,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
err = this.LoadConfigure(game_storeconf, cfg.NewGameStoneStore)
|
||||
err = this.LoadConfigure(game_stoneweek, cfg.NewGameStoneWeek)
|
||||
err = this.LoadConfigure(game_stonetask, cfg.NewGameStoneTask)
|
||||
//err = this.LoadConfigure(game_storyconf, cfg.NewGameStoneStory)
|
||||
err = this.LoadConfigure(game_stoneprivilege, cfg.NewGameStonePrivilege)
|
||||
configure.RegisterConfigure(game_stageconf, cfg.NewGameStoneStage, this.LoadGameStoneStage)
|
||||
configure.RegisterConfigure(game_buffconf, cfg.NewGameStoneBuff, this.LoadGameStoneBuff)
|
||||
configure.RegisterConfigure(game_storyconf, cfg.NewGameStoneStory, this.LoadGameStoneStory)
|
||||
@ -843,3 +844,20 @@ func (this *configureComp) getGameStoneTaskDatas() (confs []*cfg.GameStoneTaskDa
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 获取特权信息
|
||||
func (this *configureComp) getGameStonePrivilegeData(privilegeId int32) (conf *cfg.GameStonePrivilegeData, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_stoneprivilege); err == nil {
|
||||
|
||||
if conf, ok = v.(*cfg.GameStonePrivilege).GetDataMap()[privilegeId]; ok {
|
||||
return
|
||||
}
|
||||
}
|
||||
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_stonetask, privilegeId)
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
|
75
modules/stonehenge/modelStonehengePrivilege.go
Normal file
75
modules/stonehenge/modelStonehengePrivilege.go
Normal file
@ -0,0 +1,75 @@
|
||||
package stonehenge
|
||||
|
||||
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 ModelStonehengePrivilege struct {
|
||||
modules.MCompModel
|
||||
module *Stonehenge
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *ModelStonehengePrivilege) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
||||
this.TableName = comm.TableStonehengePrivilege
|
||||
this.MCompModel.Init(service, module, comp, opt)
|
||||
this.module = module.(*Stonehenge)
|
||||
|
||||
//创建uid索引
|
||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//获取特权
|
||||
func (this *ModelStonehengePrivilege) getStonehengePrivilege(uid string) (info *pb.DBStonehengePrivilege, err error) {
|
||||
info = &pb.DBStonehengePrivilege{}
|
||||
if err = this.Get(uid, info); err != nil && mgo.MongodbNil != err { // 创建一条初始的数据
|
||||
return
|
||||
}
|
||||
if mgo.MongodbNil == err {
|
||||
info = &pb.DBStonehengePrivilege{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Uid: uid,
|
||||
Privilege: map[int32]int32{},
|
||||
}
|
||||
err = this.Add(uid, info)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 激活特权信息
|
||||
func (this *ModelStonehengePrivilege) addStonehengePrivilege(uid string, privilegeId int32) {
|
||||
var (
|
||||
info *pb.DBStonehengePrivilege
|
||||
|
||||
ok bool
|
||||
err error
|
||||
)
|
||||
if info, err = this.getStonehengePrivilege(uid); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
|
||||
if _, ok = info.Privilege[privilegeId]; !ok {
|
||||
|
||||
info.Privilege[privilegeId] = 1
|
||||
if err = this.Change(uid, map[string]interface{}{
|
||||
"privilege": info.Privilege,
|
||||
}); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue
Block a user