上传随机任务接口以及底层对象支持

This commit is contained in:
liwei1dao 2022-08-30 17:57:32 +08:00
parent 8645ecfa17
commit 0f02d1b280
4 changed files with 29 additions and 2 deletions

View File

@ -113,7 +113,7 @@ type (
// 随机任务 // 随机任务
IRtask interface { IRtask interface {
//任务触发 //任务触发
SendToRtask(session IUserSession, rtaskType int32, params ...int32) (code pb.ErrorCode) SendToRtask(session IUserSession, rtaskType TaskType, params ...int32) (code pb.ErrorCode)
} }
//好友 //好友

View File

@ -5,6 +5,7 @@ import (
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@ -26,6 +27,9 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq)
equipment *pb.DB_Equipment equipment *pb.DB_Equipment
equipments []*pb.DB_Equipment equipments []*pb.DB_Equipment
updatequipment []*pb.DB_Equipment updatequipment []*pb.DB_Equipment
equipNum int32
equipStr map[int32]int32 = make(map[int32]int32)
equipLv map[int32]int32 = make(map[int32]int32)
hero *pb.DBHero hero *pb.DBHero
) )
@ -43,6 +47,7 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq)
for i, v := range req.EquipmentId { for i, v := range req.EquipmentId {
if v != "" { if v != "" {
equipNum++
if equipments[i], err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil { if equipments[i], err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
log.Errorf("Equip_Check err:%v", err) log.Errorf("Equip_Check err:%v", err)
code = pb.ErrorCode_EquipmentOnFoundEquipment code = pb.ErrorCode_EquipmentOnFoundEquipment
@ -52,12 +57,13 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq)
code = pb.ErrorCode_EquipmentIsWorn code = pb.ErrorCode_EquipmentIsWorn
return return
} }
equipLv[equipments[i].Lv]++
if confs[i], err = this.module.configure.GetEquipmentConfigureById(equipments[i].CId); err != nil { if confs[i], err = this.module.configure.GetEquipmentConfigureById(equipments[i].CId); err != nil {
log.Errorf("Equip_Check err:%v", err) log.Errorf("Equip_Check err:%v", err)
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
} }
equipStr[confs[i].Star]++
} else { } else {
equipments[i] = nil equipments[i] = nil
} }
@ -138,6 +144,13 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq)
code = pb.ErrorCode_SystemError code = pb.ErrorCode_SystemError
return return
} }
this.module.ModuleRtask.SendToRtask(session, comm.Rtype5, utils.ToInt32(hero.HeroID), equipNum)
for k, v := range equipStr {
this.module.ModuleRtask.SendToRtask(session, comm.Rtype41, utils.ToInt32(hero.HeroID), v, k)
}
for k, v := range equipLv {
this.module.ModuleRtask.SendToRtask(session, comm.Rtype42, utils.ToInt32(hero.HeroID), v, k)
}
session.SendMsg(string(this.module.GetType()), "equip", &pb.EquipmentEquipResp{Equipments: updatequipment}) session.SendMsg(string(this.module.GetType()), "equip", &pb.EquipmentEquipResp{Equipments: updatequipment})
return return
} }

View File

@ -31,6 +31,7 @@ type ModuleBase struct {
ModuleEquipment comm.IEquipment //装备模块 ModuleEquipment comm.IEquipment //装备模块
ModuleTask comm.ITask //任务 ModuleTask comm.ITask //任务
ModuleFriend comm.IFriend //好友 ModuleFriend comm.IFriend //好友
ModuleRtask comm.IRtask //随机任务
} }
//重构模块配置对象 //重构模块配置对象
@ -84,6 +85,11 @@ func (this *ModuleBase) Start() (err error) {
return return
} }
this.ModuleFriend = module.(comm.IFriend) this.ModuleFriend = module.(comm.IFriend)
if module, err = this.service.GetModule(comm.ModuleRtask); err != nil {
return
}
this.ModuleRtask = module.(comm.IRtask)
return return
} }

View File

@ -69,3 +69,11 @@ func IsNum(s string) bool {
_, err := strconv.ParseFloat(s, 64) _, err := strconv.ParseFloat(s, 64)
return err == nil return err == nil
} }
func ToInt32(s string) int32 {
if j, err := strconv.ParseInt(s, 10, 32); err != nil {
return 0
} else {
return int32(j)
}
}