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 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 resp.Data = list
session.SendMsg(string(this.module.GetType()), "getstory", resp) session.SendMsg(string(this.module.GetType()), "getstory", resp)
return return

View File

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

View File

@ -52,6 +52,21 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
return 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) { 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 v, err = this.GetConfigure(game_caravan); err == nil {
if configure, ok := v.(*cfg.GameCaravanCity); ok { if configure, ok := v.(*cfg.GameCaravanCity); ok {
if data = configure.Get(cityId); data == nil { if data = configure.Get(cityId); data != nil {
err = comm.NewNotFoundConfErr(moduleName, game_caravan, cityId) return
this.module.Errorln(err)
} }
return
} }
} }
err = comm.NewNotFoundConfErr(moduleName, game_caravan, cityId) 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 v, err = this.GetConfigure(game_caravan_lv); err == nil {
if configure, ok := v.(*cfg.GameCaravanLv); ok { if configure, ok := v.(*cfg.GameCaravanLv); ok {
if data = configure.Get(lv); data == nil { if data = configure.Get(lv); data != nil {
err = comm.NewNotFoundConfErr(moduleName, game_caravan_lv, lv) return
this.module.Errorln(err)
} }
return
} }
} }
err = comm.NewNotFoundConfErr(moduleName, game_caravan_lv, lv) err = comm.NewNotFoundConfErr(moduleName, game_caravan_lv, lv)
return 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) { func (this *configureComp) GetAllCaravanCity() (data []*cfg.GameCaravanCityData) {
if v, err := this.GetConfigure(game_caravan); err == nil { if v, err := this.GetConfigure(game_caravan); err == nil {
@ -137,6 +131,7 @@ func (this *configureComp) GetAllCaravanCity() (data []*cfg.GameCaravanCityData)
} }
return return
} }
func (this *configureComp) GetAllCaravanItem() (data []*cfg.GameCaravanThingData) { func (this *configureComp) GetAllCaravanItem() (data []*cfg.GameCaravanThingData) {
if v, err := this.GetConfigure(game_caravan_thing); err == nil { 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 { if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err {
// 创建一条数据 // 创建一条数据
result.Id = primitive.NewObjectID().Hex() result.Id = primitive.NewObjectID().Hex()
//result.Resettime = utils.WeekIntervalTime()
result.Citystime = configure.Now().Unix() result.Citystime = configure.Now().Unix()
result.Rtime = configure.Now().Unix() result.Rtime = configure.Now().Unix()
result.Lv = 1 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.InitCaravanCityData(uid, result) // 初始1级
this.module.InitCaravanItemData(uid, result) this.module.InitCaravanItemData(uid, result)
this.Add(uid, result) err = this.Add(uid, result)
err = nil
return return
} }

View File

@ -2,6 +2,7 @@ package caravan
import ( import (
"context" "context"
"fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/mgo" "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) { func (this *ModelRank) SetUsrRankList(uid string) (result *pb.DBCaravanRank, err error) {
var (
user *pb.DBUser
model *db.DBModel
)
conn_, err := db.Cross() // 获取跨服数据库对象 conn_, err := db.Cross() // 获取跨服数据库对象
if err != nil { if err != nil {
return return
} }
user, err1 := this.module.ModuleUser.GetUser(uid) user, err = this.module.ModuleUser.GetUser(uid)
if err1 != nil { if err != nil {
err = err1
return return
} }
model := db.NewDBModelByExpired(comm.TableCaravanRank, conn_) if model = db.NewDBModelByExpired(comm.TableCaravanRank, conn_); model == nil {
if model == nil { err = fmt.Errorf("cand found table :%s,%v", comm.TableCaravanRank, conn_)
return return
} }
result = &pb.DBCaravanRank{} 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_smithytask, cfg.NewGameSmithyTask)
err = this.LoadConfigure(game_smithymake, cfg.NewGameSmithyMake) err = this.LoadConfigure(game_smithymake, cfg.NewGameSmithyMake)
this.GmGetAllAtlasConf()
return return
} }

View File

@ -21,6 +21,7 @@ func (this *apiComp) BookAward(session comm.IUserSession, req *pb.StonehengeBook
award []*pb.UserAssets award []*pb.UserAssets
ok bool ok bool
err error err error
atno []*pb.UserAtno
) )
if errdata = this.BookAwardCheck(session, req); errdata != nil { if errdata = this.BookAwardCheck(session, req); errdata != nil {
return return
@ -38,6 +39,7 @@ func (this *apiComp) BookAward(session comm.IUserSession, req *pb.StonehengeBook
for _, v := range confs { for _, v := range confs {
if v.Type == req.Btype && v.ColltectionNum == req.Stage { if v.Type == req.Btype && v.ColltectionNum == req.Stage {
conf = v conf = v
break
} }
} }
} }
@ -70,11 +72,11 @@ func (this *apiComp) BookAward(session comm.IUserSession, req *pb.StonehengeBook
} }
bookAward.Stage[conf.ColltectionNum] = true 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 return
} }
award = make([]*pb.UserAssets, 0) award = make([]*pb.UserAssets, 0)
for _, v := range conf.Reward { for _, v := range atno {
award = append(award, &pb.UserAssets{ award = append(award, &pb.UserAssets{
A: v.A, A: v.A,
T: v.T, 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}) 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) { 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 return
} }

View File

@ -123,12 +123,6 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.StonehengeBattleR
BattleEvents: battleConf.BattleReadyID, 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) errdata, record := this.module.battle.CreateStoneBattle(session, stoneBattle)
if errdata != nil { if errdata != nil {
return return

View File

@ -193,7 +193,14 @@ func (this *apiComp) Story(session comm.IUserSession, req *pb.StonehengeStoryReq
this.module.modelStonehenge.AddNewEvent([]int32{newEvent}, stone) this.module.modelStonehenge.AddNewEvent([]int32{newEvent}, stone)
} }
update["rooms"] = stone.Rooms 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{ session.SendMsg(string(this.module.GetType()), "story", &pb.StonehengeStoryResp{
Story: stone.Rooms.Story, Story: stone.Rooms.Story,
NewEvent: newEvent, 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) { func (this *configureComp) getGameStonePrivilegeData(privilegeId int32) (conf *cfg.GameStonePrivilegeData, err error) {
var ( var (
v interface{} v interface{}
ok bool
) )
if v, err = this.GetConfigure(game_stoneprivilege); err == nil { if v, err = this.GetConfigure(game_stoneprivilege); err == nil {
if configure, ok := v.(*cfg.GameStonePrivilege); ok {
if conf, ok = v.(*cfg.GameStonePrivilege).GetDataMap()[privilegeId]; ok { if conf = configure.Get(privilegeId); conf != nil {
return return
}
} }
} }
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_stonetask, privilegeId) err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_stonetask, privilegeId)