fix: 修复日志格式化字符串错误和任务奖励逻辑
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -17,15 +17,13 @@ func (h Controller) IsCollect(
|
||||
ID: data.Type,
|
||||
}
|
||||
|
||||
c.Service.Task.Exec(uint32(1335), func(te *model.Task) bool {
|
||||
|
||||
r := bitset32.From(te.Data)
|
||||
// 分支未完成时,标记完成并发放奖励
|
||||
taskData, taskErr := c.Service.Task.GetTask(uint32(1335))
|
||||
if taskErr == nil {
|
||||
r := bitset32.From(taskData.Data)
|
||||
if r.Test(uint(data.Type)) {
|
||||
result.IsCom = 1
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
_, ok := lo.Find([]uint32{1, 2, 3, 4, 301}, func(item uint32) bool {
|
||||
return data.Type == item
|
||||
@@ -59,14 +57,17 @@ func (h Controller) Collect(
|
||||
return data.Type == item
|
||||
})
|
||||
if res == model.Completed && ok { //这块是为了兼容旧版本
|
||||
c.Service.Task.Exec(uint32(1335), func(te *model.Task) bool {
|
||||
taskData, taskErr := c.Service.Task.GetTask(uint32(1335))
|
||||
if taskErr != nil {
|
||||
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrSystemError)
|
||||
}
|
||||
|
||||
r := bitset32.From(te.Data)
|
||||
|
||||
r.Set(uint(data.Type))
|
||||
te.Data = r.Bytes()
|
||||
return true
|
||||
})
|
||||
r := bitset32.From(taskData.Data)
|
||||
r.Set(uint(data.Type))
|
||||
taskData.Data = r.Bytes()
|
||||
if taskErr = c.Service.Task.SetTask(taskData); taskErr != nil {
|
||||
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrSystemError)
|
||||
}
|
||||
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrSystemError)
|
||||
}
|
||||
|
||||
@@ -80,21 +81,22 @@ func (h Controller) Collect(
|
||||
if !lo.Contains(validIDs, data.ID) {
|
||||
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrSystemError)
|
||||
}
|
||||
c.Service.Task.Exec(uint32(1335), func(te *model.Task) bool {
|
||||
taskData, taskErr := c.Service.Task.GetTask(uint32(1335))
|
||||
if taskErr != nil {
|
||||
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrSystemError)
|
||||
}
|
||||
|
||||
r := bitset32.From(te.Data)
|
||||
// 分支未完成时,标记完成并发放奖励
|
||||
if !r.Test(uint(data.Type)) {
|
||||
r.Set(uint(data.Type))
|
||||
te.Data = r.Bytes()
|
||||
r := model.GenPetInfo(int(data.ID), -1, -1, 0, 1, nil, 0)
|
||||
c.Service.Pet.PetAdd(r, 0)
|
||||
result.CatchTime = r.CatchTime
|
||||
|
||||
return true
|
||||
r := bitset32.From(taskData.Data)
|
||||
if !r.Test(uint(data.Type)) {
|
||||
r.Set(uint(data.Type))
|
||||
taskData.Data = r.Bytes()
|
||||
if taskErr = c.Service.Task.SetTask(taskData); taskErr != nil {
|
||||
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrSystemError)
|
||||
}
|
||||
return false
|
||||
})
|
||||
petInfo := model.GenPetInfo(int(data.ID), -1, -1, 0, 1, nil, 0)
|
||||
c.Service.Pet.PetAdd(petInfo, 0)
|
||||
result.CatchTime = petInfo.CatchTime
|
||||
}
|
||||
|
||||
if result.CatchTime == 0 {
|
||||
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrAwardAlreadyClaimed)
|
||||
|
||||
Reference in New Issue
Block a user