This commit is contained in:
liwei 2023-07-12 16:07:51 +08:00
commit 7af53cf7ff
9 changed files with 124 additions and 29 deletions

View File

@ -270,7 +270,7 @@ const (
TableHdData = "hddata" TableHdData = "hddata"
// 活动列表 // 活动列表
TableHdList = "huodong" TableHdInfo = "hdinfo"
//世界任务 //世界任务
TableWtask = "wtask" TableWtask = "wtask"

View File

@ -549,4 +549,9 @@ type (
Delivery(session IUserSession, pid string) (errdata *pb.ErrorData, items []*pb.UserAssets) Delivery(session IUserSession, pid string) (errdata *pb.ErrorData, items []*pb.UserAssets)
OpenWarorder(wtype int32, opentime int64) OpenWarorder(wtype int32, opentime int64)
} }
IActivity interface {
GetHdInfoByHdId(hid int32) (result *pb.DBHuodong, err error) // 通过活动id 获取活动信息
GetAllHdInfo() (result []*pb.DBHuodong, err error) // 获取所有活动信息
}
) )

View File

@ -11,9 +11,10 @@ func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.ActivityGet
return return
} }
// 获取所有活动信息
func (this *apiComp) GetList(session comm.IUserSession, req *pb.ActivityGetListReq) (errdata *pb.ErrorData) { func (this *apiComp) GetList(session comm.IUserSession, req *pb.ActivityGetListReq) (errdata *pb.ErrorData) {
list, err := this.module.modelhdList.getHdList(session.GetUserId()) list, err := this.module.modelhdList.getHdInfo()
if err != nil { if err != nil {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError, Code: pb.ErrorCode_DBError,

View File

@ -1,11 +1,13 @@
package activity package activity
import ( import (
"context"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx" "go.mongodb.org/mongo-driver/x/bsonx"
) )
@ -16,32 +18,50 @@ type modelHdList struct {
} }
func (this *modelHdList) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *modelHdList) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = string(comm.TableHdList) this.TableName = string(comm.TableHdInfo)
err = this.MCompModel.Init(service, module, comp, options) err = this.MCompModel.Init(service, module, comp, options)
this.module = module.(*Activity) this.module = module.(*Activity)
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "hdid", Value: bsonx.Int32(1)}}, Keys: bsonx.Doc{{Key: "hdid", Value: bsonx.Int32(1)}},
}) })
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
})
return return
} }
func (this *modelHdList) getHdList(uid string) (result []*pb.DBHuodong, err error) { func (this *modelHdList) getHdInfo() (result []*pb.DBHuodong, err error) {
result = make([]*pb.DBHuodong, 0)
if err = this.GetList(uid, &result); err != nil { if _data, err := this.DBModel.DB.Find(comm.TableHdInfo, bson.M{}); err == nil {
this.module.Errorf("getActivityList db error: %v", err) for _data.Next(context.TODO()) {
err = nil temp := &pb.DBHuodong{}
if err = _data.Decode(temp); err != nil {
this.module.Errorln(err)
} else {
result = append(result, temp)
}
}
}
return
}
// 通过活动ID查找
func (this *modelHdList) getHdInfoByHdId(hid int32) (result *pb.DBHuodong, err error) {
_data := this.DBModel.DB.FindOne(comm.TableHdInfo, bson.M{"hdid": hid})
result = &pb.DBHuodong{}
if err = _data.Decode(result); err != nil {
this.module.Errorln(err)
} }
return return
} }
// 不需要修改 此接口不调用 // 不需要修改 此接口不调用
func (this *modelHdList) modifyHdList(uid string, data map[string]interface{}) error { func (this *modelHdList) modifyHdInfo(uid string, data map[string]interface{}) error {
return this.Change(uid, data) return this.Change(uid, data)
} }
func (this *modelHdList) addHdList(hd *pb.DBHuodong) error { func (this *modelHdList) addHdInfo(hd *pb.DBHuodong) error {
if _, err := this.DB.InsertOne(core.SqlTable("hdinfo"), hd); err != nil { if _, err := this.DB.InsertOne(core.SqlTable("hdinfo"), hd); err != nil {
return err return err
} }

View File

@ -44,7 +44,11 @@ func (this *Activity) Init(service core.IService, module core.IModule, options c
// }() // }()
return return
} }
func (this *Activity) Start() (err error) {
err = this.ModuleBase.Start()
//this.modelhdList.getHdInfoByHdId(10002)
return
}
func (this *Activity) OnInstallComp() { func (this *Activity) OnInstallComp() {
this.ModuleBase.OnInstallComp() this.ModuleBase.OnInstallComp()
this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.api = this.RegisterComp(new(apiComp)).(*apiComp)
@ -92,7 +96,19 @@ func (this *Activity) CreateHdData() (err error) {
} }
this.modelhdList.addHdList(db) this.modelhdList.addHdInfo(db)
fmt.Printf("%v", db) fmt.Printf("%v", db)
return return
} }
func (this *Activity) GetAllHdInfo() (result []*pb.DBHuodong, err error) {
result, err = this.modelhdList.getHdInfo()
return
}
// 通过活动ID查找
func (this *Activity) GetHdInfoByHdId(hid int32) (result *pb.DBHuodong, err error) {
result, err = this.modelhdList.getHdInfoByHdId(hid)
return
}

