This commit is contained in:
meixiongfeng 2023-11-21 19:16:14 +08:00
parent c580f74eb2
commit bf5f14fb82
10 changed files with 57 additions and 51 deletions

View File

@ -70,7 +70,14 @@ func (this *apiComp) GetStory(session comm.IUserSession, req *pb.CaravanGetStory
update["tasktime"] = list.Tasktime
}
this.module.modelCaravan.modifyCaravanDataByObjId(session.GetUserId(), update)
if err = this.module.modelCaravan.modifyCaravanDataByObjId(session.GetUserId(), update); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
resp.Data = list
session.SendMsg(string(this.module.GetType()), "getstory", resp)
return

View File

@ -36,7 +36,7 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.CaravanRankList
Name: userinfo.Name,
Userlv: userinfo.Lv,
Avatar: userinfo.Avatar,
Rank: rankid, // rankid为0 表示未上榜
Rank: rankid,
Merchantmoney: userinfo.Merchantmoney,
CaravanLv: userinfo.Caravanlv,
Title: userinfo.Curtitle,

View File

@ -52,6 +52,21 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
return
}
func (this *configureComp) GetCaravanGoods(itemId string) (data *cfg.GameCaravanThingData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_caravan_thing); err == nil {
if configure, ok := v.(*cfg.GameCaravanThing); ok {
if data = configure.Get(itemId); data != nil {
return
}
}
}
err = comm.NewNotFoundConfErr(moduleName, game_caravan_thing, itemId)
this.module.Errorln(err)
return
}
// 加载多个配置文件
func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) {
@ -77,11 +92,9 @@ func (this *configureComp) GetCaravanCity(cityId int32) (data *cfg.GameCaravanCi
)
if v, err = this.GetConfigure(game_caravan); err == nil {
if configure, ok := v.(*cfg.GameCaravanCity); ok {
if data = configure.Get(cityId); data == nil {
err = comm.NewNotFoundConfErr(moduleName, game_caravan, cityId)
this.module.Errorln(err)
if data = configure.Get(cityId); data != nil {
return
}
return
}
}
err = comm.NewNotFoundConfErr(moduleName, game_caravan, cityId)
@ -95,34 +108,15 @@ func (this *configureComp) GetCaravanLv(lv int32) (data *cfg.GameCaravanLvData,
)
if v, err = this.GetConfigure(game_caravan_lv); err == nil {
if configure, ok := v.(*cfg.GameCaravanLv); ok {
if data = configure.Get(lv); data == nil {
err = comm.NewNotFoundConfErr(moduleName, game_caravan_lv, lv)
this.module.Errorln(err)
if data = configure.Get(lv); data != nil {
return
}
return
}
}
err = comm.NewNotFoundConfErr(moduleName, game_caravan_lv, lv)
return
}
func (this *configureComp) GetCaravanGoods(itemId string) (data *cfg.GameCaravanThingData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_caravan_thing); err == nil {
if configure, ok := v.(*cfg.GameCaravanThing); ok {
if data = configure.Get(itemId); data == nil {
err = comm.NewNotFoundConfErr(moduleName, game_caravan_thing, itemId)
this.module.Errorln(err)
}
return
}
}
err = comm.NewNotFoundConfErr(moduleName, game_caravan_thing, itemId)
return
}
func (this *configureComp) GetAllCaravanCity() (data []*cfg.GameCaravanCityData) {
if v, err := this.GetConfigure(game_caravan); err == nil {
@ -137,6 +131,7 @@ func (this *configureComp) GetAllCaravanCity() (data []*cfg.GameCaravanCityData)
}
return
}
func (this *configureComp) GetAllCaravanItem() (data []*cfg.GameCaravanThingData) {
if v, err := this.GetConfigure(game_caravan_thing); err == nil {

View File

@ -48,7 +48,6 @@ func (this *modelCaravan) getCaravanList(uid string) (result *pb.DBCaravan, err
if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err {
// 创建一条数据
result.Id = primitive.NewObjectID().Hex()
//result.Resettime = utils.WeekIntervalTime()
result.Citystime = configure.Now().Unix()
result.Rtime = configure.Now().Unix()
result.Lv = 1
@ -58,8 +57,7 @@ func (this *modelCaravan) getCaravanList(uid string) (result *pb.DBCaravan, err
}
this.module.InitCaravanCityData(uid, result) // 初始1级
this.module.InitCaravanItemData(uid, result)
this.Add(uid, result)
err = nil
err = this.Add(uid, result)
return
}

View File

@ -2,6 +2,7 @@ package caravan
import (
"context"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/mgo"
@ -33,17 +34,20 @@ func (this *ModelRank) Init(service core.IService, module core.IModule, comp cor
}
func (this *ModelRank) SetUsrRankList(uid string) (result *pb.DBCaravanRank, err error) {
var (
user *pb.DBUser
model *db.DBModel
)
conn_, err := db.Cross() // 获取跨服数据库对象
if err != nil {
return
}
user, err1 := this.module.ModuleUser.GetUser(uid)
if err1 != nil {
err = err1
user, err = this.module.ModuleUser.GetUser(uid)
if err != nil {
return
}
model := db.NewDBModelByExpired(comm.TableCaravanRank, conn_)
if model == nil {
if model = db.NewDBModelByExpired(comm.TableCaravanRank, conn_); model == nil {
err = fmt.Errorf("cand found table :%s,%v", comm.TableCaravanRank, conn_)
return
}
result = &pb.DBCaravanRank{}

View File

@ -60,7 +60,6 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
err = this.LoadConfigure(game_smithytask, cfg.NewGameSmithyTask)
err = this.LoadConfigure(game_smithymake, cfg.NewGameSmithyMake)
this.GmGetAllAtlasConf()
return
}

View File

@ -21,6 +21,7 @@ func (this *apiComp) BookAward(session comm.IUserSession, req *pb.StonehengeBook
award []*pb.UserAssets
ok bool
err error
atno []*pb.UserAtno
)
if errdata = this.BookAwardCheck(session, req); errdata != nil {
return
@ -38,6 +39,7 @@ func (this *apiComp) BookAward(session comm.IUserSession, req *pb.StonehengeBook
for _, v := range confs {
if v.Type == req.Btype && v.ColltectionNum == req.Stage {
conf = v
break
}
}
}
@ -70,11 +72,11 @@ func (this *apiComp) BookAward(session comm.IUserSession, req *pb.StonehengeBook
}
bookAward.Stage[conf.ColltectionNum] = true
if errdata = this.module.DispenseRes(session, conf.Reward, true); errdata != nil {
if errdata, atno = this.module.DispenseAtno(session, conf.Reward, true); errdata != nil {
return
}
award = make([]*pb.UserAssets, 0)
for _, v := range conf.Reward {
for _, v := range atno {
award = append(award, &pb.UserAssets{
A: v.A,
T: v.T,
@ -94,7 +96,7 @@ func (this *apiComp) BookAward(session comm.IUserSession, req *pb.StonehengeBook
session.SendMsg(string(this.module.GetType()), "bookaward", &pb.StonehengeBookAwardResp{Btype: req.Btype, Stage: req.Stage, Award: award})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "StonehengeBookAwardReq", award)
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "StonehengeBookAwardReq", atno)
})
return
}

View File

@ -123,12 +123,6 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.StonehengeBattleR
BattleEvents: battleConf.BattleReadyID,
}
// if _, ok := stone.Rooms.Passive[EventType30]; ok {
// }
// if _, ok := stone.Rooms.Passive[EventType31]; ok { // 扣我方血量
// }
errdata, record := this.module.battle.CreateStoneBattle(session, stoneBattle)
if errdata != nil {
return

View File

@ -193,7 +193,14 @@ func (this *apiComp) Story(session comm.IUserSession, req *pb.StonehengeStoryReq
this.module.modelStonehenge.AddNewEvent([]int32{newEvent}, stone)
}
update["rooms"] = stone.Rooms
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
if err = this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.String(),
Message: err.Error(),
}
return
}
session.SendMsg(string(this.module.GetType()), "story", &pb.StonehengeStoryResp{
Story: stone.Rooms.Story,
NewEvent: newEvent,

View File

@ -682,13 +682,13 @@ func (this *configureComp) getGameStoneTaskDatas() (confs []*cfg.GameStoneTaskDa
// 获取特权信息
func (this *configureComp) getGameStonePrivilegeData(privilegeId int32) (conf *cfg.GameStonePrivilegeData, err error) {
var (
v interface{}
ok bool
v interface{}
)
if v, err = this.GetConfigure(game_stoneprivilege); err == nil {
if conf, ok = v.(*cfg.GameStonePrivilege).GetDataMap()[privilegeId]; ok {
return
if configure, ok := v.(*cfg.GameStonePrivilege); ok {
if conf = configure.Get(privilegeId); conf != nil {
return
}
}
}
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_stonetask, privilegeId)