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,8 +321,8 @@ 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 {
@ -330,7 +330,6 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
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: "req", Value: fmt.Sprintf("%s:%s %v", req.MainType, req.SubType, req.Message.String())},
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 {
return
}
if ok { //在线直接推送消息
if err = _session.Push(); err != nil {
this.module.Errorln(err)
}
this.module.PutUserSession(_session)
}
res := make([]*pb.UserAssets, 0)
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{}{
"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})
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
}
///设置战斗阵型
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 (
battle *BattleItem
ok bool
faiside int32
winside int32
)
if code = this.CancelCheck(session, req); code != pb.ErrorCode_Success {
if code = this.ActiveCancelCheck(session, req); code != pb.ErrorCode_Success {
return
}
this.module.lock.RLock()
@ -28,10 +29,18 @@ func (this *apiComp) Cancel(session comm.IUserSession, req *pb.PvpActiveCancelRe
this.module.lock.RUnlock()
if ok {
if battle.Red.Uid == session.GetUserId() {
faiside = 1
winside = 2
} else {
faiside = 2
winside = 1
}
if battle.State == pb.PvpState_battle {
this.module.battle.ConcedeBattle(&pb.BattleConcedeReq{
Battleid: req.Battleid,
Side: faiside,
})
} else {
this.module.PvpFinishPush(&pb.BattleFinishPush{
Battleid: req.Battleid,
WinSide: winside,
@ -42,11 +51,12 @@ func (this *apiComp) Cancel(session comm.IUserSession, req *pb.PvpActiveCancelRe
}, battle.RedSession, battle.BlueSession); err != nil {
this.module.Errorln(err)
}
}
} else {
code = pb.ErrorCode_BattleInCmdFailed
return
}
session.SendMsg(string(this.module.GetType()), "cancel", &pb.PvpActiveCancelResp{Issucc: true})
session.SendMsg(string(this.module.GetType()), "activecancel", &pb.PvpActiveCancelResp{Issucc: true})
return
}

View File

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

View File

@ -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{

View File

@ -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,

View File

@ -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
}
}

File diff suppressed because it is too large Load Diff