This commit is contained in:
meixiongfeng 2023-09-18 19:19:43 +08:00
commit 04ae401832
9 changed files with 130 additions and 85 deletions

View File

@ -20,7 +20,7 @@ type (
}
//功能开启通知
IOpenCmdNotice interface {
OpenCmdNotice(uid string, keys ...string)
OpenCmdNotice(session IUserSession, keys ...string)
}
// 活动通知
IActivityNotice interface {
@ -583,6 +583,7 @@ type (
}
//每日任务
IDailytask interface {
IOpenCmdNotice
IGetReddot
//任务组完成
TaskGroupComplete(session IUserSession, group int32)

View File

@ -94,7 +94,8 @@ func (this *configureComp) GetMonsterFormat(id int32) (result []*cfg.GameMonster
if result, ok = this.mformat[id]; ok {
return
}
err = fmt.Errorf("GetMonsterFormat no found :%d", id)
// err = fmt.Errorf("GetMonsterFormat no found :%d", id)
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_monsterformat, id)
this.module.Errorln(err)
return
}
@ -128,6 +129,7 @@ func (this *configureComp) getPandamasBuff(id int32) (configure *cfg.GamePandama
} else {
if configure, ok = v.(*cfg.GamePandamasBuff).GetDataMap()[id]; !ok {
// err = fmt.Errorf("not found:%d ", id)
// err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_pandamasbuff, id)
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_pandamasbuff, id)
this.module.Errorln(err)
return
@ -146,7 +148,8 @@ func (this *configureComp) Getequipsuit(id int32) (result *cfg.GameEquipSuitData
this.module.Errorln(err)
} else {
if result, ok = v.(*cfg.GameEquipSuit).GetDataMap()[id]; !ok {
err = fmt.Errorf("on found Getequipsuit:%d", id)
// err = fmt.Errorf("on found Getequipsuit:%d", id)
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_equipsuit, id)
this.module.Errorln(err)
}
}
@ -163,7 +166,8 @@ func (this *configureComp) GetBattlereadyCapskill(id int32) (result *cfg.GameBat
this.module.Errorln(err)
} else {
if result, ok = v.(*cfg.GameBattleready_capskill).GetDataMap()[id]; !ok {
err = fmt.Errorf("on found BattlereadyCapskill:%d", id)
// err = fmt.Errorf("on found BattlereadyCapskill:%d", id)
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_battleready_capskill, id)
this.module.Errorln(err)
}
}
@ -177,6 +181,7 @@ func (this *configureComp) GetSkillAtk(skillId int32, skillLv int32) (result *cf
return
}
}
// err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_skillafteratk, skillId)
err = fmt.Errorf("no found SkillAtk skillId:%d skillLv%d", skillId, skillLv)
this.module.Errorln(err.Error())
return
@ -192,7 +197,8 @@ func (this *configureComp) GetSkillAfteratk(skillId int32) (result *cfg.GameSkil
this.module.Errorln(err)
} else {
if result, ok = v.(*cfg.GameSkillAfteratk).GetDataMap()[skillId]; !ok {
err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId)
// err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId)
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_skillafteratk, skillId)
this.module.Errorln(err.Error())
}
}
@ -209,7 +215,8 @@ func (this *configureComp) GetSkillBuff(skillId int32) (result *cfg.GameSkillBuf
this.module.Errorln(err)
} else {
if result, ok = v.(*cfg.GameSkillBuff).GetDataMap()[skillId]; !ok {
err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId)
// err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId)
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_skillbuff, skillId)
this.module.Errorln(err.Error())
}
}
@ -226,7 +233,8 @@ func (this *configureComp) GetSkillPassive(skillId int32) (result *cfg.GameSkill
this.module.Errorln(err)
} else {
if result, ok = v.(*cfg.GameSkillPassive).GetDataMap()[skillId]; !ok {
err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId)
// err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId)
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_skillpassive, skillId)
this.module.Errorln(err.Error())
}
}
@ -242,7 +250,7 @@ func (this *configureComp) GetBattleTask(battle int32) (result *cfg.GameBattleta
this.module.Errorln(err)
} else {
if result, ok = v.(*cfg.GameBattletasktesting).GetDataMap()[battle]; !ok {
err = fmt.Errorf("on found GetBattleTask battle:%d", battle)
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_battletasktesting, battle)
this.module.Errorln(err.Error())
}
}

View File

