From e7959048ebbc82da34c3f0d355ee572dea51344b Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 4 Aug 2023 11:43:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E6=9C=8D=E5=BA=86=E5=85=B8=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_hdcelebration.json | 39 +++++++++++ bin/json/game_playerinfor_overview.json | 6 ++ comm/const.go | 24 ++++--- comm/imodule.go | 3 + modules/activity/api_gethddata.go | 21 +++++- modules/activity/comp_configure.go | 27 ++++++++ modules/activity/model_hddata.go | 2 + modules/activity/model_hdlist.go | 6 ++ modules/activity/module.go | 63 +++++++++++++++++ sys/configure/structs/Game.HDCelebration.go | 42 +++++++++++ .../structs/Game.HDCelebrationData.go | 69 +++++++++++++++++++ .../structs/Game.PlayerInfor_overviewData.go | 2 + sys/configure/structs/Tables.go | 7 ++ 13 files changed, 300 insertions(+), 11 deletions(-) create mode 100644 bin/json/game_hdcelebration.json create mode 100644 sys/configure/structs/Game.HDCelebration.go create mode 100644 sys/configure/structs/Game.HDCelebrationData.go diff --git a/bin/json/game_hdcelebration.json b/bin/json/game_hdcelebration.json new file mode 100644 index 000000000..720d72f02 --- /dev/null +++ b/bin/json/game_hdcelebration.json @@ -0,0 +1,39 @@ +[ + { + "ID": 1, + "systemtype": 1, + "bosstype": [ + 0 + ], + "num": [ + 6 + ], + "days": 2 + }, + { + "ID": 2, + "systemtype": 2, + "bosstype": [ + 31 + ], + "num": [ + 6 + ], + "days": 2 + }, + { + "ID": 3, + "systemtype": 2, + "bosstype": [ + 1, + 2, + 3 + ], + "num": [ + 2, + 2, + 2 + ], + "days": 2 + } +] \ No newline at end of file diff --git a/bin/json/game_playerinfor_overview.json b/bin/json/game_playerinfor_overview.json index e41518040..4231094c8 100644 --- a/bin/json/game_playerinfor_overview.json +++ b/bin/json/game_playerinfor_overview.json @@ -11,6 +11,7 @@ "resources": "Person/10000/10000M.prefab", "vague": "Person/10000/10000MT.prefab", "pvpAnimator": "Person/10000/10000_MPvp.controller", + "mainq": "Person/10000/10000M_q.prefab", "playerhead": "tx_js_nz", "name": { "key": "playerinfor_playerinfor_overview_name_1", @@ -29,6 +30,7 @@ "resources": "Person/10000/10000W.prefab", "vague": "Person/10000/10000WT.prefab", "pvpAnimator": "Person/10000/10000_WPvp.controller", + "mainq": "Person/10000/10000W_q.prefab", "playerhead": "tx_js_nvz", "name": { "key": "playerinfor_playerinfor_overview_name_2", @@ -47,6 +49,7 @@ "resources": "", "vague": "", "pvpAnimator": "", + "mainq": "", "playerhead": "tx_js_nz", "name": { "key": "playerinfor_playerinfor_overview_name_3", @@ -65,6 +68,7 @@ "resources": "", "vague": "", "pvpAnimator": "", + "mainq": "", "playerhead": "tx_js_nvz", "name": { "key": "playerinfor_playerinfor_overview_name_4", @@ -83,6 +87,7 @@ "resources": "", "vague": "", "pvpAnimator": "", + "mainq": "", "playerhead": "tx_js_nz", "name": { "key": "playerinfor_playerinfor_overview_name_5", @@ -101,6 +106,7 @@ "resources": "", "vague": "", "pvpAnimator": "", + "mainq": "", "playerhead": "tx_js_nvz", "name": { "key": "playerinfor_playerinfor_overview_name_6", diff --git a/comm/const.go b/comm/const.go index 4f42d6ebf..f41170b71 100644 --- a/comm/const.go +++ b/comm/const.go @@ -988,14 +988,18 @@ const ( ) const ( - HdTypeWarorder = 1 //圣桃战令类型 - HdTypePay = 2 //圣桃充值礼包 - KFSevenTask = 3 //开服任务 - XSFundPhysical = 4 //现时活动 体力基金 - XSFundRecruit = 5 //现时活动 招募基金 - XSFundExp = 6 //现时活动 经验基金 - HdLevel = 7 //开服等级活动 - HdTypeSign = 8 //七日签到 - HdTypeTurntable = 9 //大转盘 - AddUpRecharge = 10 //累计充值 + HdTypeWarorder = 1 //圣桃战令类型 + HdTypePay = 2 //圣桃充值礼包 + KFSevenTask = 3 //开服任务 + XSFundPhysical = 4 //现时活动 体力基金 + XSFundRecruit = 5 //现时活动 招募基金 + XSFundExp = 6 //现时活动 经验基金 + HdLevel = 7 //开服等级活动 + HdTypeSign = 8 //七日签到 + + AddUpRecharge = 10 //累计充值 + + // 特殊类型活动 只受活动开启限制 + HdTypeTurntable = 1001 //大转盘 + HdCelebration = 1002 // 庆典活动 ) diff --git a/comm/imodule.go b/comm/imodule.go index 3a84f5f14..d8afed5e9 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -594,6 +594,9 @@ type ( GetAllHdInfo() (hdList map[int32][]*pb.DBHuodong) // 获取所有活动信息 GetHdInfoByItype(itype int32) (result []*pb.DBHuodong, err error) // UpdateActivitySlider(session IUserSession) // 修改活动进度 + + // 庆典活动 + HDCelebration(session IUserSession, systemtype int32, bosstype int32) } //每日任务 IDailytask interface { diff --git a/modules/activity/api_gethddata.go b/modules/activity/api_gethddata.go index fd868127d..7c33c5250 100644 --- a/modules/activity/api_gethddata.go +++ b/modules/activity/api_gethddata.go @@ -24,7 +24,7 @@ func (this *apiComp) GetHdData(session comm.IUserSession, req *pb.ActivityGetHdD curTime := configure.Now().Unix() for _, id := range req.Oid { if activity, err = this.module.modelhdList.getHdListByHdId(id); err != nil { - if activity.Stime <= curTime && curTime <= activity.Etime { + if activity.Stime > curTime || curTime > activity.Etime { // 不在活动范围内数据不给活动记录数据 continue } } @@ -52,6 +52,25 @@ func (this *apiComp) GetHdData(session comm.IUserSession, req *pb.ActivityGetHdD } } } + + // 获取开服庆典活动 + if activity.Itype == comm.HdCelebration { + key := fmt.Sprintf("%s:%s", session.GetUserId(), id) + if data, err := this.module.modelhdData.getHddataByOid(session.GetUserId(), key); err != nil { + // 注意 Gotarr:map[int32]int32 key value 已经挑战的次数 + if !utils.IsToday(data.Lasttime) { // 不是今天重置 + data.Lasttime = configure.Now().Unix() + data.Gotarr = make(map[int32]int32) + // 计算进度 + data.Val = int32((configure.Now().Unix()-activity.Stime)/24*3600) + 1 + update := make(map[string]interface{}) + update["lasttime"] = data.Lasttime + update["val"] = data.Val + update["gotarr"] = data.Gotarr + this.module.modelhdData.ModifyActivityList(session.GetUserId(), data.Id, update) + } + } + } result = append(result, list) } diff --git a/modules/activity/comp_configure.go b/modules/activity/comp_configure.go index c220eb16a..1122a340d 100644 --- a/modules/activity/comp_configure.go +++ b/modules/activity/comp_configure.go @@ -12,6 +12,7 @@ import ( const ( venturegiftsdraw = "game_venturegiftsdraw.json" //大转盘 + hdcelebration = "game_hdcelebration.json" //开服庆典 ) // /配置管理基础组件 @@ -29,6 +30,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp this.module = module.(*Activity) err = this.LoadMultiConfigure(map[string]interface{}{ venturegiftsdraw: cfg.NewGameVenturegiftsDraw, + hdcelebration: cfg.NewGameCelebration, }) configure.RegisterConfigure(venturegiftsdraw, cfg.NewGameVenturegiftsDraw, func() { @@ -97,3 +99,28 @@ func (this *configureComp) GetPool1() (m map[int32]*cfg.GameVenturegiftsDrawData func (this *configureComp) GetPool2() (m map[int32]*cfg.GameVenturegiftsDrawData) { return this.pool2 } + +// id +func (this *configureComp) GetHDCelebration(id int32) (conf *cfg.GameCelebrationData, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(hdcelebration); err == nil { + if conf, ok = v.(*cfg.GameCelebration).GetDataMap()[id]; !ok { + err = fmt.Errorf("%T no is *cfg.GameCelebrationData", v) + return + } + } + return +} + +func (this *configureComp) GetHDCelebrationData() (days []int32) { + + if v, err := this.GetConfigure(hdcelebration); err == nil { + for _, v := range v.(*cfg.GameCelebration).GetDataList() { + days = append(days, v.Days) + } + } + return +} diff --git a/modules/activity/model_hddata.go b/modules/activity/model_hddata.go index 839e1f74a..c3f9cf023 100644 --- a/modules/activity/model_hddata.go +++ b/modules/activity/model_hddata.go @@ -6,6 +6,7 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/x/bsonx" @@ -54,6 +55,7 @@ func (this *modelhdData) getHddataByOid(uid string, oid string) (result *pb.DBAc result.Id = fmt.Sprintf("%s:%s", uid, oid) result.Uid = uid result.Hdoid = oid + result.Lasttime = configure.Now().Unix() this.AddList(uid, result.Id, result) err = nil return diff --git a/modules/activity/model_hdlist.go b/modules/activity/model_hdlist.go index e2ecf84d5..e2fc21f7e 100644 --- a/modules/activity/model_hdlist.go +++ b/modules/activity/model_hdlist.go @@ -93,3 +93,9 @@ func (this *modelHdList) LoadActivityData() { } } } +func (this *modelHdList) getHdInfoByType(itype int32) (activity []*pb.DBHuodong) { + if v, ok := this.activity[itype]; ok { + return v + } + return nil +} diff --git a/modules/activity/module.go b/modules/activity/module.go index 1f774ae3c..469d168db 100644 --- a/modules/activity/module.go +++ b/modules/activity/module.go @@ -6,8 +6,10 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/sys/db" + "go_dreamfactory/utils" ) type Activity struct { @@ -205,3 +207,64 @@ func (this *Activity) Turntable(drawIndex int32, reward []int32) (item *cfg.Game return } + +// 统计庆典活动完成情况 +func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32, bosstype int32) bool { + bDouble := false // 是否开启双倍奖励 + if activity := this.modelhdList.getHdInfoByType(comm.HdCelebration); activity != nil { + for _, v := range activity { + if configure.Now().Unix() > v.Stime && configure.Now().Unix() < v.Etime { // 活动范围内 + update := make(map[string]interface{}) + bChange := false + // 查询玩家活动记录 + key := fmt.Sprintf("%s:%s", session.GetUserId(), v.Id) + if data, err := this.modelhdData.getHddataByOid(session.GetUserId(), key); err != nil { + // 注意 Gotarr:map[int32]int32 key value 已经挑战的次数 + if !utils.IsToday(data.Lasttime) { // 不是今天重置 + data.Lasttime = configure.Now().Unix() + data.Gotarr = make(map[int32]int32) + // 计算进度 + data.Val = int32((configure.Now().Unix()-v.Stime)/24*3600) + 1 + update["lasttime"] = data.Lasttime + update["val"] = data.Val + update["gotarr"] = data.Gotarr + bChange = true + } + var pos int32 + + for index, v := range this.configure.GetHDCelebrationData() { + for i := 0; i < int(v); i++ { + pos++ + if data.Val == pos { + if conf, err := this.configure.GetHDCelebration(int32(index) + 1); err != nil { + // kay = bosstype << 8 + systemtype + if conf.Systemtype == systemtype { + data.Gotarr[bosstype] += 1 + // 天数 + var idays int32 + for i, v1 := range conf.Bosstype { + if v1 == systemtype { + idays = conf.Num[i] + break + } + } + // 更新信息 + update["gotarr"] = data.Gotarr + bChange = true + if data.Gotarr[bosstype] <= idays { + bDouble = true + } + } + } + } + } + } + if bChange { + this.modelhdData.ModifyActivityList(session.GetUserId(), data.Id, update) + } + } + } + } + } + return bDouble +} diff --git a/sys/configure/structs/Game.HDCelebration.go b/sys/configure/structs/Game.HDCelebration.go new file mode 100644 index 000000000..d4d3b50be --- /dev/null +++ b/sys/configure/structs/Game.HDCelebration.go @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +package cfg + +type GameHDCelebration struct { + _dataMap map[int32]*GameHDCelebrationData + _dataList []*GameHDCelebrationData +} + +func NewGameHDCelebration(_buf []map[string]interface{}) (*GameHDCelebration, error) { + _dataList := make([]*GameHDCelebrationData, 0, len(_buf)) + dataMap := make(map[int32]*GameHDCelebrationData) + for _, _ele_ := range _buf { + if _v, err2 := DeserializeGameHDCelebrationData(_ele_); err2 != nil { + return nil, err2 + } else { + _dataList = append(_dataList, _v) + dataMap[_v.ID] = _v + } + } + return &GameHDCelebration{_dataList:_dataList, _dataMap:dataMap}, nil +} + +func (table *GameHDCelebration) GetDataMap() map[int32]*GameHDCelebrationData { + return table._dataMap +} + +func (table *GameHDCelebration) GetDataList() []*GameHDCelebrationData { + return table._dataList +} + +func (table *GameHDCelebration) Get(key int32) *GameHDCelebrationData { + return table._dataMap[key] +} + + diff --git a/sys/configure/structs/Game.HDCelebrationData.go b/sys/configure/structs/Game.HDCelebrationData.go new file mode 100644 index 000000000..508619275 --- /dev/null +++ b/sys/configure/structs/Game.HDCelebrationData.go @@ -0,0 +1,69 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +package cfg + +import "errors" + +type GameHDCelebrationData struct { + ID int32 + Systemtype int32 + Bosstype []int32 + Num []int32 + Days int32 +} + +const TypeId_GameHDCelebrationData = -1921981892 + +func (*GameHDCelebrationData) GetTypeId() int32 { + return -1921981892 +} + +func (_v *GameHDCelebrationData)Deserialize(_buf map[string]interface{}) (err error) { + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["ID"].(float64); !_ok_ { err = errors.New("ID error"); return }; _v.ID = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["systemtype"].(float64); !_ok_ { err = errors.New("systemtype error"); return }; _v.Systemtype = int32(_tempNum_) } + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["bosstype"].([]interface{}); !_ok_ { err = errors.New("bosstype error"); return } + + _v.Bosstype = make([]int32, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ int32 + { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } + _v.Bosstype = append(_v.Bosstype, _list_v_) + } + } + + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["num"].([]interface{}); !_ok_ { err = errors.New("num error"); return } + + _v.Num = make([]int32, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ int32 + { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } + _v.Num = append(_v.Num, _list_v_) + } + } + + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["days"].(float64); !_ok_ { err = errors.New("days error"); return }; _v.Days = int32(_tempNum_) } + return +} + +func DeserializeGameHDCelebrationData(_buf map[string]interface{}) (*GameHDCelebrationData, error) { + v := &GameHDCelebrationData{} + if err := v.Deserialize(_buf); err == nil { + return v, nil + } else { + return nil, err + } +} diff --git a/sys/configure/structs/Game.PlayerInfor_overviewData.go b/sys/configure/structs/Game.PlayerInfor_overviewData.go index 49f557d11..4ce0b7c9d 100644 --- a/sys/configure/structs/Game.PlayerInfor_overviewData.go +++ b/sys/configure/structs/Game.PlayerInfor_overviewData.go @@ -20,6 +20,7 @@ type GamePlayerInfor_overviewData struct { Resources string Vague string PvpAnimator string + Mainq string Playerhead string Name string } @@ -53,6 +54,7 @@ func (_v *GamePlayerInfor_overviewData)Deserialize(_buf map[string]interface{}) { var _ok_ bool; if _v.Resources, _ok_ = _buf["resources"].(string); !_ok_ { err = errors.New("resources error"); return } } { var _ok_ bool; if _v.Vague, _ok_ = _buf["vague"].(string); !_ok_ { err = errors.New("vague error"); return } } { var _ok_ bool; if _v.PvpAnimator, _ok_ = _buf["pvpAnimator"].(string); !_ok_ { err = errors.New("pvpAnimator error"); return } } + { var _ok_ bool; if _v.Mainq, _ok_ = _buf["mainq"].(string); !_ok_ { err = errors.New("mainq error"); return } } { var _ok_ bool; if _v.Playerhead, _ok_ = _buf["playerhead"].(string); !_ok_ { err = errors.New("playerhead error"); return } } {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["name"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Name error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Name, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } } return diff --git a/sys/configure/structs/Tables.go b/sys/configure/structs/Tables.go index fa6b9beaa..077f4bb32 100644 --- a/sys/configure/structs/Tables.go +++ b/sys/configure/structs/Tables.go @@ -233,6 +233,7 @@ type Tables struct { Heroupstory *GameHeroupstory HeroupstoryChapter *GameHeroupstoryChapter HeroupstoryBattle *GameHeroupstoryBattle + HDCelebration *GameHDCelebration } func NewTables(loader JsonLoader) (*Tables, error) { @@ -1572,5 +1573,11 @@ func NewTables(loader JsonLoader) (*Tables, error) { if tables.HeroupstoryBattle, err = NewGameHeroupstoryBattle(buf) ; err != nil { return nil, err } + if buf, err = loader("game_hdcelebration") ; err != nil { + return nil, err + } + if tables.HDCelebration, err = NewGameHDCelebration(buf) ; err != nil { + return nil, err + } return tables, nil }