Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
be9aead903
@ -321,16 +321,15 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
|
||||
}
|
||||
stime := time.Now()
|
||||
// this.gateway.Debugf("----------3 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType)
|
||||
// ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
|
||||
ctx := context.Background()
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
|
||||
// ctx := context.Background()
|
||||
if len(serviceTag) == 0 {
|
||||
// this.gateway.Debugf("----------4 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType)
|
||||
if err = this.gateway.Service().RpcCall(ctx, servicePath, string(comm.Rpc_GatewayRoute), req, reply); err != nil {
|
||||
this.gateway.Error("[UserResponse]",
|
||||
log.Field{Key: "uid", Value: this.uId},
|
||||
log.Field{Key: "serviceTag", Value: serviceTag},
|
||||
log.Field{Key: "servicePath", Value: servicePath},
|
||||
log.Field{Key: "servicePath", Value: servicePath},
|
||||
log.Field{Key: "servicePath", Value: servicePath},
|
||||
log.Field{Key: "req", Value: fmt.Sprintf("%s:%s %v", req.MainType, req.SubType, req.Message.String())},
|
||||
log.Field{Key: "err", Value: err.Error()},
|
||||
)
|
||||
|
@ -154,6 +154,8 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
||||
}
|
||||
|
||||
finishRsp := func() {
|
||||
this.module.modelWorldtask.updateRandomTask(session.GetUserId(), userTask)
|
||||
|
||||
nextTaskIds := this.module.modelWorldtask.findNextTasks(curTaskConf.Key)
|
||||
this.module.Debug("nextTaskIds", log.Field{Key: "nextTaskIds", Value: nextTaskIds})
|
||||
|
||||
@ -168,10 +170,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,47 +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)
|
||||
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)
|
||||
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)
|
||||
}
|
||||
@ -226,6 +231,8 @@ func (this *ModelWorldtask) updateCheckCond(uid string, userTask *pb.DBWorldtask
|
||||
|
||||
// 任务完成推送
|
||||
func (this *ModelWorldtask) taskFinishPush(session comm.IUserSession, groupId int32, userTask *pb.DBWorldtask, curTaskConf *cfg.GameWorldTaskData) {
|
||||
this.updateRandomTask(session.GetUserId(), userTask)
|
||||
|
||||
nextTaskIds := this.findNextTasks(curTaskConf.Key)
|
||||
this.moduleWorldtask.Debug("nextTaskIds", log.Field{Key: "nextTaskIds", Value: nextTaskIds})
|
||||
|
||||
@ -295,11 +302,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 +326,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 +346,53 @@ 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.DaliyRefreshTime >= 3600*24 {
|
||||
dailyIds := this.randomTask(user.Lv, dailyDes, myWorldtask)
|
||||
if len(dailyIds) > 0 {
|
||||
for _, v := range dailyIds {
|
||||
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["daliyRefreshTime"] = configure.Now().Unix()
|
||||
}
|
||||
}
|
||||
//周常
|
||||
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