diff --git a/modules/dispatch/model_dispatch.go b/modules/dispatch/model_dispatch.go index c6008d332..1686f08d2 100644 --- a/modules/dispatch/model_dispatch.go +++ b/modules/dispatch/model_dispatch.go @@ -1,6 +1,7 @@ package dispatch import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" @@ -131,10 +132,14 @@ func (this *modelDispatch) randomTask(dispatch *pb.DBDispatch, n int) (tasks []* if rid == 0 { return nil } + conf, _ := this.module.configure.getDispatchTaskConf(rid) + + race := comm.GetRandW(conf.Raceweight) + 1 if _, ok := existmap[rid]; !ok { tasks = append(tasks, &pb.DispatchTask{ TaskId: rid, + Race: race, }) total++ } @@ -213,6 +218,10 @@ func (this *modelDispatch) replaceFinishedTask(uid string, dispatch *pb.DBDispat // 验证英雄的条件 func (this *modelDispatch) validHeroCond(uid string, taskId int32, heroId string) (ok1, ok2 bool, err error) { + var ( + task *pb.DispatchTask + ) + //校验英雄是否已被派遣 dispatch := this.getDBDispatch(uid) if dispatch == nil { @@ -227,6 +236,16 @@ func (this *modelDispatch) validHeroCond(uid string, taskId int32, heroId string } } } + for _, v := range dispatch.Nb.Tasks { + if v.TaskId == taskId { + task = v + } + } + + if task == nil { + err = fmt.Errorf("no fund task:%d", taskId) + return + } //taskConf gd, err := this.module.configure.getDispatchTaskConf(taskId) @@ -267,34 +286,43 @@ func (this *modelDispatch) validHeroCond(uid string, taskId int32, heroId string } } - for _, v := range gd.Taskreqex { - if v.Key == 1 { - if hero.Lv >= v.Param { - ok2 = true - } else { - ok2 = false - break - } - } else if v.Key == 2 { - if hero.Star >= v.Param { - ok2 = true - } else { - ok2 = false - break - } - } else if v.Key == 3 { - hcfg, err2 := this.module.configure.GetHeroConfig(hero.HeroID) - if err2 != nil { - return false, false, err2 - } - if hcfg.Race == v.Param { - ok2 = true - } else { - ok2 = false - break - } - } + hcfg, err2 := this.module.configure.GetHeroConfig(hero.HeroID) + if err2 != nil { + return false, false, err2 } + if hcfg.Race == task.Race { + ok2 = true + } else { + ok2 = false + } + // for _, v := range gd.Taskreqex { + // if v.Key == 1 { + // if hero.Lv >= v.Param { + // ok2 = true + // } else { + // ok2 = false + // break + // } + // } else if v.Key == 2 { + // if hero.Star >= v.Param { + // ok2 = true + // } else { + // ok2 = false + // break + // } + // } else if v.Key == 3 { + // hcfg, err2 := this.module.configure.GetHeroConfig(hero.HeroID) + // if err2 != nil { + // return false, false, err2 + // } + // if hcfg.Race == v.Param { + // ok2 = true + // } else { + // ok2 = false + // break + // } + // } + // } } return diff --git a/pb/dispatch_db.pb.go b/pb/dispatch_db.pb.go index 0d8533e6a..61e933d84 100644 --- a/pb/dispatch_db.pb.go +++ b/pb/dispatch_db.pb.go @@ -26,9 +26,9 @@ type DBDispatch struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` // - Nb *Noticeboard `protobuf:"bytes,2,opt,name=nb,proto3" json:"nb" bson:"nb"` //公告栏 - Completecount map[int32]int32 `protobuf:"bytes,3,rep,name=completecount,proto3" json:"completecount" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //任务完成次数 + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` // + Nb *Noticeboard `protobuf:"bytes,2,opt,name=nb,proto3" json:"nb" bson:"nb"` //公告栏 + Completecount map[int32]int32 `protobuf:"bytes,3,rep,name=completecount,proto3" json:"completecount" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"completecount"` //公告栏 } func (x *DBDispatch) Reset() { @@ -203,11 +203,12 @@ type DispatchTask struct { unknownFields protoimpl.UnknownFields TaskId int32 `protobuf:"varint,1,opt,name=taskId,proto3" json:"taskId" bson:"taskId"` //任务ID - Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status" bson:"status"` //任务状态 默认0 1任务中 2任务完成 - Duration int64 `protobuf:"varint,3,opt,name=duration,proto3" json:"duration" bson:"duration"` //持续截至时间 - LeftTime int64 `protobuf:"varint,4,opt,name=leftTime,proto3" json:"leftTime" bson:"leftTime"` //任务截至时间 - HeroIds []string `protobuf:"bytes,5,rep,name=heroIds,proto3" json:"heroIds"` //go_tags(`bson:"heroIds"`) 派遣的英雄 - Exaward bool `protobuf:"varint,6,opt,name=exaward,proto3" json:"exaward" bson:"exaward"` //是否获取额外奖励 + Race int32 `protobuf:"varint,2,opt,name=race,proto3" json:"race" bson:"race"` //任务ID + Status int32 `protobuf:"varint,3,opt,name=status,proto3" json:"status" bson:"status"` //任务状态 默认0 1任务中 2任务完成 + Duration int64 `protobuf:"varint,4,opt,name=duration,proto3" json:"duration" bson:"duration"` //持续截至时间 + LeftTime int64 `protobuf:"varint,5,opt,name=leftTime,proto3" json:"leftTime" bson:"leftTime"` //任务截至时间 + HeroIds []string `protobuf:"bytes,6,rep,name=heroIds,proto3" json:"heroIds"` //go_tags(`bson:"heroIds"`) 派遣的英雄 + Exaward bool `protobuf:"varint,7,opt,name=exaward,proto3" json:"exaward" bson:"exaward"` //是否获取额外奖励 } func (x *DispatchTask) Reset() { @@ -249,6 +250,13 @@ func (x *DispatchTask) GetTaskId() int32 { return 0 } +func (x *DispatchTask) GetRace() int32 { + if x != nil { + return x.Race + } + return 0 +} + func (x *DispatchTask) GetStatus() int32 { if x != nil { return x.Status @@ -319,19 +327,20 @@ var file_dispatch_dispatch_db_proto_rawDesc = []byte{ 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x08, 0x20, 0x03, 0x28, 0x05, 0x52, 0x0c, 0x77, 0x65, 0x65, 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, - 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xaa, 0x01, 0x0a, 0x0c, 0x44, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xbe, 0x01, 0x0a, 0x0c, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, - 0x6b, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x64, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x64, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x65, 0x66, 0x74, 0x54, - 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6c, 0x65, 0x66, 0x74, 0x54, - 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x73, 0x18, 0x05, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x73, 0x12, 0x18, 0x0a, - 0x07, 0x65, 0x78, 0x61, 0x77, 0x61, 0x72, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, - 0x65, 0x78, 0x61, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6b, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x04, 0x72, 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x1a, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6c, + 0x65, 0x66, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6c, + 0x65, 0x66, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x49, + 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, + 0x73, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x78, 0x61, 0x77, 0x61, 0x72, 0x64, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x07, 0x65, 0x78, 0x61, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var (