diff --git a/etcd/keyconf.go b/etcd/keyconf.go index 25e3733..f13819d 100644 --- a/etcd/keyconf.go +++ b/etcd/keyconf.go @@ -30,18 +30,19 @@ const ( ETCDKEY_PLAYERPOOL = "/game/plt/playerpool/" // 个人水池调控配置 ETCDKEY_GAME_CONFIG = "/game/plt/gameconfig/" // 游戏管理/全局配置 ETCDKEY_ACT_PHONELOTTERY = "/game/act_phoneLottery" - ETCDKEY_ChannelSwitch = "/game/channel/switch" // 渠道开关 - ETCDKEY_ACT_Invite = "/game/act_invite" // 邀请活动配置 - ETCDKEY_ACT_Permit = "/game/act_permit" // 赛季通行证配置 - ETCDKEY_DIAMOND_LOTTERY = "/game/diamond_lottery" // 钻石抽奖配置 - ETCDKEY_Item = "/game/item" // 道具列表 - ETCDKEY_SKin = "/game/skin_config" // 皮肤配置 - ETCDKEY_RANK_TYPE = "/game/RankType" // 排行榜奖励配置 - ETCDKEY_AWARD_CONFIG = "/game/awardlog_config" //获奖记录 - ETCDKEY_GUIDE = "/game/guide_config" //新手引导配置 - ETCDKEY_MACHINE = "/game/machine_config" //娃娃机配置 - ETCDKEY_MatchAudience = "/game/match_audience" //比赛观众 - ETCDKEY_Spirit = "/game/spirit" // 小精灵配置 - ETCDKEY_RoomType = "/game/room_type" // 房间类型配置 - ETCDKEY_RoomConfig = "/game/room_config" // 房间配置 + ETCDKEY_ChannelSwitch = "/game/channel/switch" // 渠道开关 + ETCDKEY_ACT_Invite = "/game/act_invite" // 邀请活动配置 + ETCDKEY_ACT_Permit = "/game/act_permit" // 赛季通行证配置 + ETCDKEY_DIAMOND_LOTTERY = "/game/diamond_lottery" // 钻石抽奖配置 + ETCDKEY_Item = "/game/item" // 道具列表 + ETCDKEY_SKin = "/game/skin_config" // 皮肤配置 + ETCDKEY_RANK_TYPE = "/game/RankType" // 排行榜奖励配置 + ETCDKEY_AWARD_CONFIG = "/game/awardlog_config" //获奖记录 + ETCDKEY_GUIDE = "/game/guide_config" //新手引导配置 + ETCDKEY_MACHINE = "/game/machine_config" //娃娃机配置 + ETCDKEY_MatchAudience = "/game/match_audience" //比赛观众 + ETCDKEY_Spirit = "/game/spirit" // 小精灵配置 + ETCDKEY_RoomType = "/game/room_type" // 房间类型配置 + ETCDKEY_RoomConfig = "/game/room_config" // 房间配置 + ETCDKEY_RoomConfigSystem = "/game/system_room_config" // 系统房间配置 ) diff --git a/gamesrv/base/scene.go b/gamesrv/base/scene.go index e54f299..7ee4f14 100644 --- a/gamesrv/base/scene.go +++ b/gamesrv/base/scene.go @@ -33,10 +33,6 @@ type GameScene interface { SceneDestroy(force bool) } -type CanRebindSnId interface { - RebindPlayerSnId(oldSnId, newSnId int32) -} - // todo 结构优化 type Scene struct { *server.WGCreateScene @@ -131,20 +127,6 @@ func (this *Scene) GetSceneType() int32 { return 0 } -func (this *Scene) RebindPlayerSnId(oldSnId, newSnId int32) { - if p, exist := this.Players[oldSnId]; exist { - delete(this.Players, oldSnId) - this.Players[newSnId] = p - } - if p, exist := this.audiences[oldSnId]; exist { - delete(this.audiences, oldSnId) - this.audiences[newSnId] = p - } - if rebind, ok := this.ExtraData.(CanRebindSnId); ok { - rebind.RebindPlayerSnId(oldSnId, newSnId) - } -} - func (this *Scene) GetInit() bool { return this.init() } @@ -1218,20 +1200,6 @@ func (this *Scene) NotifySceneRoundPause() { this.SendToWorld(int(server.SSPacketID_PACKET_GW_SCENESTART), pack) } -func (this *Scene) SyncGameState(sec, bl int) { - if this.SceneState != nil { - pack := &server.GWGameState{ - SceneId: this.SceneId, - State: proto.Int(this.SceneState.GetState()), - Ts: proto.Int64(time.Now().Unix()), - Sec: proto.Int(sec), - BankerListNum: proto.Int(bl), - } - proto.SetDefaults(pack) - this.SendToWorld(int(server.SSPacketID_PACKET_GW_GAMESTATE), pack) - } -} - // SyncScenePlayer 游戏开始的时候同步防伙牌数据 func (this *Scene) SyncScenePlayer() { pack := &server.GWScenePlayerLog{ diff --git a/gamesrv/base/scene_mgr.go b/gamesrv/base/scene_mgr.go index 4be3d5e..403251e 100644 --- a/gamesrv/base/scene_mgr.go +++ b/gamesrv/base/scene_mgr.go @@ -183,12 +183,6 @@ func (this *SceneMgr) OnMonthTimer() { // } } -func (this *SceneMgr) RebindPlayerSnId(oldSnId, newSnId int32) { - for _, s := range this.scenes { - s.RebindPlayerSnId(oldSnId, newSnId) - } -} - func (this *SceneMgr) DestoryAllScene() { for _, s := range this.scenes { s.Destroy(true) diff --git a/model/config.go b/model/config.go index 4ba254c..8cc0b9a 100644 --- a/model/config.go +++ b/model/config.go @@ -150,6 +150,8 @@ type AllConfig struct { // 房卡场房间配置 RoomConfig map[int32]*webapi.RoomConfig // key: 房间配置id RoomTypeMap map[int32][]*webapi.RoomConfig // key: 房间类型id:房间配置 + // 系统房间配置 + RoomConfigSystem map[int32]*webapi.RoomConfigSystem } type GlobalConfig struct { @@ -175,13 +177,14 @@ func (cm *ConfigMgr) GetConfig(platform string) *AllConfig { if !ok { c = &AllConfig{ // todo 初始化默认值 - EntrySwitch: make(map[int32]*webapi.EntrySwitch), - ShopInfos: make(map[int32]*ShopInfo), - ChannelSwitch: make(map[int32]*webapi.ChannelSwitchConfig), - MatchAudience: make(map[int32]*webapi.MatchAudience), - RoomType: make(map[int32]*webapi.RoomType), - RoomConfig: make(map[int32]*webapi.RoomConfig), - RoomTypeMap: make(map[int32][]*webapi.RoomConfig), + EntrySwitch: make(map[int32]*webapi.EntrySwitch), + ShopInfos: make(map[int32]*ShopInfo), + ChannelSwitch: make(map[int32]*webapi.ChannelSwitchConfig), + MatchAudience: make(map[int32]*webapi.MatchAudience), + RoomType: make(map[int32]*webapi.RoomType), + RoomConfig: make(map[int32]*webapi.RoomConfig), + RoomTypeMap: make(map[int32][]*webapi.RoomConfig), + RoomConfigSystem: make(map[int32]*webapi.RoomConfigSystem), } cm.platform[platform] = c } diff --git a/protocol/webapi/common.pb.go b/protocol/webapi/common.pb.go index 34d5de1..2f4e42a 100644 --- a/protocol/webapi/common.pb.go +++ b/protocol/webapi/common.pb.go @@ -8769,6 +8769,150 @@ func (x *RoomConfig) GetImageURI() string { return "" } +// etcd /game/room_config_system +type RoomConfigSystem struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Platform string `protobuf:"bytes,1,opt,name=Platform,proto3" json:"Platform,omitempty"` // 平台 + Id int32 `protobuf:"varint,2,opt,name=Id,proto3" json:"Id,omitempty"` // 配置id + RoomConfigId int32 `protobuf:"varint,3,opt,name=RoomConfigId,proto3" json:"RoomConfigId,omitempty"` // 房间配置id + GameFreeId int32 `protobuf:"varint,4,opt,name=GameFreeId,proto3" json:"GameFreeId,omitempty"` // 场次id + Round int32 `protobuf:"varint,5,opt,name=Round,proto3" json:"Round,omitempty"` // 局数 + PlayerNum int32 `protobuf:"varint,6,opt,name=PlayerNum,proto3" json:"PlayerNum,omitempty"` // 人数 + NeedPassword int32 `protobuf:"varint,7,opt,name=NeedPassword,proto3" json:"NeedPassword,omitempty"` // 是否需要密码 1是 2否 + CostType int32 `protobuf:"varint,8,opt,name=CostType,proto3" json:"CostType,omitempty"` // 消耗类型 1AA 2房主 + Voice int32 `protobuf:"varint,9,opt,name=Voice,proto3" json:"Voice,omitempty"` // 是否开启语音 1是 2否 + State int32 `protobuf:"varint,10,opt,name=State,proto3" json:"State,omitempty"` // 房间状态 1空 2满人(假人) + FullTime int32 `protobuf:"varint,11,opt,name=FullTime,proto3" json:"FullTime,omitempty"` // 房间状态为满人时房间保留多久,单位秒 + AutoCreate int32 `protobuf:"varint,12,opt,name=AutoCreate,proto3" json:"AutoCreate,omitempty"` // 自动创建开关 1开启 2关闭 + AutoCreateTime int32 `protobuf:"varint,13,opt,name=AutoCreateTime,proto3" json:"AutoCreateTime,omitempty"` // 自动创建时间间隔,单位秒 +} + +func (x *RoomConfigSystem) Reset() { + *x = RoomConfigSystem{} + if protoimpl.UnsafeEnabled { + mi := &file_common_proto_msgTypes[92] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RoomConfigSystem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoomConfigSystem) ProtoMessage() {} + +func (x *RoomConfigSystem) ProtoReflect() protoreflect.Message { + mi := &file_common_proto_msgTypes[92] + 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 RoomConfigSystem.ProtoReflect.Descriptor instead. +func (*RoomConfigSystem) Descriptor() ([]byte, []int) { + return file_common_proto_rawDescGZIP(), []int{92} +} + +func (x *RoomConfigSystem) GetPlatform() string { + if x != nil { + return x.Platform + } + return "" +} + +func (x *RoomConfigSystem) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *RoomConfigSystem) GetRoomConfigId() int32 { + if x != nil { + return x.RoomConfigId + } + return 0 +} + +func (x *RoomConfigSystem) GetGameFreeId() int32 { + if x != nil { + return x.GameFreeId + } + return 0 +} + +func (x *RoomConfigSystem) GetRound() int32 { + if x != nil { + return x.Round + } + return 0 +} + +func (x *RoomConfigSystem) GetPlayerNum() int32 { + if x != nil { + return x.PlayerNum + } + return 0 +} + +func (x *RoomConfigSystem) GetNeedPassword() int32 { + if x != nil { + return x.NeedPassword + } + return 0 +} + +func (x *RoomConfigSystem) GetCostType() int32 { + if x != nil { + return x.CostType + } + return 0 +} + +func (x *RoomConfigSystem) GetVoice() int32 { + if x != nil { + return x.Voice + } + return 0 +} + +func (x *RoomConfigSystem) GetState() int32 { + if x != nil { + return x.State + } + return 0 +} + +func (x *RoomConfigSystem) GetFullTime() int32 { + if x != nil { + return x.FullTime + } + return 0 +} + +func (x *RoomConfigSystem) GetAutoCreate() int32 { + if x != nil { + return x.AutoCreate + } + return 0 +} + +func (x *RoomConfigSystem) GetAutoCreateTime() int32 { + if x != nil { + return x.AutoCreateTime + } + return 0 +} + var File_common_proto protoreflect.FileDescriptor var file_common_proto_rawDesc = []byte{ @@ -10141,10 +10285,35 @@ var file_common_proto_rawDesc = []byte{ 0x28, 0x05, 0x52, 0x08, 0x43, 0x6f, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x55, 0x52, 0x49, 0x18, 0x10, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x55, 0x52, 0x49, 0x42, 0x26, - 0x5a, 0x24, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, - 0x77, 0x65, 0x62, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x55, 0x52, 0x49, 0x22, 0x86, + 0x03, 0x0a, 0x10, 0x52, 0x6f, 0x6f, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x79, 0x73, + 0x74, 0x65, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, + 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x49, 0x64, 0x12, + 0x22, 0x0a, 0x0c, 0x52, 0x6f, 0x6f, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x49, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x52, 0x6f, 0x6f, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x47, 0x61, 0x6d, 0x65, 0x46, 0x72, 0x65, 0x65, 0x49, + 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x47, 0x61, 0x6d, 0x65, 0x46, 0x72, 0x65, + 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x05, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x6c, 0x61, + 0x79, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x50, 0x6c, + 0x61, 0x79, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x12, 0x22, 0x0a, 0x0c, 0x4e, 0x65, 0x65, 0x64, 0x50, + 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x4e, + 0x65, 0x65, 0x64, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x43, + 0x6f, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x43, + 0x6f, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x56, 0x6f, 0x69, 0x63, 0x65, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x12, 0x14, 0x0a, + 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x46, 0x75, 0x6c, 0x6c, 0x54, 0x69, 0x6d, 0x65, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x46, 0x75, 0x6c, 0x6c, 0x54, 0x69, 0x6d, 0x65, 0x12, + 0x1e, 0x0a, 0x0a, 0x41, 0x75, 0x74, 0x6f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0a, 0x41, 0x75, 0x74, 0x6f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, + 0x26, 0x0a, 0x0e, 0x41, 0x75, 0x74, 0x6f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, + 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x41, 0x75, 0x74, 0x6f, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x42, 0x26, 0x5a, 0x24, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, + 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x77, 0x65, 0x62, 0x61, 0x70, 0x69, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -10159,7 +10328,7 @@ func file_common_proto_rawDescGZIP() []byte { return file_common_proto_rawDescData } -var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 102) +var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 103) var file_common_proto_goTypes = []interface{}{ (*MysqlDbSetting)(nil), // 0: webapi.MysqlDbSetting (*MongoDbSetting)(nil), // 1: webapi.MongoDbSetting @@ -10253,32 +10422,33 @@ var file_common_proto_goTypes = []interface{}{ (*SpiritConfig)(nil), // 89: webapi.SpiritConfig (*RoomType)(nil), // 90: webapi.RoomType (*RoomConfig)(nil), // 91: webapi.RoomConfig - nil, // 92: webapi.Platform.BindTelRewardEntry - nil, // 93: webapi.PlayerData.RankScoreEntry - nil, // 94: webapi.ItemShop.AwardEntry - nil, // 95: webapi.VIPcfg.AwardEntry - nil, // 96: webapi.VIPcfg.Privilege1Entry - nil, // 97: webapi.VIPcfg.Privilege7Entry - nil, // 98: webapi.VIPcfg.Privilege9Entry - nil, // 99: webapi.ActInviteConfig.PayScoreEntry - nil, // 100: webapi.SkinLevel.UpItemEntry - nil, // 101: webapi.SkinItem.UnlockParamEntry - (*server.DB_GameFree)(nil), // 102: server.DB_GameFree - (*server.DB_GameItem)(nil), // 103: server.DB_GameItem + (*RoomConfigSystem)(nil), // 92: webapi.RoomConfigSystem + nil, // 93: webapi.Platform.BindTelRewardEntry + nil, // 94: webapi.PlayerData.RankScoreEntry + nil, // 95: webapi.ItemShop.AwardEntry + nil, // 96: webapi.VIPcfg.AwardEntry + nil, // 97: webapi.VIPcfg.Privilege1Entry + nil, // 98: webapi.VIPcfg.Privilege7Entry + nil, // 99: webapi.VIPcfg.Privilege9Entry + nil, // 100: webapi.ActInviteConfig.PayScoreEntry + nil, // 101: webapi.SkinLevel.UpItemEntry + nil, // 102: webapi.SkinItem.UnlockParamEntry + (*server.DB_GameFree)(nil), // 103: server.DB_GameFree + (*server.DB_GameItem)(nil), // 104: server.DB_GameItem } var file_common_proto_depIdxs = []int32{ 2, // 0: webapi.Platform.Leaderboard:type_name -> webapi.RankSwitch 3, // 1: webapi.Platform.ClubConfig:type_name -> webapi.ClubConfig 4, // 2: webapi.Platform.ThirdGameMerchant:type_name -> webapi.ThirdGame - 92, // 3: webapi.Platform.BindTelReward:type_name -> webapi.Platform.BindTelRewardEntry + 93, // 3: webapi.Platform.BindTelReward:type_name -> webapi.Platform.BindTelRewardEntry 6, // 4: webapi.GameConfigGlobal.GameStatus:type_name -> webapi.GameStatus - 102, // 5: webapi.GameFree.DbGameFree:type_name -> server.DB_GameFree + 103, // 5: webapi.GameFree.DbGameFree:type_name -> server.DB_GameFree 8, // 6: webapi.PlatformGameConfig.DbGameFrees:type_name -> webapi.GameFree 0, // 7: webapi.PlatformDbConfig.Mysql:type_name -> webapi.MysqlDbSetting 1, // 8: webapi.PlatformDbConfig.MongoDb:type_name -> webapi.MongoDbSetting 1, // 9: webapi.PlatformDbConfig.MongoDbLog:type_name -> webapi.MongoDbSetting - 102, // 10: webapi.GameConfigGroup.DbGameFree:type_name -> server.DB_GameFree - 93, // 11: webapi.PlayerData.RankScore:type_name -> webapi.PlayerData.RankScoreEntry + 103, // 10: webapi.GameConfigGroup.DbGameFree:type_name -> server.DB_GameFree + 94, // 11: webapi.PlayerData.RankScore:type_name -> webapi.PlayerData.RankScoreEntry 32, // 12: webapi.PlayerData.Items:type_name -> webapi.ItemInfo 14, // 13: webapi.PlayerData.RoleUnlockList:type_name -> webapi.ModInfo 14, // 14: webapi.PlayerData.PetUnlockList:type_name -> webapi.ModInfo @@ -10291,7 +10461,7 @@ var file_common_proto_depIdxs = []int32{ 32, // 21: webapi.ExchangeShop.Items:type_name -> webapi.ItemInfo 25, // 22: webapi.ExchangeShopList.List:type_name -> webapi.ExchangeShop 29, // 23: webapi.ExchangeShopList.Weight:type_name -> webapi.ShopWeight - 94, // 24: webapi.ItemShop.Award:type_name -> webapi.ItemShop.AwardEntry + 95, // 24: webapi.ItemShop.Award:type_name -> webapi.ItemShop.AwardEntry 30, // 25: webapi.ItemShopList.List:type_name -> webapi.ItemShop 32, // 26: webapi.MatchInfoAward.ItemId:type_name -> webapi.ItemInfo 33, // 27: webapi.GameMatchDate.Award:type_name -> webapi.MatchInfoAward @@ -10312,14 +10482,14 @@ var file_common_proto_depIdxs = []int32{ 38, // 42: webapi.WelfareSpree.Item:type_name -> webapi.WelfareDate 48, // 43: webapi.WelfareFirstPayDataList.List:type_name -> webapi.WelfareSpree 48, // 44: webapi.WelfareContinuousPayDataList.List:type_name -> webapi.WelfareSpree - 95, // 45: webapi.VIPcfg.Award:type_name -> webapi.VIPcfg.AwardEntry - 96, // 46: webapi.VIPcfg.Privilege1:type_name -> webapi.VIPcfg.Privilege1Entry - 97, // 47: webapi.VIPcfg.Privilege7:type_name -> webapi.VIPcfg.Privilege7Entry - 98, // 48: webapi.VIPcfg.Privilege9:type_name -> webapi.VIPcfg.Privilege9Entry + 96, // 45: webapi.VIPcfg.Award:type_name -> webapi.VIPcfg.AwardEntry + 97, // 46: webapi.VIPcfg.Privilege1:type_name -> webapi.VIPcfg.Privilege1Entry + 98, // 47: webapi.VIPcfg.Privilege7:type_name -> webapi.VIPcfg.Privilege7Entry + 99, // 48: webapi.VIPcfg.Privilege9:type_name -> webapi.VIPcfg.Privilege9Entry 51, // 49: webapi.VIPcfgDataList.List:type_name -> webapi.VIPcfg 38, // 50: webapi.ChessRankConfig.Item:type_name -> webapi.WelfareDate 55, // 51: webapi.ChessRankcfgData.Datas:type_name -> webapi.ChessRankConfig - 99, // 52: webapi.ActInviteConfig.PayScore:type_name -> webapi.ActInviteConfig.PayScoreEntry + 100, // 52: webapi.ActInviteConfig.PayScore:type_name -> webapi.ActInviteConfig.PayScoreEntry 62, // 53: webapi.ActInviteConfig.Awards1:type_name -> webapi.RankAward 62, // 54: webapi.ActInviteConfig.Awards2:type_name -> webapi.RankAward 62, // 55: webapi.ActInviteConfig.Awards3:type_name -> webapi.RankAward @@ -10336,12 +10506,12 @@ var file_common_proto_depIdxs = []int32{ 69, // 66: webapi.DiamondLotteryData.Info:type_name -> webapi.DiamondLotteryInfo 70, // 67: webapi.DiamondLotteryData.Players:type_name -> webapi.DiamondLotteryPlayers 72, // 68: webapi.DiamondLotteryConfig.LotteryData:type_name -> webapi.DiamondLotteryData - 103, // 69: webapi.ItemConfig.Items:type_name -> server.DB_GameItem + 104, // 69: webapi.ItemConfig.Items:type_name -> server.DB_GameItem 32, // 70: webapi.RankAwardInfo.Item:type_name -> webapi.ItemInfo 75, // 71: webapi.RankTypeInfo.Award:type_name -> webapi.RankAwardInfo 76, // 72: webapi.RankTypeConfig.Info:type_name -> webapi.RankTypeInfo - 100, // 73: webapi.SkinLevel.UpItem:type_name -> webapi.SkinLevel.UpItemEntry - 101, // 74: webapi.SkinItem.UnlockParam:type_name -> webapi.SkinItem.UnlockParamEntry + 101, // 73: webapi.SkinLevel.UpItem:type_name -> webapi.SkinLevel.UpItemEntry + 102, // 74: webapi.SkinItem.UnlockParam:type_name -> webapi.SkinItem.UnlockParamEntry 78, // 75: webapi.SkinItem.Levels:type_name -> webapi.SkinLevel 79, // 76: webapi.SkinConfig.Items:type_name -> webapi.SkinItem 82, // 77: webapi.AwardLogConfig.AwardLog:type_name -> webapi.AwardLogData @@ -11467,6 +11637,18 @@ func file_common_proto_init() { return nil } } + file_common_proto_msgTypes[92].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RoomConfigSystem); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -11474,7 +11656,7 @@ func file_common_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_common_proto_rawDesc, NumEnums: 0, - NumMessages: 102, + NumMessages: 103, NumExtensions: 0, NumServices: 0, }, diff --git a/protocol/webapi/common.proto b/protocol/webapi/common.proto index 40e1676..19efed0 100644 --- a/protocol/webapi/common.proto +++ b/protocol/webapi/common.proto @@ -961,4 +961,21 @@ message RoomConfig { int32 CostType = 14; // 消耗类型 1AA 2房主 3自定义 int32 Voice = 15; // 是否开启语音 1是 2否 3自定义 string ImageURI = 16; // 奖励图片 +} + +// etcd /game/room_config_system +message RoomConfigSystem{ + string Platform = 1; // 平台 + int32 Id = 2; // 配置id + int32 RoomConfigId = 3; // 房间配置id + int32 GameFreeId = 4; // 场次id + int32 Round = 5; // 局数 + int32 PlayerNum = 6; // 人数 + int32 NeedPassword = 7; // 是否需要密码 1是 2否 + int32 CostType = 8; // 消耗类型 1AA 2房主 + int32 Voice = 9; // 是否开启语音 1是 2否 + int32 State = 10; // 房间状态 1空 2满人(假人) + int32 FullTime = 11; // 房间状态为满人时房间保留多久,单位秒 + int32 AutoCreate = 12; // 自动创建开关 1开启 2关闭 + int32 AutoCreateTime = 13; // 自动创建时间间隔,单位秒 } \ No newline at end of file diff --git a/worldsrv/action_coinscene.go b/worldsrv/action_coinscene.go index 25282fb..02f866b 100644 --- a/worldsrv/action_coinscene.go +++ b/worldsrv/action_coinscene.go @@ -104,7 +104,7 @@ func (this *CSCoinSceneGetPlayerNumHandler) Process(s *netlib.Session, packetid // if len(params) != 0 && (p.GMLevel > 0 || dbGameFree.GetCreateRoomNum() != 0) { //允许GM|或者可选房间的游戏直接按房间ID进场 // s := SceneMgrSingleton.GetScene(int(params[0])) // if s != nil { -// if s.limitPlatform.IdStr == p.Platform || (s.groupId != 0 && s.groupId == gps.GroupId) { +// if s.platform.IdStr == p.Platform || (s.groupId != 0 && s.groupId == gps.GroupId) { // roomId = params[0] // } // } diff --git a/worldsrv/action_friend.go b/worldsrv/action_friend.go index d9861e7..b32e237 100644 --- a/worldsrv/action_friend.go +++ b/worldsrv/action_friend.go @@ -468,8 +468,8 @@ func (this *CSInviteFriendOpHandler) Process(s *netlib.Session, packetid int, da return nil } //进入房间 - if scene.limitPlatform != nil { - if scene.limitPlatform.Isolated && p.Platform != scene.limitPlatform.IdStr { + if scene.platform != nil { + if scene.platform.Isolated && p.Platform != scene.platform.IdStr { logger.Logger.Warn("CSInviteFriendHandler scene room not find") opRetCode = friend.OpResultCode_OPRC_InviteFriend_RoomNotExist //房间不存在 send(p) @@ -504,7 +504,7 @@ func (this *CSInviteFriendOpHandler) Process(s *netlib.Session, packetid int, da // 房费是否充足 if scene.IsCustom() { cfg := PlatformMgrSingleton.GetConfig(p.Platform).RoomConfig[scene.RoomConfigId] - if scene.CostType == 1 && !scene.sp.CostEnough(int(scene.CostType), scene.playerNum, cfg, p) { + if scene.CostType == 1 && !scene.sp.CostEnough(int(scene.CostType), scene.playerNum, cfg, p.SnId) { logger.Logger.Trace("CSInviteFriendHandler cost error") opRetCode = friend.OpResultCode_OPRC_InviteFriend_CostNotEnough send(p) @@ -519,7 +519,7 @@ func (this *CSInviteFriendOpHandler) Process(s *netlib.Session, packetid int, da send(p) return nil } - if reason := sp.CanEnter(scene, p); reason != 0 { + if reason := sp.CanEnter(scene, p.SnId); reason != 0 { logger.Logger.Trace("CSInviteFriendHandler CanEnter reason ", reason) opRetCode = friend.OpResultCode_OPRC_InviteFriend_GameNotCanEnter //游戏已开始 send(p) diff --git a/worldsrv/action_game.go b/worldsrv/action_game.go index 360feeb..4aa858c 100644 --- a/worldsrv/action_game.go +++ b/worldsrv/action_game.go @@ -73,15 +73,15 @@ func (this *CSEnterRoomHandler) Process(s *netlib.Session, packetid int, data in gameMode = scene.gameMode roomId = scene.sceneId if p.IsRob { - p.Platform = scene.limitPlatform.IdStr + p.Platform = scene.platform.IdStr } cfg = PlatformMgrSingleton.GetGameFree(p.Platform, scene.dbGameFree.Id) if cfg != nil && (cfg.GroupId != scene.groupId || cfg.GroupId == 0) { - if scene.limitPlatform != nil { - if scene.limitPlatform.Isolated && p.Platform != scene.limitPlatform.IdStr { + if scene.platform != nil { + if scene.platform.Isolated && p.Platform != scene.platform.IdStr { code = gamehall.OpResultCode_Game_OPRC_RoomNotExist_Game - logger.Logger.Tracef("CSEnterRoomHandler ScenePolicy(gameid:%v mode:%v) scene.limitPlatform.Isolated && p.Platform != scene.limitPlatform.Name", scene.gameId, scene.gameMode) + logger.Logger.Tracef("CSEnterRoomHandler ScenePolicy(gameid:%v mode:%v) scene.platform.Isolated && p.Platform != scene.platform.Name", scene.gameId, scene.gameMode) goto failed } } @@ -106,7 +106,7 @@ func (this *CSEnterRoomHandler) Process(s *netlib.Session, packetid int, data in // 房费是否充足 if scene.IsCustom() { cfg := PlatformMgrSingleton.GetConfig(p.Platform).RoomConfig[scene.RoomConfigId] - if scene.CostType == 1 && !scene.sp.CostEnough(int(scene.CostType), scene.playerNum, cfg, p) { + if scene.CostType == 1 && !scene.sp.CostEnough(int(scene.CostType), scene.playerNum, cfg, p.SnId) { code = gamehall.OpResultCode_Game_OPRC_CostNotEnough logger.Logger.Trace("CSEnterRoomHandler cost error") goto failed @@ -128,7 +128,7 @@ func (this *CSEnterRoomHandler) Process(s *netlib.Session, packetid int, data in } //检测房间状态是否开启 - if !scene.IsMatchScene() && !PlatformMgrSingleton.CheckGameState(scene.limitPlatform.IdStr, dbGameFree.Id) { + if !scene.IsMatchScene() && !PlatformMgrSingleton.CheckGameState(scene.platform.IdStr, dbGameFree.Id) { code = gamehall.OpResultCode_Game_OPRC_GameHadClosed logger.Logger.Tracef("CSEnterRoomHandler SnId:%v GameFreeId:%v GameHadClosed", p.SnId, dbGameFree.Id) goto failed @@ -141,7 +141,7 @@ func (this *CSEnterRoomHandler) Process(s *netlib.Session, packetid int, data in goto failed } - if reason := sp.CanEnter(scene, p); reason != 0 { + if reason := sp.CanEnter(scene, p.SnId); reason != 0 { code = gamehall.OpResultCode_Game(reason) logger.Logger.Trace("CSEnterRoomHandler sp.CanEnter(scene, p) reason ", reason) goto failed @@ -318,7 +318,7 @@ func (this *CSQueryRoomInfoHandler) ProcessLocalGame(s *netlib.Session, packetid isShow = true } } - if p.Platform == scene.limitPlatform.IdStr || isShow { + if p.Platform == scene.platform.IdStr || isShow { if scene.sceneMode == int(msg.GetSceneMode()) && len(scene.players) != 0 { if scene.gameId == int(gameid) && scene.dbGameFree.GetSceneType() == msg.GetGameSite() { @@ -519,7 +519,7 @@ func (this *CSEnterGameHandler) ProcessLocal(s *netlib.Session, packetid int, da if len(params) != 0 && (p.GMLevel > 0 || dbGameFree.GetCreateRoomNum() != 0) { //允许GM|或者可选房间的游戏直接按房间ID进场 s := SceneMgrSingleton.GetScene(int(params[0])) if s != nil { - if s.limitPlatform.IdStr == p.Platform || (gps.GroupId != 0 && s.groupId == gps.GroupId) { + if s.platform.IdStr == p.Platform || (gps.GroupId != 0 && s.groupId == gps.GroupId) { roomId = params[0] } } @@ -615,7 +615,7 @@ func (this *CSEnterGameHandler) ProcessNormal(s *netlib.Session, packetid int, d if len(params) != 0 && p.GMLevel > 0 { //允许GM直接按房间ID进场 s := SceneMgrSingleton.GetScene(int(params[0])) if s != nil { - if s.limitPlatform.IdStr == p.Platform || (s.groupId != 0 && s.groupId == gps.GroupId) { + if s.platform.IdStr == p.Platform || (s.groupId != 0 && s.groupId == gps.GroupId) { roomId = params[0] } } @@ -648,7 +648,7 @@ func (this *CSEnterGameHandler) ProcessNormal(s *netlib.Session, packetid int, d if len(params) != 0 && (p.GMLevel > 0 || dbGameFree.GetCreateRoomNum() != 0) { //允许GM|或者可选房间的游戏直接按房间ID进场 s := SceneMgrSingleton.GetScene(int(params[0])) if s != nil { - if s.limitPlatform.IdStr == p.Platform || (gps.GroupId != 0 && s.groupId == gps.GroupId) { + if s.platform.IdStr == p.Platform || (gps.GroupId != 0 && s.groupId == gps.GroupId) { roomId = params[0] } } @@ -1132,9 +1132,9 @@ func CSAudienceEnterRoomHandler(s *netlib.Session, packetId int, data interface{ } // 是不是相同平台 cfg = PlatformMgrSingleton.GetGameFree(p.Platform, scene.dbGameFree.Id) - if cfg == nil || (scene.limitPlatform != nil && scene.limitPlatform.Isolated && p.Platform != scene.limitPlatform.IdStr) { + if cfg == nil || (scene.platform != nil && scene.platform.Isolated && p.Platform != scene.platform.IdStr) { code = gamehall.OpResultCode_Game_OPRC_RoomNotExist_Game - logger.Logger.Tracef("CSEnterRoomHandler ScenePolicy(gameid:%v mode:%v) scene.limitPlatform.Isolated && p.Platform != scene.limitPlatform.Name", scene.gameId, scene.gameMode) + logger.Logger.Tracef("CSEnterRoomHandler ScenePolicy(gameid:%v mode:%v) scene.platform.Isolated && p.Platform != scene.platform.Name", scene.gameId, scene.gameMode) goto failed } // 游戏规则是否存在 @@ -1301,7 +1301,7 @@ func CSCreatePrivateRoomHandler(s *netlib.Session, packetId int, data interface{ } // 费用是否充足 - if len(cfg.GetCost()) > 0 && !sp.CostEnough(int(costType), int(msg.GetPlayerNum()), cfg, p) { + if len(cfg.GetCost()) > 0 && !sp.CostEnough(int(costType), int(msg.GetPlayerNum()), cfg, p.SnId) { code = gamehall.OpResultCode_Game_OPRC_CostNotEnough send() return nil @@ -1345,7 +1345,7 @@ func CSCreatePrivateRoomHandler(s *netlib.Session, packetId int, data interface{ } if costType == 2 { - sp.CostPayment(scene, p) + sp.CostPayment(scene, p.SnId) } code = gamehall.OpResultCode_Game_OPRC_Sucess_Game diff --git a/worldsrv/action_hundredscene.go b/worldsrv/action_hundredscene.go index d0befc0..611c5fb 100644 --- a/worldsrv/action_hundredscene.go +++ b/worldsrv/action_hundredscene.go @@ -101,7 +101,7 @@ func (this *CSHundredSceneOpHandler) Process(s *netlib.Session, packetid int, da if len(params) != 0 && p.GMLevel > 0 { //允许GM直接按房间ID进场 s := SceneMgrSingleton.GetScene(int(params[0])) if s != nil { - if s.limitPlatform.IdStr == p.Platform || (gps.GroupId != 0 && s.groupId == gps.GroupId) { + if s.platform.IdStr == p.Platform || (gps.GroupId != 0 && s.groupId == gps.GroupId) { roomId = params[0] } } diff --git a/worldsrv/action_server.go b/worldsrv/action_server.go index 597758a..acd1c1a 100644 --- a/worldsrv/action_server.go +++ b/worldsrv/action_server.go @@ -12,8 +12,6 @@ import ( "mongo.games.com/game/common" "mongo.games.com/game/model" - "mongo.games.com/game/proto" - gamehallproto "mongo.games.com/game/protocol/gamehall" loginproto "mongo.games.com/game/protocol/login" playerproto "mongo.games.com/game/protocol/player" serverproto "mongo.games.com/game/protocol/server" @@ -171,7 +169,7 @@ func init() { //if int(msg.GetReason()) == common.PlayerLeaveReason_Bekickout { // if len(scene.paramsEx) > 0 { // gameIdEx := scene.paramsEx[0] - // gps := PlatformMgrSingleton.GetGameFree(scene.limitPlatform.IdStr, scene.paramsEx[0]) + // gps := PlatformMgrSingleton.GetGameFree(scene.platform.IdStr, scene.paramsEx[0]) // if gps != nil { // lowLimit := gps.DbGameFree.GetLowerThanKick() // if lowLimit != 0 && p.Coin+p.SafeBoxCoin < int64(lowLimit) { @@ -526,39 +524,6 @@ func init() { return nil })) - //推送游戏的状态 - netlib.RegisterFactory(int(serverproto.SSPacketID_PACKET_GW_GAMESTATE), netlib.PacketFactoryWrapper(func() interface{} { - return &serverproto.GWGameState{} - })) - netlib.RegisterHandler(int(serverproto.SSPacketID_PACKET_GW_GAMESTATE), netlib.HandlerWrapper(func(s *netlib.Session, - packetid int, pack interface{}) error { - logger.Logger.Trace("receive SSPacketID_PACKET_GW_GAMESTATE GWGameState:", pack) - if msg, ok := pack.(*serverproto.GWGameState); ok { - scene := SceneMgrSingleton.GetScene(int(msg.GetSceneId())) - if scene != nil { - scene.State = msg.GetState() - scene.StateSec = msg.GetSec() - //scene.BankerListNum = msg.GetBankerListNum() - if scene.State == scene.sp.GetBetState() { - scene.StateTs = msg.GetTs() - leftTime := int64(scene.StateSec) - (time.Now().Unix() - scene.StateTs) - if leftTime < 0 { - leftTime = 0 - } - pack := &gamehallproto.SCGameState{} - pack.List = append(pack.List, &gamehallproto.GameState{ - GameFreeId: proto.Int32(scene.dbGameFree.GetId()), - Ts: proto.Int64(leftTime), - Sec: proto.Int32(scene.StateSec), - }) - gameStateMgr.BrodcastGameState( - int32(scene.gameId), scene.limitPlatform.IdStr, int(gamehallproto.GameHallPacketID_PACKET_SC_GAMESTATE), pack) - } - } - } - return nil - })) - netlib.RegisterFactory(int(serverproto.SSPacketID_PACKET_GW_JACKPOTLIST), netlib.PacketFactoryWrapper(func() interface{} { return &serverproto.GWGameJackList{} })) diff --git a/worldsrv/coinscenepool.go b/worldsrv/coinscenepool.go index ad71f43..9beabf2 100644 --- a/worldsrv/coinscenepool.go +++ b/worldsrv/coinscenepool.go @@ -340,7 +340,7 @@ func (csp *CoinScenePool) onPlayerLeave(s *Scene, p *Player) { if s.IsEmpty() { var hasCnt int for _, scene := range csp.scenes { - if s.limitPlatform.IdStr == scene.limitPlatform.IdStr { + if s.platform.IdStr == scene.platform.IdStr { hasCnt++ } } diff --git a/worldsrv/etcd.go b/worldsrv/etcd.go index b86e111..7c38728 100644 --- a/worldsrv/etcd.go +++ b/worldsrv/etcd.go @@ -521,6 +521,22 @@ func handlerEvent(ctx context.Context, completeKey string, isInit bool, event *c //PlayerMgrSington.BroadcastMessageToPlatform(plt, int(0), nil) } } + + case equalFunc(etcd.ETCDKEY_RoomConfigSystem): + switch event.Type { + case clientv3.EventTypePut: + if data == nil { + return + } + config := data.(*webapi.RoomConfigSystem) + PlatformMgrSingleton.GetConfig(config.GetPlatform()).RoomConfigSystem[config.GetId()] = config + case clientv3.EventTypeDelete: + if plt == "" || len(param) == 0 { + return + } + delete(PlatformMgrSingleton.GetConfig(plt).RoomConfigSystem, int32(param[0])) + } + default: logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey) } diff --git a/worldsrv/gamesess.go b/worldsrv/gamesess.go index 148b66c..b853d68 100644 --- a/worldsrv/gamesess.go +++ b/worldsrv/gamesess.go @@ -159,7 +159,7 @@ func (this *GameSession) AddScene(args *AddSceneParam) { this.scenes[args.S.sceneId] = args.S //send msg msg := &server_proto.WGCreateScene{ - Platform: args.S.limitPlatform.IdStr, + Platform: args.S.platform.IdStr, SceneId: int32(args.S.sceneId), GameId: int32(args.S.gameId), GameMode: int32(args.S.gameMode), @@ -175,7 +175,7 @@ func (this *GameSession) AddScene(args *AddSceneParam) { Params: args.S.params, } if args.S.GetRoomConfigId() != 0 { - cfg := PlatformMgrSingleton.GetConfig(args.S.limitPlatform.IdStr).RoomConfig[args.S.GetRoomConfigId()] + cfg := PlatformMgrSingleton.GetConfig(args.S.platform.IdStr).RoomConfig[args.S.GetRoomConfigId()] if cfg != nil { for _, v := range cfg.GetReward() { msg.Items = append(msg.Items, &server_proto.Item{ @@ -196,14 +196,14 @@ func (this *GameSession) AddScene(args *AddSceneParam) { } // 象棋游戏添加段位配置 if args.S.dbGameFree != nil && srvdata.GameFreeMgr.IsGameDif(int32(args.S.gameId), common.GameDifChess) { - msg.ChessRank = ChessRankMgrSington.GetChessRankArr(args.S.limitPlatform.Name, int32(args.S.gameId)) + msg.ChessRank = ChessRankMgrSington.GetChessRankArr(args.S.platform.Name, int32(args.S.gameId)) } this.Send(int(server_proto.SSPacketID_PACKET_WG_CREATESCENE), msg) logger.Logger.Tracef("WGCreateScene: %v", msg) // 初始化水池 - if args.S.limitPlatform != nil && args.S.dbGameFree != nil { - this.DetectCoinPoolSetting(args.S.limitPlatform.IdStr, args.S.dbGameFree.GetId(), args.S.groupId) + if args.S.platform != nil && args.S.dbGameFree != nil { + this.DetectCoinPoolSetting(args.S.platform.IdStr, args.S.dbGameFree.GetId(), args.S.groupId) } } diff --git a/worldsrv/internal/playercache.go b/worldsrv/internal/playercache.go index 53ac1cd..3713be3 100644 --- a/worldsrv/internal/playercache.go +++ b/worldsrv/internal/playercache.go @@ -74,12 +74,12 @@ func (b *BasePlayerLoader) Save(platform string, snid int32, isSync, force bool) func (b *BasePlayerLoader) Release(platform string, snid int32) { } -var playerLoads []PlayerLoader +var _playerLoads []PlayerLoader func RegisterPlayerLoad(i PlayerLoader) { - playerLoads = append(playerLoads, i) + _playerLoads = append(_playerLoads, i) } func GetPlayerLoads() []PlayerLoader { - return playerLoads + return _playerLoads } diff --git a/worldsrv/internal/playerlistener.go b/worldsrv/internal/playerlistener.go new file mode 100644 index 0000000..12b128d --- /dev/null +++ b/worldsrv/internal/playerlistener.go @@ -0,0 +1,158 @@ +package internal + +type Player any + +type Scene any + +var _playerListeners []PlayerListener + +func RegisterPlayerListener(l PlayerListener) { + for _, ll := range _playerListeners { + if ll == l { + return + } + } + _playerListeners = append(_playerListeners, l) +} + +type PlayerListener interface { + // 登出相关 + OnPlayerLogined(p Player) // 玩家登录时触发 + OnPlayerLogouted(p Player) // 玩家登出时触发 + OnPlayerDropLine(p Player) // 玩家掉线时触发 + OnPlayerRehold(p Player) // 玩家重新连接时触发 + + // 时间相关 + OnPlayerSecTimer(p Player) // 每秒触发 + OnPlayerMiniTimer(p Player) // 每分钟触发 + OnPlayerHourTimer(p Player) // 每小时触发 + OnPlayerDayTimer(p Player, login, continuous bool) // 每天触发,login表示是否登录,continuous表示是否连续登录 + OnPlayerWeekTimer(p Player) // 每周触发 + OnPlayerMonthTimer(p Player) // 每月触发 + + // 业务相关 + OnPlayerEnterScene(p Player, s Scene) // 玩家进入场景时触发 + OnPlayerLeaveScene(p Player, s Scene) // 玩家离开场景时触发 + OnPlayerReturnScene(p Player, s Scene) // 玩家返回房间时触发 +} + +func FirePlayerLogined(p Player) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerLogined(p) + } + } +} + +func FirePlayerLogouted(p Player) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerLogouted(p) + } + } +} + +func FirePlayerDropLine(p Player) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerDropLine(p) + } + } +} + +func FirePlayerRehold(p Player) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerRehold(p) + } + } +} + +func FirePlayerSecTimer(p Player) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerSecTimer(p) + } + } +} + +func FirePlayerMiniTimer(p Player) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerMiniTimer(p) + } + } +} + +func FirePlayerHourTimer(p Player) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerHourTimer(p) + } + } +} + +func FirePlayerDayTimer(p Player, login, continuous bool) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerDayTimer(p, login, continuous) + } + } +} + +func FirePlayerWeekTimer(p Player) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerWeekTimer(p) + } + } +} + +func FirePlayerMonthTimer(p Player) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerMonthTimer(p) + } + } +} + +func FirePlayerEnterScene(p Player, s Scene) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerEnterScene(p, s) + } + } +} + +func FirePlayerLeaveScene(p Player, s Scene) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerLeaveScene(p, s) + } + } +} + +func FirePlayerReturnScene(p Player, s Scene) { + for _, l := range _playerListeners { + if l != nil { + l.OnPlayerReturnScene(p, s) + } + } +} + +type BasePlayerListener struct { +} + +func (l *BasePlayerListener) OnPlayerLogined(p Player) {} +func (l *BasePlayerListener) OnPlayerLogouted(p Player) {} +func (l *BasePlayerListener) OnPlayerDropLine(p Player) {} +func (l *BasePlayerListener) OnPlayerRehold(p Player) {} +func (l *BasePlayerListener) OnPlayerSecTimer(p Player) {} +func (l *BasePlayerListener) OnPlayerMiniTimer(p Player) {} +func (l *BasePlayerListener) OnPlayerHourTimer(p Player) {} +func (l *BasePlayerListener) OnPlayerDayTimer(p Player, login, continuous bool) {} +func (l *BasePlayerListener) OnPlayerWeekTimer(p Player) {} +func (l *BasePlayerListener) OnPlayerMonthTimer(p Player) {} +func (l *BasePlayerListener) OnPlayerEnterScene(p Player, s Scene) {} +func (l *BasePlayerListener) OnPlayerLeaveScene(p Player, s Scene) {} +func (l *BasePlayerListener) OnPlayerReturnScene(p Player, s Scene) {} diff --git a/worldsrv/player.go b/worldsrv/player.go index 9c82ec2..81824f0 100644 --- a/worldsrv/player.go +++ b/worldsrv/player.go @@ -61,15 +61,6 @@ const ( UpdateField_InviteScore ) -const ( - CurrencyType_Card int32 = iota - CurrencyType_Coin - CurrencyType_Money - CurrencyType_RMB -) - -var VIP_RandWeight = []int64{30, 30, 20, 10, 5, 5} - type ErrorString struct { code string } @@ -327,9 +318,6 @@ func (this *Player) OnLogined() { gameStateMgr.PlayerClear(this) - //玩家登录事件 - FirePlayerLogined(this) - this.RandRobotExData() if !this.IsRob { @@ -423,9 +411,6 @@ func (this *Player) OnRehold() { gameStateMgr.PlayerClear(this) - //玩家重连事件 - FirePlayerRehold(this) - FriendMgrSington.ApplyList(this.Platform, this.SnId) FriendUnreadMgrSington.CheckSendFriendUnreadData(this.Platform, this.SnId) @@ -1337,9 +1322,6 @@ func (this *Player) DropLine() { //this.StatisticsOllen(this.PlayerData.LastLogoutTime) gameStateMgr.PlayerClear(this) - - //玩家掉线事件 - FirePlayerDropLine(this) } // 退出 @@ -1429,9 +1411,6 @@ func (this *Player) OnLogouted() { //离线玩家清空俱乐部信息 //delete(clubManager.theInClubId, this.SnId) - //玩家登出事件 - FirePlayerLogouted(this) - //登录日志 logState := LoginStateMgrSington.GetLoginStateBySid(this.sid) var clog *model.ClientLoginInfo @@ -1965,12 +1944,10 @@ func (this *Player) AddChessScore(num int64) { } func (this *Player) OnSecTimer() { - FirePlayerSecTimer(this) //BagMgrSingleton.AddMailByItem(this.Platform, this.SnId, this.Name, this.SnId, 1, []int32{60001, 12}) } func (this *Player) OnMiniTimer() { - FirePlayerMiniTimer(this) TaskSubjectSingleton.Touch(common.TaskTypeOnlineTs, &TaskData{ SnId: this.SnId, Num: 60, @@ -1978,7 +1955,6 @@ func (this *Player) OnMiniTimer() { } func (this *Player) OnHourTimer() { - FirePlayerHourTimer(this) } func (this *Player) OnDayTimer(login, continuous bool, t int) { @@ -1988,7 +1964,6 @@ func (this *Player) OnDayTimer(login, continuous bool, t int) { } this.lastOnDayChange = time.Now().Local() logger.Logger.Infof("(this *Player) (%v) OnDayTimer(%v,%v) ", this.SnId, login, continuous) - FirePlayerDayTimer(this, login, continuous) this.dirty = true if login || this.scene == nil { @@ -2105,7 +2080,6 @@ func (this *Player) OnMonthTimer() { return } this.lastOnMonthChange = time.Now().Local() - FirePlayerMonthTimer(this) } func (this *Player) OnWeekTimer() { @@ -2115,7 +2089,6 @@ func (this *Player) OnWeekTimer() { return } this.lastOnWeekChange = time.Now().Local() - FirePlayerWeekTimer(this) //清理比赛券 ticket := this.Ticket diff --git a/worldsrv/playerlistener.go b/worldsrv/playerlistener.go deleted file mode 100644 index 35e223e..0000000 --- a/worldsrv/playerlistener.go +++ /dev/null @@ -1,152 +0,0 @@ -package main - -var _playerListeners []PlayerListener - -func RegistePlayerListener(l PlayerListener) { - for _, ll := range _playerListeners { - if ll == l { - return - } - } - _playerListeners = append(_playerListeners, l) -} - -type PlayerListener interface { - //登录登出相关 - OnPlayerLogined(p *Player) - OnPlayerLogouted(p *Player) - OnPlayerDropLine(p *Player) - OnPlayerRehold(p *Player) - OnPlayerReturnScene(p *Player) //玩家返回房间 - //时间相关 - OnPlayerSecTimer(p *Player) - OnPlayerMiniTimer(p *Player) - OnPlayerHourTimer(p *Player) - OnPlayerDayTimer(p *Player, login, continuous bool) - OnPlayerWeekTimer(p *Player) - OnPlayerMonthTimer(p *Player) - //业务相关 - OnPlayerEnterScene(p *Player, s *Scene) - OnPlayerLeaveScene(p *Player, s *Scene) -} - -type BasePlayerListener struct { -} - -func (l *BasePlayerListener) OnPlayerLogined(p *Player) {} -func (l *BasePlayerListener) OnPlayerLogouted(p *Player) {} -func (l *BasePlayerListener) OnPlayerDropLine(p *Player) {} -func (l *BasePlayerListener) OnPlayerRehold(p *Player) {} -func (l *BasePlayerListener) OnPlayerReturnScene(p *Player) {} -func (l *BasePlayerListener) OnPlayerSecTimer(p *Player) {} -func (l *BasePlayerListener) OnPlayerMiniTimer(p *Player) {} -func (l *BasePlayerListener) OnPlayerHourTimer(p *Player) {} -func (l *BasePlayerListener) OnPlayerDayTimer(p *Player, login, continuous bool) {} -func (l *BasePlayerListener) OnPlayerWeekTimer(p *Player) {} -func (l *BasePlayerListener) OnPlayerMonthTimer(p *Player) {} -func (l *BasePlayerListener) OnPlayerEnterScene(p *Player, s *Scene) {} -func (l *BasePlayerListener) OnPlayerLeaveScene(p *Player, s *Scene) {} - -func FirePlayerLogined(p *Player) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerLogined(p) - } - } -} - -func FirePlayerLogouted(p *Player) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerLogouted(p) - } - } -} - -func FirePlayerDropLine(p *Player) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerDropLine(p) - } - } -} - -func FirePlayerRehold(p *Player) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerRehold(p) - } - } -} - -func FirePlayerReturnScene(p *Player) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerReturnScene(p) - } - } -} - -func FirePlayerSecTimer(p *Player) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerSecTimer(p) - } - } -} - -func FirePlayerMiniTimer(p *Player) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerMiniTimer(p) - } - } -} - -func FirePlayerHourTimer(p *Player) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerHourTimer(p) - } - } -} - -func FirePlayerDayTimer(p *Player, login, continuous bool) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerDayTimer(p, login, continuous) - } - } -} - -func FirePlayerWeekTimer(p *Player) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerWeekTimer(p) - } - } -} - -func FirePlayerMonthTimer(p *Player) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerMonthTimer(p) - } - } -} - -func FirePlayerEnterScene(p *Player, s *Scene) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerEnterScene(p, s) - } - } -} - -func FirePlayerLeaveScene(p *Player, s *Scene) { - for _, l := range _playerListeners { - if l != nil { - l.OnPlayerLeaveScene(p, s) - } - } -} diff --git a/worldsrv/playernotify.go b/worldsrv/playernotify.go index 961eb79..8ca06e8 100644 --- a/worldsrv/playernotify.go +++ b/worldsrv/playernotify.go @@ -89,7 +89,7 @@ func (p *PlayerNotify) SendToClient(tp common.NotifyType, packetId int, pack int return } roomConfigId := d.GetDatas()[0].GetRoomConfigId() - cfg := PlatformMgrSingleton.GetConfig(scene.limitPlatform.IdStr).RoomConfig[roomConfigId] + cfg := PlatformMgrSingleton.GetConfig(scene.platform.IdStr).RoomConfig[roomConfigId] if cfg == nil { return } diff --git a/worldsrv/scene.go b/worldsrv/scene.go index 6793dfb..d6b2955 100644 --- a/worldsrv/scene.go +++ b/worldsrv/scene.go @@ -40,7 +40,7 @@ type Scene struct { replayCode string // 回放码 currRound int32 // 当前第几轮 totalRound int32 // 总共几轮,小于等于0表示无限轮 - cycleTimes int32 // 循环次数 + cycleTimes int32 // 循环次数,未使用 deleting bool // 正在删除 starting bool // 正在开始 closed bool // 房间已关闭 @@ -53,7 +53,7 @@ type Scene struct { createTime time.Time // 创建时间 lastTime time.Time // 最后活跃时间 startTime time.Time // 游戏开始时间 - limitPlatform *Platform // 限制平台 + platform *Platform // 限制平台 groupId int32 // 组id dbGameFree *serverproto.DB_GameFree // 场次配置 gameCtx map[int32]*PlayerGameCtx // 进入房间的环境,没有机器人数据 SnId @@ -73,6 +73,7 @@ type Scene struct { func NewScene(args *CreateSceneParam) *Scene { gameId := int(args.GF.GetGameId()) gameMode := int(args.GF.GetGameMode()) + sp := GetScenePolicy(gameId, gameMode) if sp == nil { logger.Logger.Errorf("NewScene sp == nil, gameId=%v gameMode=%v", gameId, gameMode) @@ -80,29 +81,29 @@ func NewScene(args *CreateSceneParam) *Scene { } s := &Scene{ - sceneId: args.RoomId, - playerNum: int(args.PlayerNum), - creator: args.CreateId, - gameId: gameId, - gameMode: gameMode, - sceneMode: args.SceneMode, - params: args.Params, - cycleTimes: int32(args.CycleTimes), - players: make(map[int32]*Player), - audiences: make(map[int32]*Player), - gameSess: args.GS, - sp: sp, - createTime: time.Now(), - limitPlatform: args.Platform, - groupId: 0, - gameCtx: make(map[int32]*PlayerGameCtx), //进入房间的环境 - dbGameFree: args.GF, - currRound: 0, - totalRound: int32(args.TotalRound), - BaseScore: args.BaseScore, - Channel: args.Channel, - CustomParam: args.CustomParam, - MatchParam: args.MatchParam, + sceneId: args.RoomId, + playerNum: int(args.PlayerNum), + creator: args.CreateId, + gameId: gameId, + gameMode: gameMode, + sceneMode: args.SceneMode, + params: args.Params, + cycleTimes: int32(args.CycleTimes), + players: make(map[int32]*Player), + audiences: make(map[int32]*Player), + gameSess: args.GS, + sp: sp, + createTime: time.Now(), + platform: args.Platform, + groupId: 0, + gameCtx: make(map[int32]*PlayerGameCtx), //进入房间的环境 + dbGameFree: args.GF, + currRound: 0, + totalRound: int32(args.TotalRound), + BaseScore: args.BaseScore, + Channel: args.Channel, + CustomParam: args.CustomParam, + MatchParam: args.MatchParam, } // 最大房间人数 if s.playerNum <= 0 { @@ -144,20 +145,6 @@ func NewScene(args *CreateSceneParam) *Scene { return s } -func (this *Scene) RebindPlayerSnId(oldSnId, newSnId int32) { - if this.creator == oldSnId { - this.creator = newSnId - } - if p, exist := this.players[oldSnId]; exist { - delete(this.players, oldSnId) - this.players[newSnId] = p - } - if p, exist := this.audiences[oldSnId]; exist { - delete(this.audiences, oldSnId) - this.audiences[newSnId] = p - } -} - func (this *Scene) RobotIsLimit() bool { if this.robotLimit != 0 { if this.robotNum >= this.robotLimit { @@ -426,8 +413,7 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool { this.lastTime = time.Now() } this.gameSess.AddPlayer(p) - FirePlayerEnterScene(p, this) - this.sp.OnPlayerEnter(this, p) + this.sp.OnPlayerEnter(this, p.SnId) return true } @@ -553,8 +539,7 @@ func (this *Scene) DelPlayer(p *Player) bool { if !p.IsRob { this.lastTime = time.Now() } - FirePlayerLeaveScene(p, this) - this.sp.OnPlayerLeave(this, p) + this.sp.OnPlayerLeave(this, p.SnId) return true } @@ -690,6 +675,7 @@ func (this *Scene) OnClose() { for _, p := range this.audiences { this.DelPlayer(p) } + this.players = nil this.audiences = nil this.gameSess = nil @@ -786,7 +772,7 @@ func (this *Scene) GetSceneName() string { } func (this *Scene) IsPlatform(platform string) bool { - if platform == "0" || platform == this.limitPlatform.IdStr { + if platform == "0" || platform == this.platform.IdStr { return true } return false diff --git a/worldsrv/scene_minigame.go b/worldsrv/scene_minigame.go deleted file mode 100644 index 43052d2..0000000 --- a/worldsrv/scene_minigame.go +++ /dev/null @@ -1,125 +0,0 @@ -package main - -// -//import ( -// "math/rand" -// -// "mongo.games.com/game/common" -// "mongo.games.com/game/proto" -// "mongo.games.com/game/protocol/mngame" -// server_proto "mongo.games.com/game/protocol/server" -// "mongo.games.com/goserver/core/logger" -// "mongo.games.com/goserver/srvlib" -// srvlibproto "mongo.games.com/goserver/srvlib/protocol" -//) -// -//func (s *Scene) PlayerEnterMiniGame(p *Player) bool { -// s.players[p.SnId] = p -// s.gameSess.AddPlayer(p) -// takeCoin := p.Coin -// leaveCoin := int64(0) -// gameTimes := rand.Int31n(100) -// if p.IsRob { -// takerng := s.dbGameFree.GetRobotTakeCoin() -// if len(takerng) >= 2 && takerng[1] > takerng[0] { -// if takerng[0] < s.dbGameFree.GetLimitCoin() { -// takerng[0] = s.dbGameFree.GetLimitCoin() -// } -// takeCoin = int64(common.RandInt(int(takerng[0]), int(takerng[1]))) -// } else { -// maxlimit := int64(s.dbGameFree.GetMaxCoinLimit()) -// if maxlimit != 0 && p.Coin > maxlimit { -// logger.Logger.Trace("Player coin:", p.Coin) -// //在下限和上限之间随机,并对其的100的整数倍 -// takeCoin = int64(common.RandInt(int(s.dbGameFree.GetLimitCoin()), int(maxlimit))) -// logger.Logger.Trace("Take coin:", takeCoin) -// } -// } -// takeCoin = takeCoin / 100 * 100 -// //离场金币 -// leaverng := s.dbGameFree.GetRobotLimitCoin() -// if len(leaverng) >= 2 { -// leaveCoin = int64(leaverng[0] + rand.Int31n(leaverng[1]-leaverng[0])) -// } -// -// if takeCoin > p.Coin { -// takeCoin = p.Coin -// } -// } -// -// if p.IsRob { -// s.robotNum++ -// p.RobotRandName() -// p.RobRandVipWhenEnterRoom(takeCoin) -// name := s.GetSceneName() -// logger.Logger.Tracef("(this *Scene) PlayerEnter(%v) robot(%v) robotlimit(%v)", name, s.robotNum, s.robotLimit) -// } -// -// data, err := p.MarshalData(s.gameId) -// if err == nil { -// var gateSid int64 -// if p.gateSess != nil { -// if srvInfo, ok := p.gateSess.GetAttribute(srvlib.SessionAttributeServerInfo).(*srvlibproto.SSSrvRegiste); ok && srvInfo != nil { -// sessionId := srvlib.NewSessionIdEx(srvInfo.GetAreaId(), srvInfo.GetType(), srvInfo.GetId(), 0) -// gateSid = sessionId.Get() -// } -// } -// isQuMin := false -// //if !p.IsRob { -// // pt := PlatformMgrSingleton.GetPackageTag(p.PackageID) -// // if pt != nil && pt.SpreadTag == 1 { -// // isQuMin = true -// // } -// //} -// p.miniScene[s.dbGameFree.Id] = s -// msg := &server_proto.WGPlayerEnterMiniGame{ -// Sid: proto.Int64(p.sid), -// SnId: proto.Int32(p.SnId), -// GateSid: proto.Int64(gateSid), -// SceneId: proto.Int(s.sceneId), -// PlayerData: data, -// IsQM: proto.Bool(isQuMin), -// } -// sa, err2 := p.MarshalSingleAdjustData(s.dbGameFree.Id) -// if err2 == nil && sa != nil { -// msg.SingleAdjust = sa -// } -// msg.TakeCoin = proto.Int64(takeCoin) -// msg.ExpectLeaveCoin = proto.Int64(leaveCoin) -// msg.ExpectGameTimes = proto.Int32(gameTimes) -// proto.SetDefaults(msg) -// s.SendToGame(int(server_proto.SSPacketID_PACKET_WG_PLAYERENTER_MINIGAME), msg) -// } -// return true -//} -// -//func (s *Scene) PlayerLeaveMiniGame(p *Player) bool { -// var gateSid int64 -// if p.gateSess != nil { -// if srvInfo, ok := p.gateSess.GetAttribute(srvlib.SessionAttributeServerInfo).(*srvlibproto.SSSrvRegiste); ok && srvInfo != nil { -// sessionId := srvlib.NewSessionIdEx(srvInfo.GetAreaId(), srvInfo.GetType(), srvInfo.GetId(), 0) -// gateSid = sessionId.Get() -// } -// } -// -// delete(p.miniScene, s.dbGameFree.Id) -// -// msg := &server_proto.WGPlayerLeaveMiniGame{ -// Sid: proto.Int64(p.sid), -// SnId: proto.Int32(p.SnId), -// GateSid: proto.Int64(gateSid), -// SceneId: proto.Int(s.sceneId), -// } -// proto.SetDefaults(msg) -// s.SendToGame(int(server_proto.SSPacketID_PACKET_WG_PLAYERLEAVE_MINIGAME), msg) -// -// delete(s.players, p.SnId) -// return true -//} -// -//func (s *Scene) RedirectMiniGameMsg(p *Player, msg *mngame.CSMNGameDispatcher) bool { -// msg.Id = int32(s.sceneId) //换成真实房间id -// msg.SnId = p.SnId -// s.SendToGame(int(mngame.MNGamePacketID_PACKET_CS_MNGAME_DISPATCHER), msg) -// return true -//} diff --git a/worldsrv/scenemgr.go b/worldsrv/scenemgr.go index dc72570..894b918 100644 --- a/worldsrv/scenemgr.go +++ b/worldsrv/scenemgr.go @@ -95,8 +95,8 @@ func (m *SceneMgr) GenPassword() string { func (m *SceneMgr) GetPlatformBySceneId(sceneId int) string { s := m.GetScene(sceneId) - if s != nil && s.limitPlatform != nil { - return s.limitPlatform.IdStr + if s != nil && s.platform != nil { + return s.platform.IdStr } return "" } @@ -172,7 +172,7 @@ func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode } } for _, s := range m.scenes { - if (((s.limitPlatform != nil && s.limitPlatform.IdStr == platform) || platform == "") && + if (((s.platform != nil && s.platform.IdStr == platform) || platform == "") && ((s.gameId == gameId && s.gameMode == gameMode) || gameId == 0) && (s.sceneId == sceneId || sceneId == 0) && (s.groupId == int32(groupId) || groupId == 0) && (s.dbGameFree.GetId() == gameFreeId || gameFreeId == 0) && @@ -180,8 +180,8 @@ func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode ((s.IsCustom() && isCustom) || !isCustom) && (s.GetRoomConfigId() == roomConfigId || roomConfigId == 0)) || isNeedFindAll { var platformName string - if s.limitPlatform != nil { - platformName = s.limitPlatform.IdStr + if s.platform != nil { + platformName = s.platform.IdStr } si := &webapiproto.RoomInfo{ @@ -305,7 +305,7 @@ type FindRoomParam struct { func (m *SceneMgr) FindRoomList(args *FindRoomParam) []*Scene { ret := make([]*Scene, 0) for _, v := range m.scenes { - if args.Platform != "" && v.limitPlatform.IdStr != args.Platform { + if args.Platform != "" && v.platform.IdStr != args.Platform { continue } if len(args.GameId) > 0 { diff --git a/worldsrv/scenepolicy.go b/worldsrv/scenepolicy.go index 38d7630..a8ae4d5 100644 --- a/worldsrv/scenepolicy.go +++ b/worldsrv/scenepolicy.go @@ -5,41 +5,50 @@ import "mongo.games.com/game/protocol/webapi" // ScenePolicyPool 根据不同的房间模式,选择不同的房间业务策略 var ScenePolicyPool = make(map[int]map[int]ScenePolicy) -type ScenePolicy interface { - // OnStart 场景开启事件 - OnStart(s *Scene) - // OnStop 场景关闭事件 - OnStop(s *Scene) - // OnTick 场景心跳事件 - OnTick(s *Scene) - // OnPlayerEnter 玩家进入事件 - OnPlayerEnter(s *Scene, p *Player) - // OnPlayerLeave 玩家离开事件 - OnPlayerLeave(s *Scene, p *Player) - // OnShutdown 系统维护关闭事件 - OnShutdown(s *Scene) - // OnSceneState 房间状态变更 - OnSceneState(s *Scene, state int) - // OnGameState 游戏状态变更 - OnGameState(s *Scene, state int) - - // CanEnter 能否进入 - CanEnter(s *Scene, p *Player) int - // GetBetState 获取下注状态 - GetBetState() int32 +type ScenePolicyConfig interface { // GetPlayerNum 获取玩家数量 GetPlayerNum() int // GetBaseScore 获取底分 GetBaseScore() int +} + +type ScenePolicy interface { + ScenePolicyConfig + // OnStart 场景开启事件 + // 游戏开始前 + OnStart(s *Scene) + + // OnStop 场景关闭事件 + // 房间关闭前 + OnStop(s *Scene) + + // OnTick 场景心跳事件 + OnTick(s *Scene) + + // OnPlayerEnter 玩家进入事件 + // 玩家进入后 + OnPlayerEnter(s *Scene, snid int32) + + // OnPlayerLeave 玩家离开事件 + // 玩家离开后 + OnPlayerLeave(s *Scene, snid int32) + + // OnSceneState 房间状态变更 + OnSceneState(s *Scene, state int) + + // CanEnter 能否进入 + CanEnter(s *Scene, snid int32) int // CostEnough 房费是否足够 // costType 付费方式 // playerNum 玩家数量 // roomConfig 房间配置 - CostEnough(costType, playerNum int, roomConfig *webapi.RoomConfig, p *Player) bool + CostEnough(costType, playerNum int, roomConfig *webapi.RoomConfig, snid int32) bool // CostPayment 房费支付 - CostPayment(s *Scene, p *Player) bool + CostPayment(s *Scene, snid int32) bool + // GiveCostPayment 房费返还 + GiveCostPayment(s *Scene, snid int32) bool } func GetScenePolicy(gameId, mode int) ScenePolicy { diff --git a/worldsrv/scenepolicydata.go b/worldsrv/scenepolicydata.go index 3507d61..949bc78 100644 --- a/worldsrv/scenepolicydata.go +++ b/worldsrv/scenepolicydata.go @@ -2,6 +2,7 @@ package main import ( "math" + "mongo.games.com/goserver/core/logger" "mongo.games.com/game/common" @@ -24,39 +25,38 @@ func (spd *ScenePolicyData) Init() bool { return true } +func (spd *ScenePolicyData) GetPlayerNum() int { + return int(spd.DefaultPlayerCnt) +} + +func (spd *ScenePolicyData) GetBaseScore() int { + return int(spd.BaseScore) +} + func (spd *ScenePolicyData) OnStart(s *Scene) { s.NotifyPrivateRoom(common.ListAdd) } -// 场景关闭事件 func (spd *ScenePolicyData) OnStop(s *Scene) { s.NotifyPrivateRoom(common.ListDel) // 房主付费,房间没有玩就解散了,返还房主建房费用 if s.IsCustom() && s.GetCostType() == 2 && s.currRound == 0 { - spd.GiveCostPayment(s, s.creator) + s.sp.GiveCostPayment(s, s.creator) } } -// 场景心跳事件 func (spd *ScenePolicyData) OnTick(s *Scene) { } -// 玩家进入事件 -func (spd *ScenePolicyData) OnPlayerEnter(s *Scene, p *Player) { +func (spd *ScenePolicyData) OnPlayerEnter(s *Scene, snid int32) { s.NotifyPrivateRoom(common.ListModify) } -// 玩家离开事件 -func (spd *ScenePolicyData) OnPlayerLeave(s *Scene, p *Player) { +func (spd *ScenePolicyData) OnPlayerLeave(s *Scene, snid int32) { s.NotifyPrivateRoom(common.ListModify) } -// 系统维护关闭事件 -func (spd *ScenePolicyData) OnShutdown(s *Scene) { - -} - func (spd *ScenePolicyData) OnSceneState(s *Scene, state int) { s.SceneState = int32(state) switch state { @@ -68,23 +68,17 @@ func (spd *ScenePolicyData) OnSceneState(s *Scene, state int) { if s.IsCustom() { if s.GetCostType() == 1 { for _, v := range s.players { - spd.CostPayment(s, v) + spd.CostPayment(s, v.SnId) } } } case common.SceneStateEnd: s.NotifyPrivateRoom(common.ListModify) - } } -func (spd *ScenePolicyData) OnGameState(s *Scene, state int) { - -} - -// 能否进入 -func (spd *ScenePolicyData) CanEnter(s *Scene, p *Player) int { +func (spd *ScenePolicyData) CanEnter(s *Scene, snid int32) int { if !spd.EnterAfterStart { if s.starting { return int(hallproto.OpResultCode_Game_OPRC_GameStarting_Game) @@ -130,14 +124,18 @@ func (spd *ScenePolicyData) costEnough(costType, playerNum int, roomConfig *weba return isEnough } -func (spd *ScenePolicyData) CostEnough(costType, playerNum int, roomConfig *webapi.RoomConfig, p *Player) bool { +func (spd *ScenePolicyData) CostEnough(costType, playerNum int, roomConfig *webapi.RoomConfig, snid int32) bool { if roomConfig == nil { return false } - return spd.costEnough(costType, playerNum, roomConfig, p.SnId, func(items []*model.Item) {}) + return spd.costEnough(costType, playerNum, roomConfig, snid, func(items []*model.Item) {}) } -func (spd *ScenePolicyData) CostPayment(s *Scene, p *Player) bool { +func (spd *ScenePolicyData) CostPayment(s *Scene, snid int32) bool { + p := PlayerMgrSington.GetPlayerBySnId(snid) + if p == nil { + return false + } roomConfig := PlatformMgrSingleton.GetConfig(p.Platform).RoomConfig[s.GetRoomConfigId()] if roomConfig == nil { return false @@ -160,9 +158,8 @@ func (spd *ScenePolicyData) CostPayment(s *Scene, p *Player) bool { }) } -// GiveCostPayment 退房费 func (spd *ScenePolicyData) GiveCostPayment(s *Scene, snid int32) bool { - roomConfig := PlatformMgrSingleton.GetConfig(s.limitPlatform.IdStr).RoomConfig[s.GetRoomConfigId()] + roomConfig := PlatformMgrSingleton.GetConfig(s.platform.IdStr).RoomConfig[s.GetRoomConfigId()] if roomConfig == nil { return false } @@ -194,7 +191,7 @@ func (spd *ScenePolicyData) GiveCostPayment(s *Scene, snid int32) bool { }) } else { BagMgrSingleton.AddItemsOffline(&model.AddItemParam{ - Platform: s.limitPlatform.IdStr, + Platform: s.platform.IdStr, SnId: snid, Change: items, GainWay: common.GainWayRoomCost, @@ -209,15 +206,3 @@ func (spd *ScenePolicyData) GiveCostPayment(s *Scene, snid int32) bool { } return false } - -func (spd *ScenePolicyData) GetBetState() int32 { - return spd.BetState -} - -func (spd *ScenePolicyData) GetPlayerNum() int { - return int(spd.DefaultPlayerCnt) -} - -func (spd *ScenePolicyData) GetBaseScore() int { - return int(spd.BaseScore) -} diff --git a/worldsrv/trascate_webapi.go b/worldsrv/trascate_webapi.go index 832db5c..b5e766c 100644 --- a/worldsrv/trascate_webapi.go +++ b/worldsrv/trascate_webapi.go @@ -1640,7 +1640,7 @@ func init() { gameFreeId = s.dbGameFree.GetId() } si := &webapiproto.RoomInfo{ - Platform: s.limitPlatform.Name, + Platform: s.platform.Name, SceneId: int32(s.sceneId), GameId: int32(s.gameId), GameMode: int32(s.gameMode),