update
This commit is contained in:
parent
24c248323f
commit
bf56296aa6
@ -168,10 +168,19 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), WorldtaskSubtypeFinish, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
|
||||
// this.module.modelWorldtask.updateRandomTask(session.GetUserId(),userTask)
|
||||
// for k,v:=range userTask.CurrentTask{
|
||||
// nextTask[k] = &pb.Worldtask{
|
||||
// TaskId: v.TaskId,
|
||||
// }
|
||||
// }
|
||||
|
||||
if curTaskConf.IdAfter != 0 {
|
||||
// 任务完成推送
|
||||
if err := session.SendMsg(string(this.module.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@ -39,51 +38,7 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.WorldtaskMineReq) (
|
||||
myWorldtask.CurrentTask = make(map[int32]*pb.Worldtask)
|
||||
}
|
||||
|
||||
now := configure.Now().Unix()
|
||||
update := make(map[string]interface{})
|
||||
|
||||
// 日常
|
||||
if now-myWorldtask.DaliyRefreshTime >= 3600*24 {
|
||||
dailyIds := this.module.randomTask(user.Lv, dailyDes, myWorldtask)
|
||||
if len(dailyIds) > 0 {
|
||||
for _, v := range dailyIds {
|
||||
gwtd, err := this.module.configure.getWorldtaskById(v)
|
||||
if err != nil || gwtd == nil {
|
||||
continue
|
||||
}
|
||||
myWorldtask.CurrentTask[gwtd.Group] = &pb.Worldtask{
|
||||
TaskId: v,
|
||||
TaskType: gwtd.Des,
|
||||
}
|
||||
}
|
||||
update["daliyRefreshTime"] = configure.Now().Unix()
|
||||
}
|
||||
}
|
||||
|
||||
//周常
|
||||
if now-myWorldtask.WeekRefreshTime >= 3600*24*7 {
|
||||
weekIds := this.module.randomTask(user.Lv, weekDes, myWorldtask)
|
||||
if len(weekIds) > 0 {
|
||||
for _, v := range weekIds {
|
||||
gwtd, err := this.module.configure.getWorldtaskById(v)
|
||||
if err != nil || gwtd == nil {
|
||||
continue
|
||||
}
|
||||
myWorldtask.CurrentTask[gwtd.Group] = &pb.Worldtask{
|
||||
TaskId: v,
|
||||
TaskType: gwtd.Des,
|
||||
}
|
||||
}
|
||||
update["weekRefreshTime"] = configure.Now().Unix()
|
||||
}
|
||||
}
|
||||
|
||||
update["currentTask"] = myWorldtask.CurrentTask
|
||||
|
||||
if err := this.module.modelWorldtask.Change(uid, update); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
this.module.modelWorldtask.updateRandomTask(uid, myWorldtask)
|
||||
|
||||
rsp := &pb.WorldtaskMineResp{
|
||||
Task: myWorldtask,
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
@ -161,6 +162,10 @@ func (this *ModelWorldtask) updateCheckCond(uid string, userTask *pb.DBWorldtask
|
||||
return nil
|
||||
}
|
||||
|
||||
if nextTaskConf.Des == 1 || nextTaskConf.Des == 4 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if userTask.CurrentTask == nil {
|
||||
userTask.CurrentTask = make(map[int32]*pb.Worldtask)
|
||||
}
|
||||
@ -295,11 +300,11 @@ func (this *ModelWorldtask) taskFinish(session comm.IUserSession, groupId, taskI
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Worldtask) filterTask(userLv, des int32, wt *pb.DBWorldtask) (taskIds []int32) {
|
||||
func (this *ModelWorldtask) filterTask(userLv, des int32, wt *pb.DBWorldtask) (taskIds []int32) {
|
||||
if des != 1 && des != 4 {
|
||||
return
|
||||
}
|
||||
gwt, err := this.configure.getWorldtaskCfg()
|
||||
gwt, err := this.moduleWorldtask.configure.getWorldtaskCfg()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -319,12 +324,12 @@ func (this *Worldtask) filterTask(userLv, des int32, wt *pb.DBWorldtask) (taskId
|
||||
}
|
||||
|
||||
// 随机日常、周常任务
|
||||
func (this *Worldtask) randomTask(userLv, des int32, wt *pb.DBWorldtask) (taskIds []int32) {
|
||||
func (this *ModelWorldtask) randomTask(userLv, des int32, wt *pb.DBWorldtask) (taskIds []int32) {
|
||||
var num int32
|
||||
if des == 1 {
|
||||
num = this.configure.GetGlobalConf().DailyNum
|
||||
num = this.moduleWorldtask.configure.GetGlobalConf().DailyNum
|
||||
} else if des == 4 {
|
||||
num = this.configure.GetGlobalConf().WeekNum
|
||||
num = this.moduleWorldtask.configure.GetGlobalConf().WeekNum
|
||||
}
|
||||
|
||||
tIds := this.filterTask(userLv, des, wt)
|
||||
@ -339,3 +344,36 @@ func (this *Worldtask) randomTask(userLv, des int32, wt *pb.DBWorldtask) (taskId
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *ModelWorldtask) updateRandomTask(uid string, myWorldtask *pb.DBWorldtask) {
|
||||
user := this.moduleWorldtask.ModuleUser.GetUser(uid)
|
||||
if user == nil {
|
||||
return
|
||||
}
|
||||
|
||||
now := configure.Now().Unix()
|
||||
update := make(map[string]interface{})
|
||||
//周常
|
||||
if now-myWorldtask.WeekRefreshTime >= 3600*24*7 {
|
||||
weekIds := this.randomTask(user.Lv, weekDes, myWorldtask)
|
||||
if len(weekIds) > 0 {
|
||||
for _, v := range weekIds {
|
||||
gwtd, err := this.moduleWorldtask.configure.getWorldtaskById(v)
|
||||
if err != nil || gwtd == nil {
|
||||
continue
|
||||
}
|
||||
myWorldtask.CurrentTask[gwtd.Group] = &pb.Worldtask{
|
||||
TaskId: v,
|
||||
TaskType: gwtd.Des,
|
||||
}
|
||||
}
|
||||
update["weekRefreshTime"] = configure.Now().Unix()
|
||||
}
|
||||
}
|
||||
|
||||
update["currentTask"] = myWorldtask.CurrentTask
|
||||
|
||||
if err := this.Change(uid, update); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user