@ -1,6 +1,7 @@
package combat
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
@ -70,7 +71,25 @@ func (this *apiComp) Drop(session comm.IUserSession, req *pb.CombatDropReq) (err
}
return
}
reward := this.module.configure.GetDropReward(box.Drop)
user, err := this.module.ModuleUser.GetUser(session.GetUserId())
if err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
reward := this.module.ModuleTools.GetGroupDataByLottery(box.Drop, user.Vip, user.Lv)
if len(reward) == 0 {
//if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: fmt.Sprintf("Lottery no found!:%d", box.Drop),
}
return
}
this.module.DispenseRes(session, reward, true)
atns = make([]*pb.UserAssets, len(reward))
for i, v := range reward {

View File

@ -46,7 +46,7 @@ func (this *Dailytask) Start() (err error) {
return
}
this.wtask = module.(comm.IWtask)
event.RegisterGO(comm.EventUserLogin, this.EventUserLogin)
event.Register(comm.EventUserLogin, this.EventUserLogin)
return
}
@ -61,56 +61,19 @@ func (this *Dailytask) OnInstallComp() {
// 用户登录
func (this *Dailytask) EventUserLogin(session comm.IUserSession) {
var (
dtask *pb.DBDailytask
user *pb.DBUser
errdata *pb.ErrorData
key int32
group []int32
tasks map[int32][]int32
err error
isopen bool
)
if db.IsCross() { //跨服不支持
return
}
if dtask, err = this.modelDailytask.getUserDTasks(session.GetUserId()); err != nil {
this.Errorln(err)
return
}
if !utils.IsToday(dtask.Rtime) { //不是同一天 重置
if user, err = this.ModuleUser.GetUser(session.GetUserId()); err != nil {
this.Error("no found user", log.Field{Key: "uid", Value: session.GetUserId()})
return
}
if key, group, err = this.modelDailytask.resetUserDTasks(user.Lv); err != nil {
this.Errorln(err)
return
}
if tasks, errdata = this.wtask.ResetDailytaskTask(session.Clone(), key, group...); errdata != nil {
if isopen, errdata = this.ModuleSys.CheckOpenCondCfgById(session.GetUserId(), "annulartask"); isopen {
this.Errorln(errdata)
return
}
dtask.Key = key
dtask.Groups = make([]*pb.DBDailytaskGroup, 0)
for k, v := range tasks {
dtask.Groups = append(dtask.Groups, &pb.DBDailytaskGroup{
Group: k,
Tasks: v,
})
}
dtask.Rtime = configure.Now().Unix()
if err = this.modelDailytask.Change(session.GetUserId(), map[string]interface{}{
"key": dtask.Key,
"groups": dtask.Groups,
"rtime": dtask.Rtime,
}); err != nil {
this.Errorln(err)
return
}
}
this.refreshtask(session)
}
// 任务组完成
@ -137,6 +100,15 @@ func (this *Dailytask) TaskGroupComplete(session comm.IUserSession, group int32)
}
}
// 功能是否开启
func (this *Dailytask) OpenCmdNotice(session comm.IUserSession, keys ...string) {
for _, v := range keys {
if v == "annulartask" { //日常功能开启
this.refreshtask(session)
}
}
}
// 查询每日红点信息
func (this *Dailytask) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) {
var (
@ -168,3 +140,51 @@ func (this *Dailytask) Reddot(session comm.IUserSession, rid ...comm.ReddotType)
}
return
}
func (this *Dailytask) refreshtask(session comm.IUserSession) {
var (
dtask *pb.DBDailytask
user *pb.DBUser
errdata *pb.ErrorData
key int32
group []int32
tasks map[int32][]int32
err error
)
if dtask, err = this.modelDailytask.getUserDTasks(session.GetUserId()); err != nil {
this.Errorln(err)
return
}
if !utils.IsToday(dtask.Rtime) { //不是同一天 重置
if user, err = this.ModuleUser.GetUser(session.GetUserId()); err != nil {
this.Error("no found user", log.Field{Key: "uid", Value: session.GetUserId()})
return
}
if key, group, err = this.modelDailytask.resetUserDTasks(user.Lv); err != nil {
this.Errorln(err)
return
}
if tasks, errdata = this.wtask.ResetDailytaskTask(session, key, group...); errdata != nil {
this.Errorln(errdata)
return
}
dtask.Key = key
dtask.Groups = make([]*pb.DBDailytaskGroup, 0)
for k, v := range tasks {
dtask.Groups = append(dtask.Groups, &pb.DBDailytaskGroup{
Group: k,
Tasks: v,
})
}
dtask.Rtime = configure.Now().Unix()
if err = this.modelDailytask.Change(session.GetUserId(), map[string]interface{}{
"key": dtask.Key,
"groups": dtask.Groups,
"rtime": dtask.Rtime,
}); err != nil {
this.Errorln(err)
return
}
}
}

View File

