diff --git a/bin/json/game_horoscope.json b/bin/json/game_horoscope.json index daa8bfb39..3e69b2563 100644 --- a/bin/json/game_horoscope.json +++ b/bin/json/game_horoscope.json @@ -524,7 +524,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -557,7 +557,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -617,7 +617,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -650,7 +650,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -710,7 +710,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -743,7 +743,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -1181,7 +1181,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -1214,7 +1214,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -1274,7 +1274,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -1307,7 +1307,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -1367,7 +1367,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -1400,7 +1400,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -1838,7 +1838,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -1871,7 +1871,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -1931,7 +1931,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -1964,7 +1964,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -2024,7 +2024,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -2057,7 +2057,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -2495,7 +2495,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -2528,7 +2528,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -2588,7 +2588,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -2621,7 +2621,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -2681,7 +2681,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, @@ -2714,7 +2714,7 @@ { "a": "attr", "t": "starcoin", - "n": 2 + "n": 1 } ], "AddGroup": 1, diff --git a/bin/json/game_worldtask.json b/bin/json/game_worldtask.json index d03b94a89..cb8dad978 100644 --- a/bin/json/game_worldtask.json +++ b/bin/json/game_worldtask.json @@ -5533,7 +5533,7 @@ "lock": 1, "lockend": 999, "ontxe": 300010, - "id_after": 0, + "id_after": 300030, "group": 301, "exgroup": 310, "des": 3, @@ -5787,7 +5787,7 @@ "lock": 1, "lockend": 999, "ontxe": 300061, - "id_after": 0, + "id_after": 300070, "group": 301, "exgroup": 310, "des": 3, @@ -5827,7 +5827,7 @@ "lock": 1, "lockend": 999, "ontxe": 300062, - "id_after": 0, + "id_after": 300080, "group": 301, "exgroup": 310, "des": 3, diff --git a/modules/activity/api_gethddata.go b/modules/activity/api_gethddata.go index ecefe3487..876a0c6d2 100644 --- a/modules/activity/api_gethddata.go +++ b/modules/activity/api_gethddata.go @@ -14,17 +14,25 @@ func (this *apiComp) GetHdDataCheck(session comm.IUserSession, req *pb.ActivityG } func (this *apiComp) GetHdData(session comm.IUserSession, req *pb.ActivityGetHdDataReq) (errdata *pb.ErrorData) { + var ( + list *pb.DBActivityData + err error + ) + if req.Oid == "" { - list, err := this.module.modelhdData.getHddataByOid(session.GetUserId(), req.Oid) - if err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_DBError, - Title: pb.ErrorCode_DBError.ToString(), + } else { + list, err = this.module.modelhdData.getHddataByOid(session.GetUserId(), req.Oid) + if err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + } + return } - return + } // 校验活动是否过期 - if a, err := this.module.modelhdList.getHdInfoByHdId(req.Oid); err != nil { + if a, err := this.module.modelhdList.getHdListByHdId(req.Oid); err != nil { curTime := configure.Now().Unix() if a.Htype == comm.HdTypeSign && a.Stime <= curTime && curTime <= a.Etime { @@ -38,9 +46,8 @@ func (this *apiComp) GetHdData(session comm.IUserSession, req *pb.ActivityGetHdD } } } - session.SendMsg(string(this.module.GetType()), "gethddata", &pb.ActivityGetHdDataResp{ - Data: list, + Data: []*pb.DBActivityData{list}, }) return } diff --git a/modules/activity/api_getreward.go b/modules/activity/api_getreward.go index 9de0bd079..2879de49e 100644 --- a/modules/activity/api_getreward.go +++ b/modules/activity/api_getreward.go @@ -28,7 +28,7 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.ActivityGetRew reward []*cfg.Gameatn atno []*pb.UserAtno ) - if activity, err = this.module.modelhdList.getHdInfoByHdId(req.Oid); err != nil { + if activity, err = this.module.modelhdList.getHdListByHdId(req.Oid); err != nil { curTime := configure.Now().Unix() if activity.Stime <= curTime && curTime <= activity.Etime { @@ -69,7 +69,7 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.ActivityGetRew } } } - data.Gotarr[req.Val] = true + data.Gotarr[req.Val] = 1 update := make(map[string]interface{}) update["gotarr"] = data.Gotarr this.module.modelhdData.ModifyActivityList(session.GetUserId(), data.Id, update) diff --git a/modules/activity/comp_configure.go b/modules/activity/comp_configure.go index 7941fc6f5..c220eb16a 100644 --- a/modules/activity/comp_configure.go +++ b/modules/activity/comp_configure.go @@ -1,23 +1,60 @@ package activity import ( + "fmt" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/sys/configure" + cfg "go_dreamfactory/sys/configure/structs" + "sync" ) -const () +const ( + venturegiftsdraw = "game_venturegiftsdraw.json" //大转盘 +) // /配置管理基础组件 type configureComp struct { modules.MCompConfigure + module *Activity + hlock sync.RWMutex + pool1 map[int32]*cfg.GameVenturegiftsDrawData + pool2 map[int32]*cfg.GameVenturegiftsDrawData } // 组件初始化接口 func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { err = this.MCompConfigure.Init(service, module, comp, options) + this.module = module.(*Activity) + err = this.LoadMultiConfigure(map[string]interface{}{ + venturegiftsdraw: cfg.NewGameVenturegiftsDraw, + }) + configure.RegisterConfigure(venturegiftsdraw, cfg.NewGameVenturegiftsDraw, func() { + var pool1 string + if v, err := this.GetConfigure(venturegiftsdraw); err == nil { + this.hlock.Lock() + this.pool1 = make(map[int32]*cfg.GameVenturegiftsDrawData) + this.pool2 = make(map[int32]*cfg.GameVenturegiftsDrawData) + defer this.hlock.Unlock() + if _configure, ok := v.(*cfg.GameVenturegiftsDraw); ok { + for _, v := range _configure.GetDataList() { + if pool1 == "" { + pool1 = v.DrawType + } + if pool1 == v.DrawType { + this.pool1[v.Drawkey] = v + } else { + this.pool2[v.Drawkey] = v + } + } + return + } + } else { + err = fmt.Errorf("%T no is *cfg.GameHeroAwaken", v) + } + }) return } @@ -37,3 +74,26 @@ func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err func (this *configureComp) GetConfigure(name string) (v interface{}, err error) { return configure.GetConfigure(name) } + +// 获取抽奖数据 +func (this *configureComp) GetVenturegiftsDraw(id int32) (configure *cfg.GameVenturegiftsDrawData, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(venturegiftsdraw); err == nil { + if configure, ok = v.(*cfg.GameVenturegiftsDraw).GetDataMap()[id]; !ok { + err = fmt.Errorf("%T no is *cfg.GameVenturegiftsDrawData", v) + return + } + } + return +} + +func (this *configureComp) GetPool1() (m map[int32]*cfg.GameVenturegiftsDrawData) { + return this.pool1 +} + +func (this *configureComp) GetPool2() (m map[int32]*cfg.GameVenturegiftsDrawData) { + return this.pool2 +} diff --git a/modules/activity/model_hdlist.go b/modules/activity/model_hdlist.go index 7915a348e..6d45913a1 100644 --- a/modules/activity/model_hdlist.go +++ b/modules/activity/model_hdlist.go @@ -47,7 +47,7 @@ func (this *modelHdList) getHdInfo() (result []*pb.DBHuodong, err error) { } // 通过活动ID查找 -func (this *modelHdList) getHdInfoByHdId(oid string) (result *pb.DBHuodong, err error) { +func (this *modelHdList) getHdListByHdId(oid string) (result *pb.DBHuodong, err error) { _data := this.DBModel.DB.FindOne(comm.TableHdInfo, bson.M{"_id": oid}) diff --git a/modules/activity/module.go b/modules/activity/module.go index 6825922f8..c533bcd06 100644 --- a/modules/activity/module.go +++ b/modules/activity/module.go @@ -5,7 +5,7 @@ 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" ) @@ -144,16 +144,53 @@ func (this *Activity) GetAllHdInfo() (result []*pb.DBHuodong, err error) { // 通过活动ID查找 func (this *Activity) GetHdInfoByHdId(oid string) (result *pb.DBHuodong, err error) { - result, err = this.modelhdList.getHdInfoByHdId(oid) + result, err = this.modelhdList.getHdListByHdId(oid) return } -// 更新签到进度 -func (this *Activity) UpdateSingnActivitySlider(session comm.IUserSession) { - curTime := configure.Now().Unix() - if rst, err := this.modelhdList.getHdInfoByHdType(comm.HdTypeSign); err == nil { - if rst.Stime <= curTime && curTime <= rst.Etime { +// 大转盘奖励 +func (this *Activity) Turntable(drawIndex int32, reward []int32) (item *cfg.Gameatn, err error) { + var ( + conf *cfg.GameVenturegiftsDrawData + szW []int32 // 权重 + szpool []int32 // drawkey + ) + if conf, err = this.configure.GetVenturegiftsDraw(drawIndex); err != nil { + return + } + // 过滤已经获得的道具 + for _, v := range this.configure.pool1 { + bFound := false + for _, v1 := range reward { + if v.Drawkey == v1 { + bFound = true + break + } + } + if !bFound { + szW = append(szW, v.Weight) + szpool = append(szpool, v.Drawkey) } } + if conf.Type == 2 { + for _, v := range this.configure.pool2 { + bFound := false + for _, v1 := range reward { + if v.Drawkey == v1 { + bFound = true + break + } + } + if !bFound { + szW = append(szW, v.Weight) + szpool = append(szpool, v.Drawkey) + } + } + } + if c, err := this.configure.GetVenturegiftsDraw(szpool[comm.GetRandW(szW)]); err != nil { + item = c.Id // 最终获得的道具 + } + + return } diff --git a/pb/activity_db.pb.go b/pb/activity_db.pb.go index 66aee3609..54994408a 100644 --- a/pb/activity_db.pb.go +++ b/pb/activity_db.pb.go @@ -327,12 +327,12 @@ type DBActivityData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` - Hdoid string `protobuf:"bytes,3,opt,name=hdoid,proto3" json:"hdoid"` // 活动唯一id - Gotarr map[int32]bool `protobuf:"bytes,4,rep,name=gotarr,proto3" json:"gotarr" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` - Lasttime int64 `protobuf:"varint,5,opt,name=lasttime,proto3" json:"lasttime"` - Val int32 `protobuf:"varint,6,opt,name=val,proto3" json:"val"` // 第几天登录 + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` + Hdoid string `protobuf:"bytes,3,opt,name=hdoid,proto3" json:"hdoid"` // 活动唯一id + Gotarr map[int32]int32 `protobuf:"bytes,4,rep,name=gotarr,proto3" json:"gotarr" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + Lasttime int64 `protobuf:"varint,5,opt,name=lasttime,proto3" json:"lasttime"` + Val int32 `protobuf:"varint,6,opt,name=val,proto3" json:"val"` // 第几天登录 } func (x *DBActivityData) Reset() { @@ -388,7 +388,7 @@ func (x *DBActivityData) GetHdoid() string { return "" } -func (x *DBActivityData) GetGotarr() map[int32]bool { +func (x *DBActivityData) GetGotarr() map[int32]int32 { if x != nil { return x.Gotarr } @@ -463,7 +463,7 @@ var file_activity_activity_db_proto_rawDesc = []byte{ 0x61, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x1a, 0x39, 0x0a, 0x0b, 0x47, 0x6f, 0x74, 0x61, 0x72, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } diff --git a/pb/activity_msg.pb.go b/pb/activity_msg.pb.go index 0bb6a2f8e..755dfd7cd 100644 --- a/pb/activity_msg.pb.go +++ b/pb/activity_msg.pb.go @@ -106,12 +106,13 @@ func (x *ActivityGetListResp) GetData() []*DBHuodong { return nil } +// 玩家活动数据 type ActivityGetHdDataReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Oid string `protobuf:"bytes,1,opt,name=oid,proto3" json:"oid"` + Oid string `protobuf:"bytes,1,opt,name=oid,proto3" json:"oid"` // obj 为空 取所有的活动 } func (x *ActivityGetHdDataReq) Reset() { @@ -159,7 +160,7 @@ type ActivityGetHdDataResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Data *DBActivityData `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` + Data []*DBActivityData `protobuf:"bytes,1,rep,name=data,proto3" json:"data"` } func (x *ActivityGetHdDataResp) Reset() { @@ -194,7 +195,7 @@ func (*ActivityGetHdDataResp) Descriptor() ([]byte, []int) { return file_activity_activity_msg_proto_rawDescGZIP(), []int{3} } -func (x *ActivityGetHdDataResp) GetData() *DBActivityData { +func (x *ActivityGetHdDataResp) GetData() []*DBActivityData { if x != nil { return x.Data } @@ -330,7 +331,7 @@ var file_activity_activity_msg_proto_rawDesc = []byte{ 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x69, 0x64, 0x22, 0x3c, 0x0a, 0x15, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x47, 0x65, 0x74, 0x48, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, 0x42, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, + 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, 0x42, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x3a, 0x0a, 0x14, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x47, 0x65, 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,