更新记数规则

This commit is contained in:
wh_zcy 2023-03-17 17:51:07 +08:00
parent f677a55ecc
commit e2890b1a59
6 changed files with 67 additions and 32 deletions

View File

@ -108,7 +108,14 @@ func (d *DispatchView) CreateView(t *model.TestCase) fyne.CanvasObject {
logrus.Debug("heroId参数不能为空")
return
}
heroIds := []string{hero1.Text,hero2.Text}
heroIds := []string{}
if hero1.Text!=""{
heroIds = append(heroIds, hero1.Text)
}
if hero2.Text!=""{
heroIds = append(heroIds, hero2.Text)
}
if err := service.GetPttService().SendToClient(
t.MainType,
"do",

View File

@ -19,18 +19,20 @@ func (a *apiComp) Autoreceive(session comm.IUserSession, req *pb.DispatchAutoRec
code = pb.ErrorCode_DataNotFound
return
}
var flag bool
// var flag bool
for _, v := range d.Nb.Tasks {
if v.Status == 2 {
flag = true
break
// flag = true
d.Nb.TaskCount++
d.Nb.WeekCount++
continue
}
}
if !flag {
code = pb.ErrorCode_DispatchNoFinished
return
}
// if !flag {
// code = pb.ErrorCode_DispatchNoFinished
// return
// }
tasks, oldTasks := a.module.modelDispatch.replaceFinishedTask(session.GetUserId(), d)

View File

@ -15,6 +15,13 @@ func (a *apiComp) DoCheck(session comm.IUserSession, req *pb.DispatchDoReq) (cod
code = pb.ErrorCode_ReqParameterError
return
}
for _, h := range req.HeroIds {
if h == "" {
code = pb.ErrorCode_ReqParameterError
return
}
}
return
}
@ -23,6 +30,22 @@ func (a *apiComp) Do(session comm.IUserSession, req *pb.DispatchDoReq) (code pb.
return
}
dConf, err := a.module.configure.getDispatchTaskConf(req.TaskId)
if err != nil {
code = pb.ErrorCode_SystemError
return
}
if dConf == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
if len(req.HeroIds) < int(dConf.Taskneed) {
code = pb.ErrorCode_DispatchHeroNoEnough
return
}
d := a.module.modelDispatch.getDBDispatch(session.GetUserId())
if d == nil && d.Nb == nil {
code = pb.ErrorCode_DataNotFound

View File

@ -45,13 +45,14 @@ func (a *apiComp) Receive(session comm.IUserSession, req *pb.DispatchReceiveReq)
tasks, oldTask := a.module.modelDispatch.replaceTask(session.GetUserId(), req.TaskId, d)
//更新公告任务
d.Nb.TaskCount++
d.Nb.WeekCount++
if err := a.module.modelDispatch.updateTasks(session.GetUserId(), d.Nb, tasks); err != nil {
a.module.Debug("更新公告失败", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "taskId", Value: req.TaskId})
return
}
//奖励
if oldTask != nil && oldTask.TaskId == req.TaskId {
gd, err := a.module.configure.getDispatchTaskConf(oldTask.TaskId)
if err != nil {

View File

@ -418,21 +418,6 @@ func (this *modelDispatch) updateNotice(uid string, dispatch *pb.DBDispatch) err
if err != nil || conf == nil {
return err
}
if dispatch.Nb.TaskCount >= conf.Upgrade {
//判断是否有下一等级
nextConf, err := this.module.configure.getDispatchLvConf(dispatch.Nb.Lv + 1)
if err != nil {
return err
}
if nextConf != nil {
dispatch.Nb.Lv++
dispatch.Nb.TaskCount = 0
}
}
//累计任务数
dispatch.Nb.TaskCount++
dispatch.Nb.WeekCount++
}
}
@ -448,7 +433,7 @@ func (this *modelDispatch) updateNotice(uid string, dispatch *pb.DBDispatch) err
}
}
this.module.Debug("随机数量:", log.Field{Key: "count", Value: randCount})
//刷新任务
count := len(dispatch.Nb.Tasks)
if count < 6 {
randCount = 6 - count
@ -460,6 +445,18 @@ func (this *modelDispatch) updateNotice(uid string, dispatch *pb.DBDispatch) err
}
}
//判断是否有下一等级
nextConf, err := this.module.configure.getDispatchLvConf(dispatch.Nb.Lv + 1)
if nextConf != nil {
if dispatch.Nb.TaskCount >= nextConf.Upgrade {
if err != nil {
return err
}
dispatch.Nb.Lv++
dispatch.Nb.TaskCount = 0
}
}
return this.updateTasks(uid, dispatch.Nb, dispatch.Nb.Tasks)
}

