This commit is contained in:
meixiongfeng 2023-07-27 11:02:40 +08:00
parent 2c41019dea
commit b9b920c844
5 changed files with 209 additions and 63 deletions

View File

@ -46,10 +46,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.StonehengeGetLis
update["etime"] = stone.Etime update["etime"] = stone.Etime
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update) this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
} }
s := &DBStoneBoss{} for k, v := range this.module.modelStonehenge.GetAllStoneBoosData() {
this.module.ModuleTools.GetGlobalData(StoneBossKey, s)
for k, v := range s.BossStage {
//rooms = append(rooms, v.Roomid)
rooms[k] = v.Roomid rooms[k] = v.Roomid
} }
session.SendMsg(string(this.module.GetType()), "getlist", &pb.StonehengeGetListResp{ session.SendMsg(string(this.module.GetType()), "getlist", &pb.StonehengeGetListResp{

View File

@ -62,11 +62,10 @@ func (this *apiComp) GotoRoom(session comm.IUserSession, req *pb.StonehengeGotoR
stone.Rooms.Portal = this.module.configure.GetRoomGroupDataByLottery(req.Portal) stone.Rooms.Portal = this.module.configure.GetRoomGroupDataByLottery(req.Portal)
// 校验是否进boss // 校验是否进boss
if this.module.configure.GetFloorConfByStageId(stone.StageID)-1 == stone.CurRoomIndes { if this.module.configure.GetFloorConfByStageId(stone.StageID)-1 == stone.CurRoomIndes {
s := &DBStoneBoss{} if stage := this.module.modelStonehenge.GetStoneBoosData(stone.StageID); stage != nil {
this.module.ModuleTools.GetGlobalData(StoneBossKey, s) stone.Rooms.Portal = []int32{stage.Roomid}
if v, ok := s.BossStage[stone.StageID]; ok {
stone.Rooms.Portal = []int32{v.Roomid}
} }
} }
update["rooms"] = stone.Rooms update["rooms"] = stone.Rooms
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update) this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)

View File

@ -5,6 +5,7 @@ import (
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure" "go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"sync" "sync"
@ -87,7 +88,6 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
configure.RegisterConfigure(game_stageconf, cfg.NewGameStoneStage, this.LoadGameStoneStage) configure.RegisterConfigure(game_stageconf, cfg.NewGameStoneStage, this.LoadGameStoneStage)
configure.RegisterConfigure(game_buffconf, cfg.NewGameStoneBuff, this.LoadGameStoneBuff) configure.RegisterConfigure(game_buffconf, cfg.NewGameStoneBuff, this.LoadGameStoneBuff)
this.CheckStage()
return return
} }
@ -614,28 +614,27 @@ func (this *configureComp) GetGameStoneBuff(addType int32) (m map[int32]struct{}
return this.buff[addType] return this.buff[addType]
} }
func (this *configureComp) CheckStage() (bossStage map[int32]*StageData) { func (this *configureComp) CheckStage() (bossStage map[int32]*pb.StageData) {
var ( var (
boosEvent map[int32]int32 // key stageid value rommid boosEvent map[int32]int32 // key stageid value rommid
) )
bossStage = make(map[int32]*StageData, 0) bossStage = make(map[int32]*pb.StageData, 0)
boosEvent = make(map[int32]int32, 0) boosEvent = make(map[int32]int32, 0)
for k, v := range this.szStage { for k, v := range this.szStage {
if c := this.GetStageConfByStageid(k, v-1); c != nil { if c := this.GetStageConfByStageid(k, v-1); c != nil {
// 根据传送门组生成传送门 // 根据传送门组生成传送门
if rooms := this.GetRoomGroupDataByLottery(c.PortalGroup); len(rooms) > 0 { if rooms := this.GetRoomGroupDataByLottery(c.PortalGroup); len(rooms) > 0 {
stageData := &StageData{} stageData := &pb.StageData{}
boosEvent[k] = rooms[0] boosEvent[k] = rooms[0]
if roomconf, err := this.GetStoneRoomDataById(rooms[0]); err == nil { if roomconf, err := this.GetStoneRoomDataById(rooms[0]); err == nil {
// buff 组 roomconf.BossEvent
this.GetEventGroupDataByLottery(roomconf.BossEvent)
// 生成 我方buff // 生成 我方buff
if bossConf := this.GetBossConfById(roomconf.BossEvent); bossConf != nil { if bossConf := this.GetBossConfById(roomconf.BossEvent); bossConf != nil {
stageData.MaineBuff = this.GetBuffGroupDataByLottery(bossConf.FriendlyBuffGroup, 0, nil) stageData.Mainebuff = this.GetBuffGroupDataByLottery(bossConf.FriendlyBuffGroup, 0, nil)
stageData.EnemyBuff = this.GetBuffGroupDataByLottery(bossConf.EnemyBuffGroup, 0, nil) stageData.Enemybuff = this.GetBuffGroupDataByLottery(bossConf.EnemyBuffGroup, 0, nil)
} }
stageData.Roomid = rooms[0] stageData.Roomid = rooms[0]
stageData.Rtime = configure.Now().Unix()
} }
bossStage[k] = stageData bossStage[k] = stageData
} }

View File

@ -7,6 +7,7 @@ import (
"go_dreamfactory/lego/sys/mgo" "go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"sync" "sync"
@ -19,23 +20,13 @@ const (
StoneBossKey = "StoneBossKey" StoneBossKey = "StoneBossKey"
) )
type DBStoneBoss struct {
BossStage map[int32]*StageData
}
type StageData struct {
MaineBuff []int32 // 我方buff
EnemyBuff []int32 // 敌方buff
Roomid int32 // 传送门id
Rtime int64 // 刷新时间
}
// 石阵秘境 // 石阵秘境
type MStonehenge struct { type MStonehenge struct {
modules.MCompModel modules.MCompModel
module *Stonehenge module *Stonehenge
lock sync.RWMutex lock sync.RWMutex
bossStage map[int32]*StageData bossStage map[int32]*pb.StageData
} }
//组件初始化接口 //组件初始化接口
@ -43,7 +34,7 @@ func (this *MStonehenge) Init(service core.IService, module core.IModule, comp c
this.TableName = comm.TableStonehenge this.TableName = comm.TableStonehenge
this.MCompModel.Init(service, module, comp, opt) this.MCompModel.Init(service, module, comp, opt)
this.module = module.(*Stonehenge) this.module = module.(*Stonehenge)
this.bossStage = make(map[int32]*StageData) this.bossStage = make(map[int32]*pb.StageData)
//创建uid索引 //创建uid索引
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
@ -83,28 +74,25 @@ func (this *MStonehenge) ChangeStonehengeData(uid string, update map[string]inte
} }
func (this *MStonehenge) loadStoneBoos() (err error) { func (this *MStonehenge) loadStoneBoos() (err error) {
var (
bNewData bool s := &pb.DBStoneBoss{}
)
s := &DBStoneBoss{}
this.module.ModuleTools.GetGlobalData(StoneBossKey, s) this.module.ModuleTools.GetGlobalData(StoneBossKey, s)
if len(s.BossStage) == 0 { if len(s.Bossstage) == 0 || utils.WeekIntervalTime(0) != s.Rtime {
bNewData = true
} else { // 校验时间
for _, v := range s.BossStage {
if utils.WeekIntervalTime(0) != v.Rtime {
bNewData = true
break
}
}
}
if bNewData {
this.lock.Lock() this.lock.Lock()
this.bossStage = this.module.configure.CheckStage() this.bossStage = this.module.configure.CheckStage()
this.lock.Unlock() this.lock.Unlock()
this.module.ModuleTools.UpdateGlobalData(StoneBossKey, map[string]interface{}{ this.module.ModuleTools.UpdateGlobalData(StoneBossKey, map[string]interface{}{
"BossStage": this.bossStage, "BossStage": this.bossStage,
"rtime": configure.Now().Unix(),
}) })
} }
return return
} }
func (this *MStonehenge) GetStoneBoosData(id int32) (bossstage *pb.StageData) {
return this.bossStage[id]
}
func (this *MStonehenge) GetAllStoneBoosData() (bossstage map[int32]*pb.StageData) {
return this.bossStage
}

View File

@ -244,6 +244,124 @@ func (x *DBStonehenge) GetEtime() int64 {
return 0 return 0
} }
type StageData struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Mainebuff []int32 `protobuf:"varint,1,rep,packed,name=mainebuff,proto3" json:"mainebuff"` // 我方buff
Enemybuff []int32 `protobuf:"varint,2,rep,packed,name=enemybuff,proto3" json:"enemybuff"` // 敌方buff
Roomid int32 `protobuf:"varint,3,opt,name=roomid,proto3" json:"roomid"` // 传送门id
}
func (x *StageData) Reset() {
*x = StageData{}
if protoimpl.UnsafeEnabled {
mi := &file_stonehenge_stonehenge_db_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StageData) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StageData) ProtoMessage() {}
func (x *StageData) ProtoReflect() protoreflect.Message {
mi := &file_stonehenge_stonehenge_db_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use StageData.ProtoReflect.Descriptor instead.
func (*StageData) Descriptor() ([]byte, []int) {
return file_stonehenge_stonehenge_db_proto_rawDescGZIP(), []int{2}
}
func (x *StageData) GetMainebuff() []int32 {
if x != nil {
return x.Mainebuff
}
return nil
}
func (x *StageData) GetEnemybuff() []int32 {
if x != nil {
return x.Enemybuff
}
return nil
}
func (x *StageData) GetRoomid() int32 {
if x != nil {
return x.Roomid
}
return 0
}
type DBStoneBoss struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Bossstage map[int32]*StageData `protobuf:"bytes,1,rep,name=bossstage,proto3" json:"bossstage" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
Rtime int64 `protobuf:"varint,2,opt,name=rtime,proto3" json:"rtime"`
}
func (x *DBStoneBoss) Reset() {
*x = DBStoneBoss{}
if protoimpl.UnsafeEnabled {
mi := &file_stonehenge_stonehenge_db_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DBStoneBoss) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DBStoneBoss) ProtoMessage() {}
func (x *DBStoneBoss) ProtoReflect() protoreflect.Message {
mi := &file_stonehenge_stonehenge_db_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DBStoneBoss.ProtoReflect.Descriptor instead.
func (*DBStoneBoss) Descriptor() ([]byte, []int) {
return file_stonehenge_stonehenge_db_proto_rawDescGZIP(), []int{3}
}
func (x *DBStoneBoss) GetBossstage() map[int32]*StageData {
if x != nil {
return x.Bossstage
}
return nil
}
func (x *DBStoneBoss) GetRtime() int64 {
if x != nil {
return x.Rtime
}
return 0
}
var File_stonehenge_stonehenge_db_proto protoreflect.FileDescriptor var File_stonehenge_stonehenge_db_proto protoreflect.FileDescriptor
var file_stonehenge_stonehenge_db_proto_rawDesc = []byte{ var file_stonehenge_stonehenge_db_proto_rawDesc = []byte{
@ -304,8 +422,24 @@ var file_stonehenge_stonehenge_db_proto_rawDesc = []byte{
0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x74, 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, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 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, 0x38, 0x01, 0x22, 0x5f, 0x0a, 0x09, 0x53, 0x74, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12,
0x6f, 0x33, 0x1c, 0x0a, 0x09, 0x6d, 0x61, 0x69, 0x6e, 0x65, 0x62, 0x75, 0x66, 0x66, 0x18, 0x01, 0x20, 0x03,
0x28, 0x05, 0x52, 0x09, 0x6d, 0x61, 0x69, 0x6e, 0x65, 0x62, 0x75, 0x66, 0x66, 0x12, 0x1c, 0x0a,
0x09, 0x65, 0x6e, 0x65, 0x6d, 0x79, 0x62, 0x75, 0x66, 0x66, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05,
0x52, 0x09, 0x65, 0x6e, 0x65, 0x6d, 0x79, 0x62, 0x75, 0x66, 0x66, 0x12, 0x16, 0x0a, 0x06, 0x72,
0x6f, 0x6f, 0x6d, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x72, 0x6f, 0x6f,
0x6d, 0x69, 0x64, 0x22, 0xa8, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x53, 0x74, 0x6f, 0x6e, 0x65, 0x42,
0x6f, 0x73, 0x73, 0x12, 0x39, 0x0a, 0x09, 0x62, 0x6f, 0x73, 0x73, 0x73, 0x74, 0x61, 0x67, 0x65,
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x44, 0x42, 0x53, 0x74, 0x6f, 0x6e, 0x65,
0x42, 0x6f, 0x73, 0x73, 0x2e, 0x42, 0x6f, 0x73, 0x73, 0x73, 0x74, 0x61, 0x67, 0x65, 0x45, 0x6e,
0x74, 0x72, 0x79, 0x52, 0x09, 0x62, 0x6f, 0x73, 0x73, 0x73, 0x74, 0x61, 0x67, 0x65, 0x12, 0x14,
0x0a, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x72,
0x74, 0x69, 0x6d, 0x65, 0x1a, 0x48, 0x0a, 0x0e, 0x42, 0x6f, 0x73, 0x73, 0x73, 0x74, 0x61, 0x67,
0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20,
0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x53, 0x74, 0x61, 0x67, 0x65, 0x44,
0x61, 0x74, 0x61, 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,
} }
var ( var (
@ -320,28 +454,33 @@ func file_stonehenge_stonehenge_db_proto_rawDescGZIP() []byte {
return file_stonehenge_stonehenge_db_proto_rawDescData return file_stonehenge_stonehenge_db_proto_rawDescData
} }
var file_stonehenge_stonehenge_db_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_stonehenge_stonehenge_db_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_stonehenge_stonehenge_db_proto_goTypes = []interface{}{ var file_stonehenge_stonehenge_db_proto_goTypes = []interface{}{
(*RoomData)(nil), // 0: RoomData (*RoomData)(nil), // 0: RoomData
(*DBStonehenge)(nil), // 1: DBStonehenge (*DBStonehenge)(nil), // 1: DBStonehenge
nil, // 2: RoomData.EventidEntry (*StageData)(nil), // 2: StageData
nil, // 3: DBStonehenge.UserbuffEntry (*DBStoneBoss)(nil), // 3: DBStoneBoss
nil, // 4: DBStonehenge.RewardEntry nil, // 4: RoomData.EventidEntry
nil, // 5: DBStonehenge.AddweightEntry nil, // 5: DBStonehenge.UserbuffEntry
(*BattleRole)(nil), // 6: BattleRole nil, // 6: DBStonehenge.RewardEntry
nil, // 7: DBStonehenge.AddweightEntry
nil, // 8: DBStoneBoss.BossstageEntry
(*BattleRole)(nil), // 9: BattleRole
} }
var file_stonehenge_stonehenge_db_proto_depIdxs = []int32{ var file_stonehenge_stonehenge_db_proto_depIdxs = []int32{
2, // 0: RoomData.eventid:type_name -> RoomData.EventidEntry 4, // 0: RoomData.eventid:type_name -> RoomData.EventidEntry
0, // 1: DBStonehenge.rooms:type_name -> RoomData 0, // 1: DBStonehenge.rooms:type_name -> RoomData
3, // 2: DBStonehenge.userbuff:type_name -> DBStonehenge.UserbuffEntry 5, // 2: DBStonehenge.userbuff:type_name -> DBStonehenge.UserbuffEntry
6, // 3: DBStonehenge.hero:type_name -> BattleRole 9, // 3: DBStonehenge.hero:type_name -> BattleRole
4, // 4: DBStonehenge.reward:type_name -> DBStonehenge.RewardEntry 6, // 4: DBStonehenge.reward:type_name -> DBStonehenge.RewardEntry
5, // 5: DBStonehenge.addweight:type_name -> DBStonehenge.AddweightEntry 7, // 5: DBStonehenge.addweight:type_name -> DBStonehenge.AddweightEntry
6, // [6:6] is the sub-list for method output_type 8, // 6: DBStoneBoss.bossstage:type_name -> DBStoneBoss.BossstageEntry
6, // [6:6] is the sub-list for method input_type 2, // 7: DBStoneBoss.BossstageEntry.value:type_name -> StageData
6, // [6:6] is the sub-list for extension type_name 8, // [8:8] is the sub-list for method output_type
6, // [6:6] is the sub-list for extension extendee 8, // [8:8] is the sub-list for method input_type
0, // [0:6] is the sub-list for field type_name 8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
} }
func init() { file_stonehenge_stonehenge_db_proto_init() } func init() { file_stonehenge_stonehenge_db_proto_init() }
@ -375,6 +514,30 @@ func file_stonehenge_stonehenge_db_proto_init() {
return nil return nil
} }
} }
file_stonehenge_stonehenge_db_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StageData); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_stonehenge_stonehenge_db_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DBStoneBoss); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -382,7 +545,7 @@ func file_stonehenge_stonehenge_db_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_stonehenge_stonehenge_db_proto_rawDesc, RawDescriptor: file_stonehenge_stonehenge_db_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 6, NumMessages: 9,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },