Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
7af53cf7ff
@ -270,7 +270,7 @@ const (
|
||||
TableHdData = "hddata"
|
||||
|
||||
// 活动列表
|
||||
TableHdList = "huodong"
|
||||
TableHdInfo = "hdinfo"
|
||||
|
||||
//世界任务
|
||||
TableWtask = "wtask"
|
||||
|
@ -549,4 +549,9 @@ type (
|
||||
Delivery(session IUserSession, pid string) (errdata *pb.ErrorData, items []*pb.UserAssets)
|
||||
OpenWarorder(wtype int32, opentime int64)
|
||||
}
|
||||
|
||||
IActivity interface {
|
||||
GetHdInfoByHdId(hid int32) (result *pb.DBHuodong, err error) // 通过活动id 获取活动信息
|
||||
GetAllHdInfo() (result []*pb.DBHuodong, err error) // 获取所有活动信息
|
||||
}
|
||||
)
|
||||
|
@ -11,9 +11,10 @@ func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.ActivityGet
|
||||
return
|
||||
}
|
||||
|
||||
// 获取所有活动信息
|
||||
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 {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
|
@ -1,11 +1,13 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"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) {
|
||||
this.TableName = string(comm.TableHdList)
|
||||
this.TableName = string(comm.TableHdInfo)
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.module = module.(*Activity)
|
||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||
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
|
||||
}
|
||||
|
||||
func (this *modelHdList) getHdList(uid string) (result []*pb.DBHuodong, err error) {
|
||||
result = make([]*pb.DBHuodong, 0)
|
||||
if err = this.GetList(uid, &result); err != nil {
|
||||
this.module.Errorf("getActivityList db error: %v", err)
|
||||
err = nil
|
||||
func (this *modelHdList) getHdInfo() (result []*pb.DBHuodong, err error) {
|
||||
|
||||
if _data, err := this.DBModel.DB.Find(comm.TableHdInfo, bson.M{}); err == nil {
|
||||
for _data.Next(context.TODO()) {
|
||||
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
|
||||
}
|
||||
|
||||
// 不需要修改 此接口不调用
|
||||
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)
|
||||
}
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
@ -44,7 +44,11 @@ func (this *Activity) Init(service core.IService, module core.IModule, options c
|
||||
// }()
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Activity) Start() (err error) {
|
||||
err = this.ModuleBase.Start()
|
||||
//this.modelhdList.getHdInfoByHdId(10002)
|
||||
return
|
||||
}
|
||||
func (this *Activity) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
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)
|
||||
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
|
||||
}
|
||||
|
@ -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 {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
|
@ -37,6 +37,11 @@ const (
|
||||
hero_draw = "game_drawpool.json" // 新版抽卡
|
||||
hero_cardweight = "game_drawweight.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
|
||||
starW map[int64]int32
|
||||
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,
|
||||
hero_skill: cfg.NewGameHeroSkill,
|
||||
hero_draw: cfg.NewGameDrawPool,
|
||||
draw_reward: cfg.NewGamedrawReward,
|
||||
//hero_cardweight: cfg.NewGameDrawWeight,
|
||||
})
|
||||
//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)
|
||||
}
|
||||
})
|
||||
//可选卡池初始化
|
||||
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
|
||||
}
|
||||
|
||||
@ -497,3 +521,31 @@ func (this *configureComp) GMGetTalentByHeroId(hid string) (data []*cfg.GameHero
|
||||
|
||||
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
|
||||
}
|
||||
|
@ -299,8 +299,8 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen
|
||||
}
|
||||
}
|
||||
|
||||
for k, v := range addProperty {
|
||||
addProperty[k] += v
|
||||
//for k, v := range addProperty {
|
||||
//addProperty[k] += v
|
||||
// switch k {
|
||||
// case comm.AtkPro:
|
||||
// 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:
|
||||
// addProperty[comm.Speed] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Speed])))
|
||||
// }
|
||||
}
|
||||
//}
|
||||
this.mergeAddProperty(hero.Uid, hero, addProperty, equipSkill)
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,7 @@ func main() {
|
||||
wtask.NewModule(),
|
||||
passon.NewModule(),
|
||||
warorder.NewModule(),
|
||||
activity.NewModule(),
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user