diff --git a/comm/const.go b/comm/const.go index a89deefce..c91dfa54c 100644 --- a/comm/const.go +++ b/comm/const.go @@ -979,7 +979,7 @@ const ( Rtype242 TaskType = 242 //辉月等级达到x级 Rtype243 TaskType = 243 //指定英雄满级且共鸣和觉醒升至最高状态 - + Rtype245 TaskType = 245 //招募到X品质X阵营的守护者X个 ) const ( MailLineEasy int32 = 1 // 简单 diff --git a/comm/imodule.go b/comm/imodule.go index 5f79e2a25..5be723d7d 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -636,6 +636,7 @@ type ( } IUiGame interface { HDPSTodayConsum(uid string, ps int32) // 今日消耗的体力 + IActivityNotice } IStonehenge interface { diff --git a/modules/activity/module.go b/modules/activity/module.go index 2dc12bdd4..323915810 100644 --- a/modules/activity/module.go +++ b/modules/activity/module.go @@ -31,6 +31,7 @@ type Activity struct { shopcenter comm.IShopcenter // 活动中心 addrecharge comm.IAddrecharge // 活动中心 kftask comm.IActivityNotice // 开服任务 + uigame comm.IUiGame // ui小游戏 } func NewModule() core.IModule { @@ -91,7 +92,10 @@ func (this *Activity) Start() (err error) { return } this.kftask = module.(comm.IActivityNotice) - + if module, err = this.service.GetModule(comm.ModulePuzzle); err != nil { + return + } + this.uigame = module.(comm.IUiGame) if !db.IsCross() { this.modelhdList.LoadActivityData() for k, v := range this.modelhdList.activity { @@ -111,6 +115,9 @@ func (this *Activity) Start() (err error) { case pb.HdType_KFSevenTask: this.kftask.ActivityOpenNotice(v) break + case pb.HdType_HdPuzzle, pb.HdType_HdLattice, pb.HdType_HdMiner: + this.uigame.ActivityOpenNotice(v) + break } } } @@ -385,6 +392,9 @@ func (this *Activity) Rpc_ActivityOver(ctx context.Context, args *pb.RPCGeneralR case pb.HdType_KFSevenTask: this.kftask.ActivityCloseNotice(hd) break + case pb.HdType_HdPuzzle, pb.HdType_HdLattice, pb.HdType_HdMiner: + this.uigame.ActivityCloseNotice(hd) + break } } } @@ -423,6 +433,9 @@ func (this *Activity) Rpc_ActivityStar(ctx context.Context, args *pb.RPCGeneralR case pb.HdType_KFSevenTask: this.kftask.ActivityOpenNotice(hd) break + case pb.HdType_HdPuzzle, pb.HdType_HdLattice, pb.HdType_HdMiner: + this.uigame.ActivityOpenNotice(hd) + break } } } diff --git a/modules/integral/module.go b/modules/integral/module.go index e6899a24c..36116d445 100644 --- a/modules/integral/module.go +++ b/modules/integral/module.go @@ -58,7 +58,7 @@ func (this *Integral) OnInstallComp() { // 任务条件达成通知 func (this *Integral) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) { var bChange bool - this.Debug("积分bossm条件达成通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "conds", Value: conds}) + this.Debug("积分boss条件达成通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "conds", Value: conds}) dt, err := this.modelIntegral.getIntegralList(session.GetUserId()) if dt.Itype != 2 { // 只有事件模式才有debuff @@ -95,7 +95,6 @@ func (this *Integral) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIP if dt.Buff[k] != 1 && v.State == pb.BuriedItemFinishState_buried_finish { dt.Buff[k] = 1 bChange = true - } } if bChange { diff --git a/modules/uigame/api_getlattice.go b/modules/uigame/api_getlattice.go index 36e143ffc..e077b3a45 100644 --- a/modules/uigame/api_getlattice.go +++ b/modules/uigame/api_getlattice.go @@ -25,10 +25,11 @@ func (this *apiComp) GetLattice(session comm.IUserSession, req *pb.UiGameGetLatt ) update = make(map[string]interface{}) curTime := configure.Now().Unix() - if activity, err = this.module.ModuleActivity.GetHdInfoByHdId(req.Hdid); err != nil { // 活动不存在 + if activity, err = this.module.GetActivityData(pb.HdType_HdLattice); err != nil { // 活动不存在 errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ActivityInvalid, - Title: pb.ErrorCode_ActivityInvalid.ToString(), + Code: pb.ErrorCode_ActivityInvalid, + Title: pb.ErrorCode_ActivityInvalid.ToString(), + Message: err.Error(), } return } diff --git a/modules/uigame/api_getminer.go b/modules/uigame/api_getminer.go index 24b0554ba..e433ed9ab 100644 --- a/modules/uigame/api_getminer.go +++ b/modules/uigame/api_getminer.go @@ -25,7 +25,7 @@ func (this *apiComp) GetMiner(session comm.IUserSession, req *pb.UiGameGetMinerR ) update = make(map[string]interface{}) curTime := configure.Now().Unix() - if activity, err = this.module.ModuleActivity.GetHdInfoByHdId(req.Hdid); err != nil { // 活动不存在 + if activity, err = this.module.GetActivityData(pb.HdType_HdMiner); err != nil { // 活动不存在 errdata = &pb.ErrorData{ Code: pb.ErrorCode_ActivityInvalid, Title: pb.ErrorCode_ActivityInvalid.ToString(), diff --git a/modules/uigame/api_getpuzzle.go b/modules/uigame/api_getpuzzle.go index 34466a019..29c01de9c 100644 --- a/modules/uigame/api_getpuzzle.go +++ b/modules/uigame/api_getpuzzle.go @@ -25,7 +25,7 @@ func (this *apiComp) GetPuzzle(session comm.IUserSession, req *pb.UiGameGetPuzzl ) update = make(map[string]interface{}) curTime := configure.Now().Unix() - if activity, err = this.module.ModuleActivity.GetHdInfoByHdId(req.Hdid); err != nil { // 活动不存在 + if activity, err = this.module.GetActivityData(pb.HdType_HdPuzzle); err != nil { // 活动不存在 errdata = &pb.ErrorData{ Code: pb.ErrorCode_ActivityInvalid, Title: pb.ErrorCode_ActivityInvalid.ToString(), diff --git a/modules/uigame/model_lattice.go b/modules/uigame/model_lattice.go index e7386fa9e..34f51c254 100644 --- a/modules/uigame/model_lattice.go +++ b/modules/uigame/model_lattice.go @@ -15,6 +15,7 @@ import ( type modelLattice struct { modules.MCompModel module *UiGame + open bool // 游戏是否开启 } func (this *modelLattice) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { diff --git a/modules/uigame/module.go b/modules/uigame/module.go index 2ce3baa57..590526a7a 100644 --- a/modules/uigame/module.go +++ b/modules/uigame/module.go @@ -1,6 +1,7 @@ package uigame import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" @@ -8,6 +9,7 @@ import ( "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/utils" + "sync" "go_dreamfactory/modules" ) @@ -20,6 +22,8 @@ type UiGame struct { service base.IRPCXService modelLattice *modelLattice modelMiner *modelMiner + lock sync.RWMutex + hdlist map[pb.HdType]*pb.DBHuodong } func NewModule() core.IModule { @@ -212,3 +216,32 @@ func (this *UiGame) HDPSTodayConsum(uid string, ps int32) { } } } + +func (this *UiGame) ActivityOpenNotice(hd *pb.DBHuodong) { + this.lock.Lock() + defer this.lock.Unlock() + this.hdlist[hd.Itype] = hd +} + +// 活动关闭通知 +func (this *UiGame) ActivityCloseNotice(hd *pb.DBHuodong) { + this.lock.Lock() + defer this.lock.Unlock() + if _, ok := this.hdlist[hd.Itype]; ok { + delete(this.hdlist, hd.Itype) + } +} + +func (this *UiGame) GetActivityData(itype pb.HdType) (hd *pb.DBHuodong, err error) { + var ( + ok bool + ) + this.lock.RLock() + hd, ok = this.hdlist[itype] + this.lock.RUnlock() + if !ok { + err = fmt.Errorf("not found hditype:%d", itype) + return + } + return +}