随机任务战斗任务

This commit is contained in:
wh_zcy 2022-09-13 19:48:17 +08:00
parent 37780c4694
commit f1ca15e4ec
3 changed files with 252 additions and 30 deletions

View File

@ -0,0 +1,24 @@
package rtask
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
func (this *apiComp) BattleFinishCheck(session comm.IUserSession, req *pb.RtaskBattleFinishReq) (code pb.ErrorCode) {
if req.Result == 0 {
code = pb.ErrorCode_ReqParameterError
}
return
}
func (this *apiComp) BattleFinish(session comm.IUserSession, req *pb.RtaskBattleFinishReq) (code pb.ErrorCode, data proto.Message) {
if code = this.BattleFinishCheck(session, req); code != pb.ErrorCode_Success {
return
}
return
}

View File

@ -12,6 +12,7 @@ const (
gameRtaskChoose = "game_rdtaskchoose.json"
gameRtaskCondi = "game_rdtaskcondi.json"
gameRtaskSide = "game_rdtaskside.json"
gameRtaskBattle = "game_rdtaskbattle.json"
)
type configureComp struct {
@ -25,6 +26,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
gameRtaskChoose: cfg.NewGameRdtaskChoose,
gameRtaskCondi: cfg.NewGameRdtaskCondi,
gameRtaskSide: cfg.NewGameRdtaskSide,
gameRtaskBattle: cfg.NewGameRdtaskBattle,
})
return
}
@ -93,6 +95,22 @@ func (this *configureComp) getRtaskSide() (data *cfg.GameRdtaskSide, err error)
return
}
func (this *configureComp) getRtaskBattle() (data *cfg.GameRdtaskBattle, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameRtaskBattle); err != nil {
return
} else {
if data, ok = v.(*cfg.GameRdtaskBattle); !ok {
err = fmt.Errorf("%T is *cfg.GameRdtaskBattle", v)
return
}
}
return
}
// 获取选项配置
func (this *configureComp) getRtaskChooseCfg(id int32) *cfg.GameRdtaskChooseData {
cfg, err := this.getRtaskChoose()
@ -145,3 +163,17 @@ func (this *configureComp) getRtaskById(taskId int32) (data *cfg.GameRdtaskData)
}
return nil
}
// 战斗配置
func (this *configureComp) getRtaskBattleById(id int32) (data *cfg.GameRdtaskBattleData) {
cfg, err := this.getRtaskBattle()
if err != nil {
return
}
if cfg != nil {
if data, ok := cfg.GetDataMap()[id]; ok {
return data
}
}
return nil
}

View File

