20260112
This commit is contained in:
parent
fb24ab09a5
commit
222dbaae19
@ -37,6 +37,7 @@ type LiveRoomInterface interface {
|
||||
GetReadyPlayerInfoList(uid uint64) []*serverproto.LiveRoomPlayerInfo
|
||||
SendChat(senderId uint64, chatContent string)
|
||||
ShowSubmit(uid uint64, data []*serverproto.KeyValueType64) []*serverproto.KeyValueType64
|
||||
RoomState() string
|
||||
}
|
||||
|
||||
// 被子类重载函数
|
||||
@ -85,6 +86,7 @@ type LiveRoom struct {
|
||||
readyTimeline map[int32]*TimelineFrame
|
||||
showTimeline map[int32]*TimelineFrame
|
||||
resultTimeline map[int32]*TimelineFrame
|
||||
roomStateData map[string]string
|
||||
heart int64
|
||||
|
||||
submitDataList []*LiveRoomSubmitData
|
||||
@ -103,6 +105,7 @@ type LiveRoom struct {
|
||||
VF_CheckIfShowEnd func() bool
|
||||
VF_ShowEnd func()
|
||||
VF_HandlePlayCMD func(cfg *serverproto.LiveRoomTalkCfg)
|
||||
VF_GetRoomState func() string
|
||||
}
|
||||
|
||||
func newLiveRoom(roomId uint32, roomType uint32, tickInterval uint32) LiveRoom {
|
||||
@ -122,6 +125,7 @@ func newLiveRoom(roomId uint32, roomType uint32, tickInterval uint32) LiveRoom {
|
||||
giftRank: make([]*serverproto.LiveRoomPlayerInfo, 0),
|
||||
giftRecords: make([]*serverproto.LiveRoomPlayerInfo, 0),
|
||||
chatRecords: make([]*serverproto.LiveRoomChatData, 0),
|
||||
roomStateData: make(map[string]string),
|
||||
}
|
||||
liveRoom.BaseSetVF()
|
||||
liveRoom.BaseInit()
|
||||
@ -142,6 +146,7 @@ func (self *LiveRoom) BaseSetVF() {
|
||||
self.VF_CheckIfShowEnd = self.CheckIfShowEnd
|
||||
self.VF_ShowEnd = self.ShowEnd
|
||||
self.VF_HandlePlayCMD = self.HandlePlayCMD
|
||||
self.VF_GetRoomState = self.GetRoomState
|
||||
}
|
||||
|
||||
/*----------------------------------- 重载函数 -----------------------------------*/
|
||||
@ -186,6 +191,9 @@ func (self *LiveRoom) CheckIfShowEnd() bool {
|
||||
func (self *LiveRoom) ShowEnd() {}
|
||||
|
||||
func (self *LiveRoom) HandlePlayCMD(cfg *serverproto.LiveRoomTalkCfg) {}
|
||||
func (self *LiveRoom) GetRoomState() string {
|
||||
return MapToString(self.roomStateData)
|
||||
}
|
||||
|
||||
/*----------------------------------- 内部函数 -----------------------------------*/
|
||||
func (self *LiveRoom) BaseInit() {
|
||||
@ -334,6 +342,7 @@ func (self *LiveRoom) LIVEROOM_STAGE_IDLE_Enter() {
|
||||
util.InfoF("LIVEROOM_STAGE_IDLE_Enter")
|
||||
self.readyUidList = make([]uint64, 0)
|
||||
self.submitDataList = make([]*LiveRoomSubmitData, 0)
|
||||
self.roomStateData = make(map[string]string)
|
||||
self.sumGiftPoint = 0
|
||||
}
|
||||
|
||||
@ -595,6 +604,10 @@ func (self *LiveRoom) HasPlayer(uid uint64) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *LiveRoom) RoomState() string {
|
||||
return self.VF_GetRoomState()
|
||||
}
|
||||
|
||||
func (self *LiveRoom) IsFree(uid uint64) bool {
|
||||
if len(self.uidList) > LIVEROOM_MAX_PLAYER_NUM {
|
||||
return false
|
||||
|
||||
@ -42,9 +42,10 @@ func (self *LiveSellRoom) SetVF() {
|
||||
self.VF_HandlePlayCMD = self.HandlePlayCMD
|
||||
}
|
||||
|
||||
func (self *LiveSellRoom) ShowStart() {
|
||||
func (self *LiveSellRoom) ReadyStart() {
|
||||
liveRoomSellCfg := serverproto.LiveRoomSellCfgLoader
|
||||
self.currSellIds = RandomKeys(liveRoomSellCfg, 1)
|
||||
self.roomStateData["sellId"] = string(self.currSellIds[0])
|
||||
self.currSellInfos = make([]*SellInfo, 0)
|
||||
for _, sellId := range self.currSellIds {
|
||||
self.currSellInfos = append(self.currSellInfos, &SellInfo{
|
||||
@ -55,6 +56,10 @@ func (self *LiveSellRoom) ShowStart() {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *LiveSellRoom) ShowStart() {
|
||||
|
||||
}
|
||||
|
||||
// 结算阶段:给玩家背包里添加东西
|
||||
func (self *LiveSellRoom) ShowEnd() {
|
||||
for _, v := range self.currSellInfos {
|
||||
@ -147,7 +152,7 @@ func (self *LiveSellRoom) HandleShowSubmit(uid uint64, data []*serverproto.KeyVa
|
||||
func (self *LiveSellRoom) GetStageEnterParams(stage uint32) string {
|
||||
stageEnterParams := ""
|
||||
switch stage {
|
||||
case LIVEROOM_STAGE_SHOW:
|
||||
case LIVEROOM_STAGE_READY:
|
||||
stageEnterParams = JoinSlice(self.currSellIds, ":")
|
||||
}
|
||||
return stageEnterParams
|
||||
|
||||
@ -285,3 +285,30 @@ func RollForRateCfg(str string) (int, error) {
|
||||
items, _ := parseProbabilityStr(str)
|
||||
return selectByProbability(items)
|
||||
}
|
||||
|
||||
func MapToString(m map[string]string) string {
|
||||
if len(m) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
var builder strings.Builder
|
||||
|
||||
// 有序输出(按key排序)
|
||||
keys := make([]string, 0, len(m))
|
||||
for k := range m {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
// 排序(可选)
|
||||
//sort.Strings(keys)
|
||||
|
||||
for i, k := range keys {
|
||||
builder.WriteString(k)
|
||||
builder.WriteString(":")
|
||||
builder.WriteString(m[k])
|
||||
if i < len(keys)-1 {
|
||||
builder.WriteString(";")
|
||||
}
|
||||
}
|
||||
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@ -179,6 +179,7 @@ func init() {
|
||||
IsReady: liveRoom.IsReady(msg.Uid),
|
||||
GiftRecords: liveRoom.GiftRecords(),
|
||||
ChatDatas: liveRoom.ChatRecords(),
|
||||
RoomState: liveRoom.RoomState(),
|
||||
ReadyPlayerInfoList: liveRoom.GetReadyPlayerInfoList(msg.Uid),
|
||||
}
|
||||
model.ServiceReplay(ev, ackMsg)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -3893,9 +3893,10 @@ message SCLiveRoomJoinAck { //project game|fruit //RouteRule game
|
||||
uint32 stage_timer_sec = 7;
|
||||
uint32 stage_sec = 8;
|
||||
bool is_ready = 9;
|
||||
repeated LiveRoomPlayerInfo gift_records = 10;
|
||||
repeated LiveRoomChatData chat_datas = 11;
|
||||
repeated LiveRoomPlayerInfo ready_player_info_list = 12;
|
||||
string room_state = 10;
|
||||
repeated LiveRoomPlayerInfo gift_records = 11;
|
||||
repeated LiveRoomChatData chat_datas = 12;
|
||||
repeated LiveRoomPlayerInfo ready_player_info_list = 13;
|
||||
}
|
||||
message CSLiveRoomLeaveReq { //project game|fruit //RouteRule game
|
||||
uint64 uid = 1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user