View File

@ -52,7 +52,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
} }
// 准备数据 // 准备数据
///////////////////////////////////// /////////////////////////////////////
drawConf, err = this.module.configure.GetHeroDrawConfigByType(req.DrawType + comm.DrawCardType0) // 获取新的抽卡配置 drawConf, err = this.module.configure.GetHeroDrawConfigByType(req.DrawType) // 获取新的抽卡配置
if err != nil { if err != nil {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError, Code: pb.ErrorCode_ReqParameterError,

View File

@ -37,6 +37,11 @@ const (
hero_draw = "game_drawpool.json" // 新版抽卡 hero_draw = "game_drawpool.json" // 新版抽卡
hero_cardweight = "game_drawweight.json" // 新版抽卡权重 hero_cardweight = "game_drawweight.json" // 新版抽卡权重
hero_cardpool = "game_cardpool.json" // 新版卡池 hero_cardpool = "game_cardpool.json" // 新版卡池
// 限定招募和许愿招募
draw_replace = "game_drawreplace.json" // 设置5星英雄
draw_reward = "game_drawreward.json" //新手招募奖励
) )
// /配置管理组件 // /配置管理组件
@ -49,6 +54,8 @@ type configureComp struct {
module *Hero module *Hero
starW map[int64]int32 starW map[int64]int32
cardPool map[string][]*cfg.GameCardPoolData cardPool map[string][]*cfg.GameCardPoolData
_selectPool map[int32][]*cfg.GamedrawReplaceData // 可选英雄卡池
} }
// 组件初始化接口 // 组件初始化接口
@ -71,6 +78,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
game_shopitem: cfg.NewGameShopitem, game_shopitem: cfg.NewGameShopitem,
hero_skill: cfg.NewGameHeroSkill, hero_skill: cfg.NewGameHeroSkill,
hero_draw: cfg.NewGameDrawPool, hero_draw: cfg.NewGameDrawPool,
draw_reward: cfg.NewGamedrawReward,
//hero_cardweight: cfg.NewGameDrawWeight, //hero_cardweight: cfg.NewGameDrawWeight,
}) })
//this.drawCardCfg = make(map[string]map[int32][]*cfg.GameDrawCardData, 0) //this.drawCardCfg = make(map[string]map[int32][]*cfg.GameDrawCardData, 0)
@ -144,6 +152,22 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
err = fmt.Errorf("%T no is *cfg.NewGameCardPool", v) err = fmt.Errorf("%T no is *cfg.NewGameCardPool", v)
} }
}) })
//可选卡池初始化
configure.RegisterConfigure(draw_reward, cfg.NewGamedrawReplace, func() {
if v, err := this.GetConfigure(hero_cardpool); err == nil {
if _configure, ok := v.(*cfg.GamedrawReplace); ok {
this.hlock.Lock()
defer this.hlock.Unlock()
this._selectPool = make(map[int32][]*cfg.GamedrawReplaceData)
for _, v := range _configure.GetDataList() {
this._selectPool[v.Pool] = append(this._selectPool[v.Pool], v)
}
return
}
} else {
err = fmt.Errorf("%T no is *cfg.NewGamedrawReplace", v)
}
})
return return
} }
@ -497,3 +521,31 @@ func (this *configureComp) GMGetTalentByHeroId(hid string) (data []*cfg.GameHero
return return
} }
// 获取指定抽的奖励
func (this *configureComp) GetHeroDrawRewardConfigById(id int32) (data *cfg.GamedrawRewardData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(draw_reward); err == nil {
if conf, ok := v.(*cfg.GamedrawReward); ok {
if data = conf.Get(id); data != nil {
return
}
}
}
err = comm.NewNotFoundConfErr(moduleName, draw_reward, id)
return
}
// 获取所有的奖励数据
func (this *configureComp) GetAllDrawRewardConfigById() (data map[int32]*cfg.GamedrawRewardData) {
if v, err := this.GetConfigure(draw_reward); err == nil {
if conf, ok := v.(*cfg.GamedrawReward); ok {
data = conf.GetDataMap()
}
}
return
}

View File

@ -299,8 +299,8 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen
} }
} }
for k, v := range addProperty { //for k, v := range addProperty {
addProperty[k] += v //addProperty[k] += v
// switch k { // switch k {
// case comm.AtkPro: // case comm.AtkPro:
// addProperty[comm.Atk] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Atk]))) // addProperty[comm.Atk] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Atk])))
@ -311,7 +311,7 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen
// case comm.SpeedPro: // case comm.SpeedPro:
// addProperty[comm.Speed] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Speed]))) // addProperty[comm.Speed] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Speed])))
// } // }
} //}
this.mergeAddProperty(hero.Uid, hero, addProperty, equipSkill) this.mergeAddProperty(hero.Uid, hero, addProperty, equipSkill)
} }

View File

@ -132,6 +132,7 @@ func main() {
wtask.NewModule(), wtask.NewModule(),
passon.NewModule(), passon.NewModule(),
warorder.NewModule(), warorder.NewModule(),
activity.NewModule(),
) )
} }