View File

@ -344,6 +344,7 @@ const (
ErrorCode_DispatchTaskExpired ErrorCode = 4205 //任务已过期
ErrorCode_DispatchRefreshMax ErrorCode = 4206 //达到最大刷新次数
ErrorCode_DispatchNoFinished ErrorCode = 4207 //任务未完成
ErrorCode_DispatchHeroNoEnough ErrorCode = 4208 //派遣英雄数量不足
//practice
ErrorCode_PracticeQiecuoing ErrorCode = 4301 //武馆切磋中
ErrorCode_PracticeSent ErrorCode = 4302 //邀请已发送 10秒内请勿重复邀请
@ -641,6 +642,7 @@ var (
4205: "DispatchTaskExpired",
4206: "DispatchRefreshMax",
4207: "DispatchNoFinished",
4208: "DispatchHeroNoEnough",
4301: "PracticeQiecuoing",
4302: "PracticeSent",
4303: "PracticeInviteTimeOut",
@ -934,6 +936,7 @@ var (
"DispatchTaskExpired": 4205,
"DispatchRefreshMax": 4206,
"DispatchNoFinished": 4207,
"DispatchHeroNoEnough": 4208,
"PracticeQiecuoing": 4301,
"PracticeSent": 4302,
"PracticeInviteTimeOut": 4303,
@ -971,7 +974,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2a, 0x86, 0x35, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x6f, 0x2a, 0xa1, 0x35, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
@ -1391,12 +1394,14 @@ var file_errorcode_proto_rawDesc = []byte{
0x20, 0x12, 0x17, 0x0a, 0x12, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x66,
0x72, 0x65, 0x73, 0x68, 0x4d, 0x61, 0x78, 0x10, 0xee, 0x20, 0x12, 0x17, 0x0a, 0x12, 0x44, 0x69,
0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64,
0x10, 0xef, 0x20, 0x12, 0x16, 0x0a, 0x11, 0x50, 0x72, 0x61, 0x63, 0x74, 0x69, 0x63, 0x65, 0x51,
0x69, 0x65, 0x63, 0x75, 0x6f, 0x69, 0x6e, 0x67, 0x10, 0xcd, 0x21, 0x12, 0x11, 0x0a, 0x0c, 0x50,
0x72, 0x61, 0x63, 0x74, 0x69, 0x63, 0x65, 0x53, 0x65, 0x6e, 0x74, 0x10, 0xce, 0x21, 0x12, 0x1a,
0x0a, 0x15, 0x50, 0x72, 0x61, 0x63, 0x74, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65,
0x54, 0x69, 0x6d, 0x65, 0x4f, 0x75, 0x74, 0x10, 0xcf, 0x21, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x10, 0xef, 0x20, 0x12, 0x19, 0x0a, 0x14, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x48,
0x65, 0x72, 0x6f, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xf0, 0x20, 0x12, 0x16,
0x0a, 0x11, 0x50, 0x72, 0x61, 0x63, 0x74, 0x69, 0x63, 0x65, 0x51, 0x69, 0x65, 0x63, 0x75, 0x6f,
0x69, 0x6e, 0x67, 0x10, 0xcd, 0x21, 0x12, 0x11, 0x0a, 0x0c, 0x50, 0x72, 0x61, 0x63, 0x74, 0x69,
0x63, 0x65, 0x53, 0x65, 0x6e, 0x74, 0x10, 0xce, 0x21, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x72, 0x61,
0x63, 0x74, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x4f,
0x75, 0x74, 0x10, 0xcf, 0x21, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (