批量打造优化

This commit is contained in:
meixiongfeng 2023-07-13 16:38:20 +08:00
parent 8dd12dd6d3
commit e1dc59f4fb
4 changed files with 48 additions and 44 deletions

View File

@ -186,7 +186,7 @@ type (
//查询服务资源数量 //查询服务资源数量
QueryEquipments(uid string) (equipment []*pb.DB_Equipment, errdata *pb.ErrorData) QueryEquipments(uid string) (equipment []*pb.DB_Equipment, errdata *pb.ErrorData)
//查询服务资源数量 db id //查询服务资源数量 db id
QueryEquipment(uid string, Id string) (equipment *pb.DB_Equipment, errdata *pb.ErrorData) QueryEquipment(uid string, Ids ...string) (equipment []*pb.DB_Equipment, errdata *pb.ErrorData)
//查询服务资源数量 参数武器配置id //查询服务资源数量 参数武器配置id
QueryEquipmentAmount(uid string, equipmentId string) (amount uint32) QueryEquipmentAmount(uid string, equipmentId string) (amount uint32)
//添加新武器 //添加新武器

View File

@ -19,7 +19,7 @@ type Activity struct {
modelhdList *modelHdList modelhdList *modelHdList
modelhdData *modelhdData modelhdData *modelhdData
warorder comm.IWarorder // 战令 //warorder comm.IWarorder // 战令
} }
func NewModule() core.IModule { func NewModule() core.IModule {
@ -52,11 +52,16 @@ func (this *Activity) Start() (err error) {
// 服务启动 获取活动信息 // 服务启动 获取活动信息
var module core.IModule var module core.IModule
if module, err = this.service.GetModule(comm.ModuleWarorder); err == nil { if module, err = this.service.GetModule(comm.ModuleWarorder); err == nil {
this.warorder = module.(comm.IWarorder) if m, ok := module.(comm.IWarorder); ok {
this.warorder.OpenWarorder(2, rst.Stime) m.OpenWarorder(2, rst.Stime)
}
} }
// if module, err = this.service.GetModule(comm.ModulePay); err == nil {
// if m, ok := module.(comm.IPay); ok {
// m.OpenActivity(1, rst.Stime)
// }
// }
} }
return return
} }
func (this *Activity) OnInstallComp() { func (this *Activity) OnInstallComp() {

View File

@ -77,31 +77,36 @@ func (this *Equipment) EventUserOffline(uid, sessionid string) {
// IEquipment------------------------------------------------------------------------------------------------------------------------------- // IEquipment-------------------------------------------------------------------------------------------------------------------------------
// 查询武器信息 // 查询武器信息
func (this *Equipment) QueryEquipment(uid string, id string) (equipment *pb.DB_Equipment, errdata *pb.ErrorData) { func (this *Equipment) QueryEquipment(uid string, ids ...string) (equipment []*pb.DB_Equipment, errdata *pb.ErrorData) {
var err error
if uid == "" || id == "" { for _, id := range ids {
this.Errorf("请求参数错误 uid:%s Id:%s", uid, id) if uid == "" || id == "" {
errdata = &pb.ErrorData{ this.Errorf("请求参数错误 uid:%s Id:%s", uid, id)
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
return
}
if equipment, err = this.modelEquipment.QueryUserEquipmentsById(uid, id); err != nil {
if err == redis.Nil {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{
Code: pb.ErrorCode_EquipmentOnFoundEquipment, Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_EquipmentOnFoundEquipment.ToString(), Title: pb.ErrorCode_ReqParameterError.ToString(),
Message: fmt.Sprintf("未找到装备 uid:%s id:%s", uid, id),
} }
continue
}
if equip, err := this.modelEquipment.QueryUserEquipmentsById(uid, id); err == nil {
equipment = append(equipment, equip)
} else { } else {
errdata = &pb.ErrorData{ if err == redis.Nil {
Code: pb.ErrorCode_SystemError, errdata = &pb.ErrorData{
Title: pb.ErrorCode_SystemError.ToString(), Code: pb.ErrorCode_EquipmentOnFoundEquipment,
Message: err.Error(), Title: pb.ErrorCode_EquipmentOnFoundEquipment.ToString(),
Message: fmt.Sprintf("未找到装备 uid:%s id:%s", uid, id),
}
} else {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
Message: err.Error(),
}
} }
} }
} }
return return
} }

View File

@ -33,8 +33,9 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
maxT int32 maxT int32
atno []*pb.UserAtno atno []*pb.UserAtno
lava *cfg.Gameatn lava *cfg.Gameatn
bQuality bool // 是否是精炼打造 bQuality bool // 是否是精炼打造
preHitCount int32 // 打造之前的次数 preHitCount int32 // 打造之前的次数
resReward []*cfg.Gameatn // 打造装备奖励
) )
// 参数校验 // 参数校验
if req.Count == 0 { // 传0 默认打造意见 if req.Count == 0 { // 传0 默认打造意见
@ -246,28 +247,21 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
for i := 0; i < int(req.Count); i++ { for i := 0; i < int(req.Count); i++ {
res := this.module.configure.GetDropReward(newdrop) res := this.module.configure.GetDropReward(newdrop)
if ok := this.module.modelStove.CheckForgetwoEquip(req.ReelId, stove.Data[req.ReelId].Lv, addProbability); ok { if ok := this.module.modelStove.CheckForgetwoEquip(req.ReelId, stove.Data[req.ReelId].Lv, addProbability); ok {
if errdata, atno = this.module.DispenseAtno(session, res, true); errdata == nil { resReward = append(resReward, res...)
for _, v := range atno {
if eq, e := this.module.ModuleEquipment.QueryEquipment(session.GetUserId(), v.O); e == nil {
rsp.Equip = append(rsp.Equip, eq)
}
}
} else {
return
}
} }
resReward = append(resReward, res...)
if errdata, atno = this.module.DispenseAtno(session, res, true); errdata == nil { }
for _, v := range atno { if errdata, atno = this.module.DispenseAtno(session, resReward, true); errdata == nil {
if eq, err1 := this.module.ModuleEquipment.QueryEquipment(session.GetUserId(), v.O); err1 == nil { ids := make([]string, 0)
rsp.Equip = append(rsp.Equip, eq) for _, v := range atno {
} ids = append(ids, v.O)
} }
} else { if rsp.Equip, errdata = this.module.ModuleEquipment.QueryEquipment(session.GetUserId(), ids...); errdata != nil {
return return
} }
} else {
return
} }
} }
if stoveLvConf, err := this.module.configure.GetSmithyStoveConf(stove.Lv); err == nil { if stoveLvConf, err := this.module.configure.GetSmithyStoveConf(stove.Lv); err == nil {