增加任务类型
This commit is contained in:
parent
ee7004e715
commit
a087b3f668
@ -46,7 +46,7 @@ var user_builders = []*TestCase{
|
||||
},
|
||||
},
|
||||
rsp: &pb.UserAddResResp{},
|
||||
// enabled: true,
|
||||
enabled: true,
|
||||
}, {
|
||||
desc: "获取配置",
|
||||
mainType: string(comm.ModuleUser),
|
||||
|
@ -127,7 +127,7 @@ func (this *ModelTask) taskHandle(uid string, taskType comm.TaskType, taskParam
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, conf := range data {
|
||||
for _, conf := range data {
|
||||
if conf.RestrictiveCondition != 0 {
|
||||
//不满足限定条件
|
||||
if taskParam.First < conf.RestrictiveCondition {
|
||||
@ -135,9 +135,13 @@ func (this *ModelTask) taskHandle(uid string, taskType comm.TaskType, taskParam
|
||||
}
|
||||
}
|
||||
|
||||
if taskParam.Second != conf.ConditionSecond {
|
||||
continue
|
||||
}
|
||||
|
||||
//检查进度,执行处理器
|
||||
if v, ok := this.checkTaskProgress(uid, conf); ok {
|
||||
if tt, err := this.finishHandle(v, conf); err != nil {
|
||||
if tt, err := this.finishHandle(v, conf, taskParam.Second); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return tt, nil
|
||||
@ -148,8 +152,8 @@ func (this *ModelTask) taskHandle(uid string, taskType comm.TaskType, taskParam
|
||||
}
|
||||
|
||||
//任务完成处理
|
||||
func (this *ModelTask) finishHandle(userTask *pb.DBTask, config *cfg.Game_taskRoundData) (*pb.DBTask, error) {
|
||||
progress := userTask.Progress - 1
|
||||
func (this *ModelTask) finishHandle(userTask *pb.DBTask, config *cfg.Game_taskRoundData, count int32) (*pb.DBTask, error) {
|
||||
progress := userTask.Progress - count
|
||||
if progress < 0 {
|
||||
return nil, fmt.Errorf("uid %s task[%s] was finished", userTask.Uid, userTask.Id)
|
||||
}
|
||||
|
@ -827,7 +827,8 @@ type TaskParam struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
First int32 `protobuf:"varint,1,opt,name=first,proto3" json:"first"` //限定条件
|
||||
First int32 `protobuf:"varint,1,opt,name=first,proto3" json:"first"` //限定条件
|
||||
Second int32 `protobuf:"varint,2,opt,name=second,proto3" json:"second"` //次数
|
||||
}
|
||||
|
||||
func (x *TaskParam) Reset() {
|
||||
@ -869,6 +870,13 @@ func (x *TaskParam) GetFirst() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *TaskParam) GetSecond() int32 {
|
||||
if x != nil {
|
||||
return x.Second
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_comm_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_comm_proto_rawDesc = []byte{
|
||||
@ -963,14 +971,16 @@ var file_comm_proto_rawDesc = []byte{
|
||||
0x73, 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x12, 0x0c, 0x0a, 0x01, 0x41, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x41, 0x12, 0x0c, 0x0a, 0x01, 0x54, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x01, 0x54, 0x12, 0x0c, 0x0a, 0x01, 0x4e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x01, 0x4e, 0x22, 0x21, 0x0a, 0x09, 0x54, 0x61, 0x73, 0x6b, 0x50, 0x61, 0x72, 0x61, 0x6d,
|
||||
0x52, 0x01, 0x4e, 0x22, 0x39, 0x0a, 0x09, 0x54, 0x61, 0x73, 0x6b, 0x50, 0x61, 0x72, 0x61, 0x6d,
|
||||
0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x2a, 0x43, 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f, 0x41, 0x74,
|
||||
0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06, 0x0a, 0x02,
|
||||
0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12, 0x07, 0x0a,
|
||||
0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65, 0x64, 0x10,
|
||||
0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x2a, 0x43,
|
||||
0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73,
|
||||
0x54, 0x79, 0x70, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03,
|
||||
0x41, 0x74, 0x6b, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09,
|
||||
0x0a, 0x05, 0x53, 0x70, 0x65, 0x65, 0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69,
|
||||
0x74, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -92,4 +92,5 @@ message UserAssets {
|
||||
|
||||
message TaskParam {
|
||||
int32 first = 1; //限定条件
|
||||
int32 second = 2; //次数
|
||||
}
|
Loading…
Reference in New Issue
Block a user