@ -504,6 +504,133 @@ func (x *RtaskGetRewardResp) GetRtaskSubId() int32 {
return 0
}
// 战斗完成
type RtaskBattleFinishReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RtaskId int32 `protobuf:"varint,1,opt,name=rtaskId,proto3" json:"rtaskId"` //任务ID
ChooseId int32 `protobuf:"varint,2,opt,name=chooseId,proto3" json:"chooseId"` //选项配置ID
RtaskSubId int32 `protobuf:"varint,3,opt,name=rtaskSubId,proto3" json:"rtaskSubId"` //支线任务ID
Result int32 `protobuf:"varint,4,opt,name=result,proto3" json:"result"`
}
func (x *RtaskBattleFinishReq) Reset() {
*x = RtaskBattleFinishReq{}
if protoimpl.UnsafeEnabled {
mi := &file_rtask_rtask_msg_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RtaskBattleFinishReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RtaskBattleFinishReq) ProtoMessage() {}
func (x *RtaskBattleFinishReq) ProtoReflect() protoreflect.Message {
mi := &file_rtask_rtask_msg_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RtaskBattleFinishReq.ProtoReflect.Descriptor instead.
func (*RtaskBattleFinishReq) Descriptor() ([]byte, []int) {
return file_rtask_rtask_msg_proto_rawDescGZIP(), []int{9}
}
func (x *RtaskBattleFinishReq) GetRtaskId() int32 {
if x != nil {
return x.RtaskId
}
return 0
}
func (x *RtaskBattleFinishReq) GetChooseId() int32 {
if x != nil {
return x.ChooseId
}
return 0
}
func (x *RtaskBattleFinishReq) GetRtaskSubId() int32 {
if x != nil {
return x.RtaskSubId
}
return 0
}
func (x *RtaskBattleFinishReq) GetResult() int32 {
if x != nil {
return x.Result
}
return 0
}
type RtaskBattleFinishResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Bid int32 `protobuf:"varint,1,opt,name=bid,proto3" json:"bid"` //战斗配置ID
RtaskId int32 `protobuf:"varint,2,opt,name=rtaskId,proto3" json:"rtaskId"` //任务ID
}
func (x *RtaskBattleFinishResp) Reset() {
*x = RtaskBattleFinishResp{}
if protoimpl.UnsafeEnabled {
mi := &file_rtask_rtask_msg_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RtaskBattleFinishResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RtaskBattleFinishResp) ProtoMessage() {}
func (x *RtaskBattleFinishResp) ProtoReflect() protoreflect.Message {
mi := &file_rtask_rtask_msg_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RtaskBattleFinishResp.ProtoReflect.Descriptor instead.
func (*RtaskBattleFinishResp) Descriptor() ([]byte, []int) {
return file_rtask_rtask_msg_proto_rawDescGZIP(), []int{10}
}
func (x *RtaskBattleFinishResp) GetBid() int32 {
if x != nil {
return x.Bid
}
return 0
}
func (x *RtaskBattleFinishResp) GetRtaskId() int32 {
if x != nil {
return x.RtaskId
}
return 0
}
// 测试使用
type RtaskTestReq struct {
state protoimpl.MessageState
@ -518,7 +645,7 @@ type RtaskTestReq struct {
func (x *RtaskTestReq) Reset() {
*x = RtaskTestReq{}
if protoimpl.UnsafeEnabled {
mi := &file_rtask_rtask_msg_proto_msgTypes[9]
mi := &file_rtask_rtask_msg_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -531,7 +658,7 @@ func (x *RtaskTestReq) String() string {
func (*RtaskTestReq) ProtoMessage() {}
func (x *RtaskTestReq) ProtoReflect() protoreflect.Message {
mi := &file_rtask_rtask_msg_proto_msgTypes[9]
mi := &file_rtask_rtask_msg_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -544,7 +671,7 @@ func (x *RtaskTestReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use RtaskTestReq.ProtoReflect.Descriptor instead.
func (*RtaskTestReq) Descriptor() ([]byte, []int) {
return file_rtask_rtask_msg_proto_rawDescGZIP(), []int{9}
return file_rtask_rtask_msg_proto_rawDescGZIP(), []int{11}
}
func (x *RtaskTestReq) GetRtaskType() int32 {
@ -579,7 +706,7 @@ type RtaskTestResp struct {
func (x *RtaskTestResp) Reset() {
*x = RtaskTestResp{}
if protoimpl.UnsafeEnabled {
mi := &file_rtask_rtask_msg_proto_msgTypes[10]
mi := &file_rtask_rtask_msg_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -592,7 +719,7 @@ func (x *RtaskTestResp) String() string {
func (*RtaskTestResp) ProtoMessage() {}
func (x *RtaskTestResp) ProtoReflect() protoreflect.Message {
mi := &file_rtask_rtask_msg_proto_msgTypes[10]
mi := &file_rtask_rtask_msg_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -605,7 +732,7 @@ func (x *RtaskTestResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use RtaskTestResp.ProtoReflect.Descriptor instead.
func (*RtaskTestResp) Descriptor() ([]byte, []int) {
return file_rtask_rtask_msg_proto_rawDescGZIP(), []int{10}
return file_rtask_rtask_msg_proto_rawDescGZIP(), []int{12}
}
func (x *RtaskTestResp) GetFlag() bool {
@ -658,16 +785,29 @@ var file_rtask_rtask_msg_proto_rawDesc = []byte{
0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x72, 0x74, 0x61, 0x73, 0x6b,
0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x53, 0x75, 0x62, 0x49, 0x64,
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x53, 0x75, 0x62,
0x49, 0x64, 0x22, 0x5e, 0x0a, 0x0c, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x65, 0x73, 0x74, 0x52,
0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65,
0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05,
0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x64,
0x69, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x64, 0x69,
0x49, 0x64, 0x22, 0x23, 0x0a, 0x0d, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x65, 0x73, 0x74, 0x52,
0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x6c, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28,
0x08, 0x52, 0x04, 0x66, 0x6c, 0x61, 0x67, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x49, 0x64, 0x22, 0x84, 0x01, 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, 0x1a, 0x0a, 0x08, 0x63, 0x68, 0x6f, 0x6f, 0x73, 0x65, 0x49,
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x68, 0x6f, 0x6f, 0x73, 0x65, 0x49,
0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x53, 0x75, 0x62, 0x49, 0x64, 0x18,
0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x53, 0x75, 0x62, 0x49,
0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28,
0x05, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x43, 0x0a, 0x15, 0x52, 0x74, 0x61,
0x73, 0x6b, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65,
0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x62, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
0x03, 0x62, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18,
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x5e,
0x0a, 0x0c, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x1c,
0x0a, 0x09, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
0x05, 0x52, 0x09, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06,
0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, 0x52, 0x06, 0x70, 0x61,
0x72, 0x61, 0x6d, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x49, 0x64, 0x18,
0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x49, 0x64, 0x22, 0x23,
0x0a, 0x0d, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12,
0x12, 0x0a, 0x04, 0x66, 0x6c, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x66,
0x6c, 0x61, 0x67, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
@ -682,19 +822,21 @@ func file_rtask_rtask_msg_proto_rawDescGZIP() []byte {
return file_rtask_rtask_msg_proto_rawDescData
}
var file_rtask_rtask_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_rtask_rtask_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
var file_rtask_rtask_msg_proto_goTypes = []interface{}{
(*RtaskApplyReq)(nil), // 0: RtaskApplyReq
(*RtaskApplyResp)(nil), // 1: RtaskApplyResp
(*RtasklistReq)(nil), // 2: RtasklistReq
(*RtasklistResp)(nil), // 3: RtasklistResp
(*RtaskChooseReq)(nil), // 4: RtaskChooseReq
(*RtaskChooseResp)(nil), // 5: RtaskChooseResp
(*RtaskFinishPush)(nil), // 6: RtaskFinishPush
(*RtaskGetRewardReq)(nil), // 7: RtaskGetRewardReq
(*RtaskGetRewardResp)(nil), // 8: RtaskGetRewardResp
(*RtaskTestReq)(nil), // 9: RtaskTestReq
(*RtaskTestResp)(nil), // 10: RtaskTestResp
(*RtaskApplyReq)(nil), // 0: RtaskApplyReq
(*RtaskApplyResp)(nil), // 1: RtaskApplyResp
(*RtasklistReq)(nil), // 2: RtasklistReq
(*RtasklistResp)(nil), // 3: RtasklistResp
(*RtaskChooseReq)(nil), // 4: RtaskChooseReq
(*RtaskChooseResp)(nil), // 5: RtaskChooseResp
(*RtaskFinishPush)(nil), // 6: RtaskFinishPush
(*RtaskGetRewardReq)(nil), // 7: RtaskGetRewardReq
(*RtaskGetRewardResp)(nil), // 8: RtaskGetRewardResp
(*RtaskBattleFinishReq)(nil), // 9: RtaskBattleFinishReq
(*RtaskBattleFinishResp)(nil), // 10: RtaskBattleFinishResp
(*RtaskTestReq)(nil), // 11: RtaskTestReq
(*RtaskTestResp)(nil), // 12: RtaskTestResp
}
var file_rtask_rtask_msg_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
@ -819,7 +961,7 @@ func file_rtask_rtask_msg_proto_init() {
}
}
file_rtask_rtask_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RtaskTestReq); i {
switch v := v.(*RtaskBattleFinishReq); i {
case 0:
return &v.state
case 1:
@ -831,6 +973,30 @@ func file_rtask_rtask_msg_proto_init() {
}
}
file_rtask_rtask_msg_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RtaskBattleFinishResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_rtask_rtask_msg_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RtaskTestReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_rtask_rtask_msg_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RtaskTestResp); i {
case 0:
return &v.state
@ -849,7 +1015,7 @@ func file_rtask_rtask_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_rtask_rtask_msg_proto_rawDesc,
NumEnums: 0,
NumMessages: 11,
NumMessages: 13,
NumExtensions: 0,
NumServices: 0,
},