@ -210,9 +210,9 @@ func (this *Practice) TaskComplete(session comm.IUserSession, taskid ...int32) {
)
}
func (this *Practice) OpenCmdNotice(uid string, keys ...string) {
func (this *Practice) OpenCmdNotice(session comm.IUserSession, keys ...string) {
this.Debug("OpenCmdNotice",
log.Field{Key: "session", Value: uid},
log.Field{Key: "session", Value: session.GetUserId()},
log.Field{Key: "key", Value: keys},
)
if !this.IsCross() {
@ -220,7 +220,7 @@ func (this *Practice) OpenCmdNotice(uid string, keys ...string) {
if v == "practice_ pillar1" || v == "practice_ pillar2" || v == "practice_ pillar3" {
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
comm.Service_Worker, string(comm.RPC_ModulePracticeUnLockPillar),
&pb.RPCGeneralReqA2{Param1: uid, Param2: v}, &pb.EmptyResp{})
&pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v}, &pb.EmptyResp{})
if err != nil {
this.Errorln(err)
return
@ -231,7 +231,7 @@ func (this *Practice) OpenCmdNotice(uid string, keys ...string) {
} else {
for _, v := range keys {
if v == "practice_ pillar1" || v == "practice_ pillar2" || v == "practice_ pillar3" {
this.RPC_ModulePracticeUnLockPillar(context.Background(), &pb.RPCGeneralReqA2{Param1: uid, Param2: v}, &pb.EmptyResp{})
this.RPC_ModulePracticeUnLockPillar(context.Background(), &pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v}, &pb.EmptyResp{})
}
}
}

View File

@ -65,7 +65,8 @@ func (this *apiComp) FuncActivate(session comm.IUserSession, req *pb.SysFuncActi
return
}
go this.module.wtask.OpenCmdNotice(session.GetUserId(), req.Cid)
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.wtask.OpenCmdNotice(session, req.Cid)
//手动激活通知模块
for _, m := range opencfg.Notify {
i, err := this.service.GetModule(core.M_Modules(m))
@ -75,8 +76,10 @@ func (this *apiComp) FuncActivate(session comm.IUserSession, req *pb.SysFuncActi
}
if ic, ok := i.(comm.IOpenCmdNotice); ok {
go ic.OpenCmdNotice(session.GetUserId(), req.Cid)
ic.OpenCmdNotice(session, req.Cid)
}
}
})
return
}

View File

@ -76,9 +76,13 @@ func (this *apiComp) FuncGetList(session comm.IUserSession, req *pb.SysFuncGetLi
"cond": list.Cond,
})
}
if len(change) > 0 {
go this.module.wtask.OpenCmdNotice(session.GetUserId(), change...)
}
session.SendMsg(string(this.module.GetType()), "funcgetlist", rsp)
if len(change) > 0 {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.wtask.OpenCmdNotice(session, change...)
})
}
return
}

View File

@ -48,7 +48,7 @@ func (this *Turntable) Start() (err error) {
if module, err = this.service.GetModule(comm.ModuleWarorder); err != nil {
return
}
event.RegisterGO(comm.EventUserLogin, this.EventUserLogin)
event.Register(comm.EventUserLogin, this.EventUserLogin)
return
}

View File

@ -154,7 +154,7 @@ func (this *WTask) BuriedsNotify(session comm.IUserSession, condis []*pb.ConIPro
}
// 功能开启
func (this *WTask) OpenCmdNotice(uid string, keys ...string) {
func (this *WTask) OpenCmdNotice(session comm.IUserSession, keys ...string) {
var (
opencmdTask map[string][]*cfg.GameWorldTaskData
user *pb.DBUser
@ -169,21 +169,16 @@ func (this *WTask) OpenCmdNotice(uid string, keys ...string) {
break
}
}
if user, err = this.ModuleUser.GetUser(uid); err != nil {
this.Error("获取用户信息失败!", log.Field{Key: "uid", Value: uid})
if user, err = this.ModuleUser.GetUser(session.GetUserId()); err != nil {
this.Error("获取用户信息失败!", log.Field{Key: "uid", Value: session.GetUserId()})
return
}
if wtask, err = this.modelwtask.getUserWTasks(uid); err != nil {
this.Error("获取世界任务数据 失败!", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
if wtask, err = this.modelwtask.getUserWTasks(session.GetUserId()); err != nil {
this.Error("获取世界任务数据 失败!", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "err", Value: err.Error()})
return
}
session, _ := this.GetUserSession(uid)
defer func() {
session.Push()
this.PutUserSession(session)
}()
this.inquireActivations(session, wtask, user.Lv, keys, true)
}
@ -277,11 +272,6 @@ func (this *WTask) ResetDailytaskTask(session comm.IUserSession, dailytaskid int
boxchange bool
)
defer func() {
session.Push()
this.PutUserSession(session)
}()
results = make(map[int32][]int32)
for _, v := range this.configure.getdesTask(1) {
alltasks[v.Key] = v