This commit is contained in:
meixiongfeng 2023-04-11 10:58:05 +08:00
commit 6ca183b9af
8 changed files with 651 additions and 453 deletions

View File

@ -321,16 +321,15 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
} }
stime := time.Now() stime := time.Now()
// this.gateway.Debugf("----------3 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType) // 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.WithTimeout(context.Background(), time.Second*5)
ctx := context.Background() // ctx := context.Background()
if len(serviceTag) == 0 { if len(serviceTag) == 0 {
// this.gateway.Debugf("----------4 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType) // 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 { if err = this.gateway.Service().RpcCall(ctx, servicePath, string(comm.Rpc_GatewayRoute), req, reply); err != nil {
this.gateway.Error("[UserResponse]", this.gateway.Error("[UserResponse]",
log.Field{Key: "uid", Value: this.uId}, log.Field{Key: "uid", Value: this.uId},
log.Field{Key: "serviceTag", Value: serviceTag}, 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: "req", Value: fmt.Sprintf("%s:%s %v", req.MainType, req.SubType, req.Message.String())},
log.Field{Key: "err", Value: err.Error()}, log.Field{Key: "err", Value: err.Error()},
) )

View File

@ -184,12 +184,6 @@ func (this *apiComp) Expulsion(session comm.IUserSession, req *pb.PracticeExpuls
if code = this.module.ModuleHero.KungFuHero(_session, pillar.Hero, false, ""); code != pb.ErrorCode_Success { if code = this.module.ModuleHero.KungFuHero(_session, pillar.Hero, false, ""); code != pb.ErrorCode_Success {
return return
} }
if ok { //在线直接推送消息
if err = _session.Push(); err != nil {
this.module.Errorln(err)
}
this.module.PutUserSession(_session)
}
res := make([]*pb.UserAssets, 0) res := make([]*pb.UserAssets, 0)
for _, v := range ants1 { for _, v := range ants1 {
@ -227,6 +221,14 @@ func (this *apiComp) Expulsion(session comm.IUserSession, req *pb.PracticeExpuls
this.module.modelPandata.Change(pillar.Uid, map[string]interface{}{ this.module.modelPandata.Change(pillar.Uid, map[string]interface{}{
"knapsack": froom.Knapsack, "knapsack": froom.Knapsack,
}) })
if ok { //在线直接推送消息
_session.SendMsg(string(this.module.GetType()), "beexpulsion", &pb.PracticeBeExpulsionPush{Fuid: session.GetUserId(), Pillar: pillar, Knapsack: froom.Knapsack})
if err = _session.Push(); err != nil {
this.module.Errorln(err)
}
this.module.PutUserSession(_session)
}
session.SendMsg(string(this.module.GetType()), "expulsion", &pb.PracticeExpulsionResp{Pillar: pillar, Knapsack: froom.Knapsack}) session.SendMsg(string(this.module.GetType()), "expulsion", &pb.PracticeExpulsionResp{Pillar: pillar, Knapsack: froom.Knapsack})
return return
} }

View File

@ -9,18 +9,19 @@ import (
) )
//参数校验 //参数校验
func (this *apiComp) CancelCheck(session comm.IUserSession, req *pb.PvpActiveCancelReq) (code pb.ErrorCode) { func (this *apiComp) ActiveCancelCheck(session comm.IUserSession, req *pb.PvpActiveCancelReq) (code pb.ErrorCode) {
return return
} }
///设置战斗阵型 ///设置战斗阵型
func (this *apiComp) Cancel(session comm.IUserSession, req *pb.PvpActiveCancelReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) ActiveCancel(session comm.IUserSession, req *pb.PvpActiveCancelReq) (code pb.ErrorCode, data proto.Message) {
var ( var (
battle *BattleItem battle *BattleItem
ok bool ok bool
faiside int32
winside int32 winside int32
) )
if code = this.CancelCheck(session, req); code != pb.ErrorCode_Success { if code = this.ActiveCancelCheck(session, req); code != pb.ErrorCode_Success {
return return
} }
this.module.lock.RLock() this.module.lock.RLock()
@ -28,25 +29,34 @@ func (this *apiComp) Cancel(session comm.IUserSession, req *pb.PvpActiveCancelRe
this.module.lock.RUnlock() this.module.lock.RUnlock()
if ok { if ok {
if battle.Red.Uid == session.GetUserId() { if battle.Red.Uid == session.GetUserId() {
faiside = 1
winside = 2 winside = 2
} else { } else {
faiside = 2
winside = 1 winside = 1
} }
this.module.PvpFinishPush(&pb.BattleFinishPush{ if battle.State == pb.PvpState_battle {
Battleid: req.Battleid, this.module.battle.ConcedeBattle(&pb.BattleConcedeReq{
WinSide: winside, Battleid: req.Battleid,
}) Side: faiside,
if err := this.module.SendMsgToSession(string(comm.ModulePvp), "cancel", &pb.PvpCancelPush{ })
ServicePath: fmt.Sprintf("%s/%s", this.service.GetType(), this.service.GetId()), } else {
Battleid: battle.Id, this.module.PvpFinishPush(&pb.BattleFinishPush{
}, battle.RedSession, battle.BlueSession); err != nil { Battleid: req.Battleid,
this.module.Errorln(err) WinSide: winside,
})
if err := this.module.SendMsgToSession(string(comm.ModulePvp), "cancel", &pb.PvpCancelPush{
ServicePath: fmt.Sprintf("%s/%s", this.service.GetType(), this.service.GetId()),
Battleid: battle.Id,
}, battle.RedSession, battle.BlueSession); err != nil {
this.module.Errorln(err)
}
} }
} else { } else {
code = pb.ErrorCode_BattleInCmdFailed code = pb.ErrorCode_BattleInCmdFailed
return return
} }
session.SendMsg(string(this.module.GetType()), "cancel", &pb.PvpActiveCancelResp{Issucc: true}) session.SendMsg(string(this.module.GetType()), "activecancel", &pb.PvpActiveCancelResp{Issucc: true})
return return
} }

View File

@ -38,14 +38,14 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.SmithySellReq) (cod
return return
} }
// conf := this.module.configure.GetSmithyCustomerConf(req.CustomerId) conf := this.module.configure.GetSmithyCustomerConf(req.CustomerId)
// if conf == nil { if conf == nil {
// code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
// return return
// } }
// // 发奖励 // 发奖励
// this.module.DispenseRes(session, conf.Reword, true) this.module.DispenseRes(session, conf.Reword, true)
rsp := &pb.SmithySellResp{ rsp := &pb.SmithySellResp{
CustomerId: req.CustomerId, CustomerId: req.CustomerId,

View File

@ -154,6 +154,8 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
} }
finishRsp := func() { finishRsp := func() {
this.module.modelWorldtask.updateRandomTask(session.GetUserId(), userTask)
nextTaskIds := this.module.modelWorldtask.findNextTasks(curTaskConf.Key) nextTaskIds := this.module.modelWorldtask.findNextTasks(curTaskConf.Key)
this.module.Debug("nextTaskIds", log.Field{Key: "nextTaskIds", Value: nextTaskIds}) 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 { if err := session.SendMsg(string(this.module.GetType()), WorldtaskSubtypeFinish, rsp); err != nil {
code = pb.ErrorCode_SystemError code = pb.ErrorCode_SystemError
return 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 curTaskConf.IdAfter != 0 {
// 任务完成推送 // 任务完成推送
if err := session.SendMsg(string(this.module.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{ if err := session.SendMsg(string(this.module.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{

View File

@ -4,7 +4,6 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"google.golang.org/protobuf/proto" "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) myWorldtask.CurrentTask = make(map[int32]*pb.Worldtask)
} }
now := configure.Now().Unix() this.module.modelWorldtask.updateRandomTask(uid, myWorldtask)
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
}
rsp := &pb.WorldtaskMineResp{ rsp := &pb.WorldtaskMineResp{
Task: myWorldtask, Task: myWorldtask,

View File

@ -7,6 +7,7 @@ import (
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils" "go_dreamfactory/utils"
@ -161,6 +162,10 @@ func (this *ModelWorldtask) updateCheckCond(uid string, userTask *pb.DBWorldtask
return nil return nil
} }
if nextTaskConf.Des == 1 || nextTaskConf.Des == 4 {
return nil
}
if userTask.CurrentTask == nil { if userTask.CurrentTask == nil {
userTask.CurrentTask = make(map[int32]*pb.Worldtask) 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) { 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) nextTaskIds := this.findNextTasks(curTaskConf.Key)
this.moduleWorldtask.Debug("nextTaskIds", log.Field{Key: "nextTaskIds", Value: nextTaskIds}) 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 { if des != 1 && des != 4 {
return return
} }
gwt, err := this.configure.getWorldtaskCfg() gwt, err := this.moduleWorldtask.configure.getWorldtaskCfg()
if err != nil { if err != nil {
return 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 var num int32
if des == 1 { if des == 1 {
num = this.configure.GetGlobalConf().DailyNum num = this.moduleWorldtask.configure.GetGlobalConf().DailyNum
} else if des == 4 { } else if des == 4 {
num = this.configure.GetGlobalConf().WeekNum num = this.moduleWorldtask.configure.GetGlobalConf().WeekNum
} }
tIds := this.filterTask(userLv, des, wt) tIds := this.filterTask(userLv, des, wt)
@ -339,3 +346,53 @@ func (this *Worldtask) randomTask(userLv, des int32, wt *pb.DBWorldtask) (taskId
return 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
}
}

File diff suppressed because it is too large Load Diff