修改随机任务战斗结束处理
This commit is contained in:
parent
f3319fa989
commit
b35f18cf26
@ -20,63 +20,48 @@ func (this *apiComp) BattleFinish(session comm.IUserSession, req *pb.RtaskBattle
|
||||
return
|
||||
}
|
||||
|
||||
//校验战斗结果
|
||||
iBattle, err := this.moduleRtask.modelRtask.service.GetModule(comm.ModuleBattle)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
|
||||
var isWin bool
|
||||
if b, y := iBattle.(comm.IBattle); y {
|
||||
if code, isWin = b.CheckBattleReport(session, req.Report); code != pb.ErrorCode_Success {
|
||||
if req.IsWin {
|
||||
// 获取玩家的任务
|
||||
rtask := &pb.DBRtask{}
|
||||
if err := this.moduleRtask.modelRtask.Get(session.GetUserId(), rtask); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if isWin {
|
||||
// 获取玩家的任务
|
||||
rtask := &pb.DBRtask{}
|
||||
if err := this.moduleRtask.modelRtask.Get(session.GetUserId(), rtask); err != nil {
|
||||
return
|
||||
}
|
||||
// 获取当前任务配置
|
||||
conf := this.moduleRtask.configure.getRtaskById(req.RtaskId)
|
||||
if conf == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
log.Errorf("rdtask %v no found", req.RtaskId)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取当前任务配置
|
||||
conf := this.moduleRtask.configure.getRtaskById(req.RtaskId)
|
||||
if conf == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
log.Errorf("rdtask %v no found", req.RtaskId)
|
||||
return
|
||||
}
|
||||
var (
|
||||
frtaskArr *pb.FrtaskIds //完成的任务
|
||||
ok bool
|
||||
)
|
||||
|
||||
var (
|
||||
frtaskArr *pb.FrtaskIds //完成的任务
|
||||
ok bool
|
||||
)
|
||||
if frtaskArr, ok = rtask.FrtaskIds[conf.Group]; !ok {
|
||||
frtaskArr = &pb.FrtaskIds{}
|
||||
}
|
||||
|
||||
if frtaskArr, ok = rtask.FrtaskIds[conf.Group]; !ok {
|
||||
frtaskArr = &pb.FrtaskIds{}
|
||||
}
|
||||
|
||||
// 更新完成的任务
|
||||
frtaskArr.RtaskIds = append(frtaskArr.RtaskIds, req.RtaskId)
|
||||
if rtask.FrtaskIds == nil {
|
||||
rtask.FrtaskIds = make(map[int32]*pb.FrtaskIds)
|
||||
}
|
||||
rtask.FrtaskIds[conf.Group] = frtaskArr
|
||||
update := map[string]interface{}{
|
||||
"frtaskIds": rtask.FrtaskIds,
|
||||
}
|
||||
if err := this.moduleRtask.modelRtask.Change(session.GetUserId(), update); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
// 更新完成的任务
|
||||
frtaskArr.RtaskIds = append(frtaskArr.RtaskIds, req.RtaskId)
|
||||
if rtask.FrtaskIds == nil {
|
||||
rtask.FrtaskIds = make(map[int32]*pb.FrtaskIds)
|
||||
}
|
||||
rtask.FrtaskIds[conf.Group] = frtaskArr
|
||||
update := map[string]interface{}{
|
||||
"frtaskIds": rtask.FrtaskIds,
|
||||
}
|
||||
if err := this.moduleRtask.modelRtask.Change(session.GetUserId(), update); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.moduleRtask.GetType()), RtaskSubTypeBattleFinish,
|
||||
&pb.RtaskBattleFinishResp{
|
||||
RtaskId: req.RtaskId,
|
||||
IsWin: isWin,
|
||||
}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
|
@ -622,6 +622,7 @@ type RtaskBattleFinishReq struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
RtaskId int32 `protobuf:"varint,1,opt,name=rtaskId,proto3" json:"rtaskId"` //任务ID
|
||||
IsWin bool `protobuf:"varint,2,opt,name=isWin,proto3" json:"isWin"` //战斗结果
|
||||
Report *BattleReport `protobuf:"bytes,4,opt,name=report,proto3" json:"report"` //战报
|
||||
}
|
||||
|
||||
@ -664,6 +665,13 @@ func (x *RtaskBattleFinishReq) GetRtaskId() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RtaskBattleFinishReq) GetIsWin() bool {
|
||||
if x != nil {
|
||||
return x.IsWin
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *RtaskBattleFinishReq) GetReport() *BattleReport {
|
||||
if x != nil {
|
||||
return x.Report
|
||||
@ -677,7 +685,6 @@ type RtaskBattleFinishResp struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
RtaskId int32 `protobuf:"varint,1,opt,name=rtaskId,proto3" json:"rtaskId"` //任务ID
|
||||
IsWin bool `protobuf:"varint,2,opt,name=isWin,proto3" json:"isWin"` //战斗结果
|
||||
}
|
||||
|
||||
func (x *RtaskBattleFinishResp) Reset() {
|
||||
@ -719,13 +726,6 @@ func (x *RtaskBattleFinishResp) GetRtaskId() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RtaskBattleFinishResp) GetIsWin() bool {
|
||||
if x != nil {
|
||||
return x.IsWin
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
//获取玩家任务记录
|
||||
type RtaskGetrecordReq struct {
|
||||
state protoimpl.MessageState
|
||||
@ -979,17 +979,17 @@ var file_rtask_rtask_msg_proto_rawDesc = []byte{
|
||||
0x22, 0x37, 0x0a, 0x14, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x53,
|
||||
0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1f, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49,
|
||||
0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x57, 0x0a, 0x14, 0x52, 0x74, 0x61,
|
||||
0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x6d, 0x0a, 0x14, 0x52, 0x74, 0x61,
|
||||
0x73, 0x6b, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65,
|
||||
0x71, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x07, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x06, 0x72,
|
||||
0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61,
|
||||
0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x06, 0x72, 0x65, 0x70, 0x6f,
|
||||
0x72, 0x74, 0x22, 0x47, 0x0a, 0x15, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x42, 0x61, 0x74, 0x74, 0x6c,
|
||||
0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x72,
|
||||
0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x72, 0x74,
|
||||
0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x73, 0x57, 0x69, 0x6e, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x69, 0x73, 0x57, 0x69, 0x6e, 0x22, 0x13, 0x0a, 0x11, 0x52,
|
||||
0x28, 0x05, 0x52, 0x07, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x69,
|
||||
0x73, 0x57, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x69, 0x73, 0x57, 0x69,
|
||||
0x6e, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||
0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74,
|
||||
0x52, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x31, 0x0a, 0x15, 0x52, 0x74, 0x61, 0x73,
|
||||
0x6b, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73,
|
||||
0x70, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x07, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x13, 0x0a, 0x11, 0x52,
|
||||
0x74, 0x61, 0x73, 0x6b, 0x47, 0x65, 0x74, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71,
|
||||
0x22, 0x3c, 0x0a, 0x12, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x47, 0x65, 0x74, 0x72, 0x65, 0x63, 0x6f,
|
||||
0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x26, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64,
|
||||
|
Loading…
Reference in New Issue
Block a user