增加拍卖直播房间
This commit is contained in:
parent
20bf0f001e
commit
bbaa30849b
11
server/.idea/workspace.xml
generated
11
server/.idea/workspace.xml
generated
@ -9,16 +9,17 @@
|
||||
<change beforePath="$PROJECT_DIR$/../doc/etcd-v3.5.17-windows-amd64/default.etcd/member/wal/0.tmp" beforeDir="false" afterPath="$PROJECT_DIR$/../doc/etcd-v3.5.17-windows-amd64/default.etcd/member/wal/0.tmp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../doc/etcd-v3.5.17-windows-amd64/default.etcd/member/wal/0000000000000000-0000000000000000.wal" beforeDir="false" afterPath="$PROJECT_DIR$/../doc/etcd-v3.5.17-windows-amd64/default.etcd/member/wal/0000000000000000-0000000000000000.wal" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/config/csv/LiveRoomCfg.csv" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/config/csv/LiveRoomCfg.csv" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/config/csv/LiveRoomTalkCfg.csv" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/config/csv/LiveRoomTalkCfg.csv" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/config/csv/LiveRoomSellCfg.csv" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/config/csv/LiveRoomSellCfg.csv" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/fruit/model/live_answer_room.go" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/fruit/model/live_answer_room.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/fruit/model/live_card_room.go" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/fruit/model/live_card_room.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/fruit/model/live_game_room.go" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/fruit/model/live_game_room.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/fruit/model/live_room.go" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/fruit/model/live_room.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/fruit/model/live_sell_room.go" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/fruit/model/live_sell_room.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/fruit/model/room_def.go" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/fruit/model/room_def.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/fruit/msg/room_msg.go" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/fruit/msg/room_msg.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/fruit/model/room_manager.go" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/fruit/model/room_manager.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/serverproto/config_csv.go" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/serverproto/config_csv.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/serverproto/login.pb.go" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/serverproto/login.pb.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/serverproto/login.proto" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/serverproto/login.proto" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/serverproto/user.pb.go" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/serverproto/user.pb.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/roserver/serverproto/user.proto" beforeDir="false" afterPath="$PROJECT_DIR$/roserver/serverproto/user.proto" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../server_publish/run/linux/auth" beforeDir="false" afterPath="$PROJECT_DIR$/../server_publish/run/linux/auth" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../server_publish/run/linux/battleboss" beforeDir="false" afterPath="$PROJECT_DIR$/../server_publish/run/linux/battleboss" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../server_publish/run/linux/battlerecord" beforeDir="false" afterPath="$PROJECT_DIR$/../server_publish/run/linux/battlerecord" afterDir="false" />
|
||||
|
||||
7
server/roserver/config/csv/LiveRoomBidCfg.csv
Normal file
7
server/roserver/config/csv/LiveRoomBidCfg.csv
Normal file
@ -0,0 +1,7 @@
|
||||
序号,名字,描述,图标,原价,秒杀价格,包含物品(物品ID:数量;物品ID:数量)
|
||||
Id,Name,Desp,Icon,Price,AddPrice,Items
|
||||
int,string,string,string,string,int,list
|
||||
1,拍卖1,拍卖1描述,,2:100,20,126:1;127:1;128:1;130:1
|
||||
2,拍卖2,拍卖2描述,,2:100,20,126:1;127:1;128:1;130:1
|
||||
3,拍卖3,拍卖3描述,,2:100,20,126:1;127:1;128:1;130:1
|
||||
4,拍卖4,拍卖4描述,,2:100,20,126:1;127:1;128:1;130:1
|
||||
|
@ -1,7 +1,7 @@
|
||||
序号,描述,售卖数量,图标,原价,秒杀价格,包含物品(物品ID:数量;物品ID:数量)
|
||||
Id,Desp,SellNum,Icon,Price,CutPrice,Items
|
||||
int,string,int,string,string,string,list
|
||||
1,秒杀1,1,,2:100,2:80,126:1
|
||||
2,秒杀2,1,,2:100,2:80,127:1
|
||||
3,秒杀3,1,,2:100,2:80,128:1
|
||||
4,秒杀4,1,,2:100,2:80,130:1
|
||||
序号,名字,描述,售卖数量,图标,原价,秒杀价格,包含物品(物品ID:数量;物品ID:数量)
|
||||
Id,Name,Desp,SellNum,Icon,Price,CutPrice,Items
|
||||
int,string,string,int,string,string,string,list
|
||||
1,秒杀1,秒杀1描述,1,,2:100,2:80,126:1
|
||||
2,秒杀2,秒杀2描述,1,,2:100,2:80,127:1
|
||||
3,秒杀3,秒杀3描述,1,,2:100,2:80,128:1
|
||||
4,秒杀4,秒杀4描述,1,,2:100,2:80,130:1
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
model2 "roserver/baseserver/model"
|
||||
gameModel "roserver/game/model"
|
||||
"roserver/serverproto"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type LiveAnswerRoom struct {
|
||||
@ -88,7 +89,7 @@ func (self *LiveAnswerRoom) ShowEnd() {
|
||||
}
|
||||
|
||||
// Play命令:用于给客户端发送命令,显示题目,这里返回客户端显示题目相关数据
|
||||
func (self *LiveAnswerRoom) GetPlayDataList(readyUidList []uint64, uid uint64, cfg *serverproto.LiveRoomTalkCfg) []*serverproto.KeyValueType64Str {
|
||||
func (self *LiveAnswerRoom) GetCMDPlayDataList(readyUidList []uint64, uid uint64, cfg *serverproto.LiveRoomTalkCfg) []*serverproto.KeyValueType64 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -128,13 +129,13 @@ func (self *LiveAnswerRoom) GetShowResultList(readyUidList []uint64, uid uint64)
|
||||
}
|
||||
|
||||
// 返回玩家玩游戏得到的奖励
|
||||
func (self *LiveAnswerRoom) GetShowRewardList(readyUidList []uint64, uid uint64) []*serverproto.KeyValueType64Str {
|
||||
rewardList := make([]*serverproto.KeyValueType64Str, 0)
|
||||
func (self *LiveAnswerRoom) GetShowRewardList(readyUidList []uint64, uid uint64) []*serverproto.KeyValueType64 {
|
||||
rewardList := make([]*serverproto.KeyValueType64, 0)
|
||||
if userAnswerInfo, exist := self.userAnswers[uid]; exist {
|
||||
for _, v := range userAnswerInfo.rewardItems {
|
||||
rewardList = append(rewardList, &serverproto.KeyValueType64Str{
|
||||
Key: uint64(v.Key),
|
||||
StrVal: string(v.Value),
|
||||
rewardList = append(rewardList, &serverproto.KeyValueType64{
|
||||
Key: uint64(v.Key),
|
||||
Value: v.Value,
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -163,8 +164,9 @@ func (self *LiveAnswerRoom) HandleShowSubmit(uid uint64, data []*serverproto.Key
|
||||
}
|
||||
for _, v := range data {
|
||||
questionId := v.Key
|
||||
answer := v.Value
|
||||
self.userAnswers[uid].answers[questionId] = answer
|
||||
answerStr := v.StrVal
|
||||
answer, _ := strconv.Atoi(answerStr)
|
||||
self.userAnswers[uid].answers[questionId] = int32(answer)
|
||||
}
|
||||
return submitResult
|
||||
}
|
||||
|
||||
123
server/roserver/fruit/model/live_bid_room.go
Normal file
123
server/roserver/fruit/model/live_bid_room.go
Normal file
@ -0,0 +1,123 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"roserver/serverproto"
|
||||
)
|
||||
|
||||
type LiveBidRoom struct {
|
||||
LiveRoom
|
||||
currBidCfg *serverproto.LiveRoomBidCfg
|
||||
currBidInfo *BidInfo
|
||||
}
|
||||
|
||||
type BidInfo struct {
|
||||
uid uint64
|
||||
bidPrice uint32
|
||||
}
|
||||
|
||||
func newLiveBidRoom(roomId uint32, tickInterval uint32) *LiveBidRoom {
|
||||
room := &LiveBidRoom{
|
||||
LiveRoom: newLiveRoom(roomId, LIVEROOM_TYPE_BID, tickInterval),
|
||||
}
|
||||
return room
|
||||
}
|
||||
|
||||
func (self *LiveBidRoom) ReadyStart() {
|
||||
liveRoomBidCfg := serverproto.LiveRoomBidCfgLoader
|
||||
bidIds := RandomKeys(liveRoomBidCfg, 1)
|
||||
self.currBidCfg = liveRoomBidCfg[bidIds[0]]
|
||||
}
|
||||
|
||||
func (self *LiveBidRoom) ShowStart() {
|
||||
|
||||
}
|
||||
|
||||
func (self *LiveBidRoom) CheckIfShowEnd() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// 结算阶段:给玩家背包里添加东西
|
||||
func (self *LiveBidRoom) ShowEnd() {
|
||||
}
|
||||
|
||||
func (self *LiveBidRoom) GetMaxReadyNum(roomType uint32) int {
|
||||
return LIVEROOM_BID_MAX_READY_NUM
|
||||
}
|
||||
|
||||
func (self *LiveBidRoom) HandlePlayCMD(cfg *serverproto.LiveRoomTalkCfg) {}
|
||||
|
||||
// 返回客户端显示拍卖的商品信息
|
||||
func (self *LiveBidRoom) GetCMDPlayDataList(readyUidList []uint64, uid uint64, cfg *serverproto.LiveRoomTalkCfg) []*serverproto.KeyValueType64 {
|
||||
dataList := make([]*serverproto.KeyValueType64, 0)
|
||||
if len(cfg.Params1) > 0 {
|
||||
playParam := cfg.Params1[0]
|
||||
switch playParam {
|
||||
case LIVEROOM_CMD_PLAY_PARAM_BidPreview:
|
||||
dataList = append(dataList, &serverproto.KeyValueType64{
|
||||
Key: uint64(self.currBidCfg.Id),
|
||||
StrVal: "",
|
||||
})
|
||||
case LIVEROOM_CMD_PLAY_PARAM_Bid:
|
||||
// 每轮开始出价,显示上一轮的竞拍结果
|
||||
}
|
||||
}
|
||||
return dataList
|
||||
}
|
||||
|
||||
// 返回客户端显示秒杀成功的玩家信息
|
||||
func (self *LiveBidRoom) GetShowResultList(readyUidList []uint64, uid uint64) []*serverproto.LiveRoomPlayerInfo {
|
||||
playerResults := make([]*serverproto.LiveRoomPlayerInfo, 0)
|
||||
return playerResults
|
||||
}
|
||||
|
||||
func (self *LiveBidRoom) GetShowRewardList(readyUidList []uint64, uid uint64) []*serverproto.KeyValueType {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *LiveBidRoom) HasShowData() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *LiveBidRoom) GetShowData(readyUidList []uint64, uid uint64) []*serverproto.KeyValueType64 {
|
||||
submitResult := make([]*serverproto.KeyValueType64, 0)
|
||||
if self.currBidInfo != nil {
|
||||
player := RoomMgr.GetPlayer(self.currBidInfo.uid)
|
||||
submitResult = append(submitResult, &serverproto.KeyValueType64{
|
||||
Key: uint64(0),
|
||||
Value: int32(self.currBidInfo.bidPrice),
|
||||
StrVal: player.Name,
|
||||
})
|
||||
}
|
||||
return submitResult
|
||||
}
|
||||
|
||||
// 玩家抢购秒杀
|
||||
func (self *LiveBidRoom) HandleShowSubmit(uid uint64, data []*serverproto.KeyValueType64) []*serverproto.KeyValueType64 {
|
||||
submitResult := make([]*serverproto.KeyValueType64, 0)
|
||||
// 1.先检查玩家是否拥有报价那么多的金币
|
||||
// 2.再检查报价是否比上一轮报价高
|
||||
if len(data) > 0 {
|
||||
bidPrice := uint32(data[0].Value)
|
||||
if (self.currBidInfo != nil && bidPrice > self.currBidInfo.bidPrice) || self.currBidInfo == nil {
|
||||
self.currBidInfo = &BidInfo{uid: uid, bidPrice: uint32(bidPrice)}
|
||||
}
|
||||
player := RoomMgr.GetPlayer(self.currBidInfo.uid)
|
||||
submitResult = append(submitResult, &serverproto.KeyValueType64{
|
||||
Key: uint64(bidPrice),
|
||||
Value: int32(self.currBidInfo.bidPrice),
|
||||
StrVal: player.Name,
|
||||
})
|
||||
}
|
||||
return submitResult
|
||||
}
|
||||
|
||||
func (self *LiveBidRoom) GetStageEnterParams(stage uint32) string {
|
||||
stageEnterParams := ""
|
||||
switch stage {
|
||||
case LIVEROOM_STAGE_READY:
|
||||
stageEnterParams = string(self.currBidCfg.Id)
|
||||
case LIVEROOM_STAGE_SHOW:
|
||||
stageEnterParams = string(self.currBidCfg.Id)
|
||||
}
|
||||
return stageEnterParams
|
||||
}
|
||||
@ -29,15 +29,15 @@ type RollCardCfg struct {
|
||||
type LiveCardRoom struct {
|
||||
LiveRoom
|
||||
rollCardCfgList []*RollCardCfg
|
||||
rollCards []*serverproto.KeyValueType64Str
|
||||
showRewards []*serverproto.KeyValueType64Str
|
||||
rollCards []*serverproto.KeyValueType64
|
||||
showRewards []*serverproto.KeyValueType64
|
||||
}
|
||||
|
||||
func newLiveCardRoom(roomId uint32, tickInterval uint32) *LiveCardRoom {
|
||||
room := &LiveCardRoom{
|
||||
LiveRoom: newLiveRoom(roomId, LIVEROOM_TYPE_CARD, tickInterval),
|
||||
rollCards: make([]*serverproto.KeyValueType64Str, 0),
|
||||
showRewards: make([]*serverproto.KeyValueType64Str, 0),
|
||||
rollCards: make([]*serverproto.KeyValueType64, 0),
|
||||
showRewards: make([]*serverproto.KeyValueType64, 0),
|
||||
}
|
||||
room.Init()
|
||||
return room
|
||||
@ -175,7 +175,7 @@ func (self *LiveCardRoom) RollCards(cardType int32, cardCount int) []string {
|
||||
func (self *LiveCardRoom) ShowStart() {
|
||||
// 为准备的玩家抽卡
|
||||
weightCfg := map[string]int{"NORMAL": 50, "MINI": 30, "MVP": 20}
|
||||
self.rollCards = make([]*serverproto.KeyValueType64Str, 0)
|
||||
self.rollCards = make([]*serverproto.KeyValueType64, 0)
|
||||
for _, uid := range self.LiveRoom.readyUidList {
|
||||
cards := make([]string, 0)
|
||||
// 1. 保底抽一张MINI卡
|
||||
@ -199,11 +199,11 @@ func (self *LiveCardRoom) ShowStart() {
|
||||
rand.Shuffle(len(cards), func(i, j int) {
|
||||
cards[i], cards[j] = cards[j], cards[i]
|
||||
})
|
||||
self.rollCards = append(self.rollCards, &serverproto.KeyValueType64Str{
|
||||
self.rollCards = append(self.rollCards, &serverproto.KeyValueType64{
|
||||
Key: uid,
|
||||
StrVal: strings.Join(cards, ";"),
|
||||
})
|
||||
self.showRewards = append(self.showRewards, &serverproto.KeyValueType64Str{
|
||||
self.showRewards = append(self.showRewards, &serverproto.KeyValueType64{
|
||||
Key: uid,
|
||||
StrVal: strings.Join(cards, ";"),
|
||||
})
|
||||
@ -222,7 +222,7 @@ func (self *LiveCardRoom) GetMaxReadyNum(roomType uint32) int {
|
||||
return LIVEROOM_CARD_MAX_READY_NUM
|
||||
}
|
||||
|
||||
func (self *LiveCardRoom) GetPlayDataList(readyUidList []uint64, uid uint64, cfg *serverproto.LiveRoomTalkCfg) []*serverproto.KeyValueType64Str {
|
||||
func (self *LiveCardRoom) GetCMDPlayDataList(readyUidList []uint64, uid uint64, cfg *serverproto.LiveRoomTalkCfg) []*serverproto.KeyValueType64 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ func (self *LiveCardRoom) GetShowResultList(readyUidList []uint64, uid uint64) [
|
||||
}
|
||||
|
||||
// 抽卡:获取当前玩家获得的物品
|
||||
func (self *LiveCardRoom) GetShowRewardList(readyUidList []uint64, uid uint64) []*serverproto.KeyValueType64Str {
|
||||
func (self *LiveCardRoom) GetShowRewardList(readyUidList []uint64, uid uint64) []*serverproto.KeyValueType64 {
|
||||
return self.showRewards
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ func (self *LiveGameRoom) GetMaxReadyNum(roomType uint32) int {
|
||||
return LIVEROOM_GAME_MAX_READY_NUM
|
||||
}
|
||||
|
||||
func (self *LiveGameRoom) GetPlayDataList(readyUidList []uint64, uid uint64, cfg *serverproto.LiveRoomTalkCfg) []*serverproto.KeyValueType64Str {
|
||||
func (self *LiveGameRoom) GetPlayDataList(readyUidList []uint64, uid uint64, cfg *serverproto.LiveRoomTalkCfg) []*serverproto.KeyValueType64 {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ func (self *LiveRoom) GetMaxReadyNum(roomType uint32) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *LiveRoom) GetPlayDataList(readyUidList []uint64, uid uint64, cfg *serverproto.LiveRoomTalkCfg) []*serverproto.KeyValueType64Str {
|
||||
func (self *LiveRoom) GetCMDPlayDataList(readyUidList []uint64, uid uint64, cfg *serverproto.LiveRoomTalkCfg) []*serverproto.KeyValueType64 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ func (self *LiveRoom) GetShowResultList(readyUidList []uint64, uid uint64) []*se
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *LiveRoom) GetShowRewardList(readyUidList []uint64, uid uint64) []*serverproto.KeyValueType64Str {
|
||||
func (self *LiveRoom) GetShowRewardList(readyUidList []uint64, uid uint64) []*serverproto.KeyValueType64 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -116,10 +116,15 @@ func (self *LiveRoom) GetStageEnterParams(stage uint32) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *LiveRoom) ShowStart() {}
|
||||
|
||||
func (self *LiveRoom) ReadyStart() {}
|
||||
func (self *LiveRoom) ShowStart() {}
|
||||
func (self *LiveRoom) CheckIfShowEnd() bool {
|
||||
return false
|
||||
}
|
||||
func (self *LiveRoom) ShowEnd() {}
|
||||
|
||||
func (self *LiveRoom) HandlePlayCMD(cfg *serverproto.LiveRoomTalkCfg) {}
|
||||
|
||||
/*----------------------------------- 内部函数 -----------------------------------*/
|
||||
func (self *LiveRoom) Init() {
|
||||
self.idleTimeline = self.CreateTimeline(LIVEROOM_STAGE_IDLE)
|
||||
@ -238,11 +243,12 @@ func (self *LiveRoom) HandleCMD(sn int32, cfg *serverproto.LiveRoomTalkCfg) {
|
||||
}
|
||||
})
|
||||
case LIVEROOM_CMD_PLAY:
|
||||
self.HandlePlayCMD(cfg)
|
||||
self.SendAllPlayers(func(uid uint64) interface{} {
|
||||
return &serverproto.SCLiveRoomCMDPlayNtf{
|
||||
Uid: uid,
|
||||
RoomId: self.roomId,
|
||||
PlayDataList: self.GetPlayDataList(self.readyUidList, uid, cfg),
|
||||
PlayDataList: self.GetCMDPlayDataList(self.readyUidList, uid, cfg),
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -278,7 +284,7 @@ func (self *LiveRoom) LIVEROOM_STAGE_IDLE_Exit() {}
|
||||
|
||||
/*----------------------------------- Stage: READY -----------------------------------*/
|
||||
func (self *LiveRoom) LIVEROOM_STAGE_READY_Enter() {
|
||||
//util.InfoF("LIVEROOM_STAGE_READY_Enter")
|
||||
self.ReadyStart()
|
||||
}
|
||||
|
||||
func (self *LiveRoom) LIVEROOM_STAGE_READY_Update(deltaMS uint32) {
|
||||
@ -312,6 +318,10 @@ func (self *LiveRoom) LIVEROOM_STAGE_SHOW_Update(deltaMS uint32) {
|
||||
self.ChangeStage(LIVEROOM_STAGE_RESULT)
|
||||
return
|
||||
}
|
||||
if self.CheckIfShowEnd() {
|
||||
self.ChangeStage(LIVEROOM_STAGE_RESULT)
|
||||
return
|
||||
}
|
||||
//util.InfoF("LIVEROOM_STAGE_SHOW_Update: Tick %d", uint32(self.stageTick))
|
||||
if frame, exist := self.showTimeline[self.stageTick]; exist {
|
||||
for i := 0; i < len(frame.talkCfgList); i++ {
|
||||
|
||||
@ -62,7 +62,7 @@ func (self *LiveSellRoom) GetMaxReadyNum(roomType uint32) int {
|
||||
}
|
||||
|
||||
// 返回客户端显示秒杀的商品数据
|
||||
func (self *LiveSellRoom) GetPlayDataList(readyUidList []uint64, uid uint64, cfg *serverproto.LiveRoomTalkCfg) []*serverproto.KeyValueType64Str {
|
||||
func (self *LiveSellRoom) GetCMDPlayDataList(readyUidList []uint64, uid uint64, cfg *serverproto.LiveRoomTalkCfg) []*serverproto.KeyValueType64 {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,8 @@ const (
|
||||
LIVEROOM_TYPE_SELL = 2
|
||||
LIVEROOM_TYPE_ANSWER = 3
|
||||
LIVEROOM_TYPE_GAME = 4
|
||||
LIVEROOM_TYPE_SEND_GIFT = 5
|
||||
LIVEROOM_TYPE_BID = 5
|
||||
LIVEROOM_TYPE_SEND_GIFT = 6
|
||||
)
|
||||
|
||||
const (
|
||||
@ -35,6 +36,7 @@ const (
|
||||
LIVEROOM_SELL_MAX_READY_NUM = 100
|
||||
LIVEROOM_ANSWER_MAX_READY_NUM = 100
|
||||
LIVEROOM_GAME_MAX_READY_NUM = 100
|
||||
LIVEROOM_BID_MAX_READY_NUM = 100
|
||||
)
|
||||
|
||||
const (
|
||||
@ -47,6 +49,11 @@ const (
|
||||
LIVEROOM_CMD_PLAY = 2
|
||||
)
|
||||
|
||||
const (
|
||||
LIVEROOM_CMD_PLAY_PARAM_BidPreview = "BidPreview"
|
||||
LIVEROOM_CMD_PLAY_PARAM_Bid = "Bid"
|
||||
)
|
||||
|
||||
// 泛型按值删除
|
||||
func SliceRemoveByValue[T comparable](slice []T, value T) []T {
|
||||
result := slice[:0]
|
||||
@ -72,6 +79,15 @@ func SliceIsExist[T comparable](slice []T, value T) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func SliceContains[T any](slice []T, predicate func(T) bool) bool {
|
||||
for _, v := range slice {
|
||||
if predicate(v) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 从 map 中随机选择 N 个键
|
||||
func RandomKeys[K comparable, V any](m map[K]V, n int) []K {
|
||||
if n <= 0 || len(m) == 0 {
|
||||
|
||||
@ -11,6 +11,7 @@ const (
|
||||
LIVE_SELL_ROOM_NUM = 1
|
||||
LIVE_ANSWER_ROOM_NUM = 1
|
||||
LIVE_GAME_ROOM_NUM = 1
|
||||
LIVE_BID_ROOM_NUM = 1
|
||||
LIVEROOM_UPDATE_DELTA_MS = 100
|
||||
)
|
||||
|
||||
@ -21,8 +22,8 @@ type RoomManager struct {
|
||||
updateTimer util.ServerTimer
|
||||
deletePlayerTimer util.ServerTimer
|
||||
roomCount uint32
|
||||
players map[uint64]*RoomPlayer
|
||||
fruitGameRooms []*FruitGameRoom
|
||||
players map[uint64]*RoomPlayer
|
||||
liveRooms []LiveRoomInterface
|
||||
}
|
||||
|
||||
@ -56,6 +57,9 @@ func (self *RoomManager) Init() {
|
||||
for i := 0; i < LIVE_GAME_ROOM_NUM; i++ {
|
||||
self.AllocLiveGameRoom()
|
||||
}
|
||||
for i := 0; i < LIVE_BID_ROOM_NUM; i++ {
|
||||
self.AllocBidGameRoom()
|
||||
}
|
||||
}
|
||||
|
||||
func (self *RoomManager) AllocRoomId() uint32 {
|
||||
@ -102,6 +106,13 @@ func (self *RoomManager) AllocLiveGameRoom() uint32 {
|
||||
return roomId
|
||||
}
|
||||
|
||||
func (self *RoomManager) AllocBidGameRoom() uint32 {
|
||||
roomId := self.AllocRoomId()
|
||||
room := newLiveBidRoom(roomId, LIVEROOM_TICK_INTERVAL)
|
||||
self.liveRooms = append(self.liveRooms, room)
|
||||
return roomId
|
||||
}
|
||||
|
||||
func (self *RoomManager) FindLiveRoom(uid uint64, liveType uint32) (LiveRoomInterface, error) {
|
||||
for _, liveRoom := range self.liveRooms {
|
||||
if liveRoom.RoomType() == liveType && liveRoom.HasPlayer(uid) {
|
||||
|
||||
@ -82,6 +82,7 @@ const (
|
||||
CFG_KeepSakeCfg = "KeepSakeCfg.csv"
|
||||
CFG_LevelCfg = "LevelCfg.csv"
|
||||
CFG_LineMissionCfg = "LineMissionCfg.csv"
|
||||
CFG_LiveRoomBidCfg = "LiveRoomBidCfg.csv"
|
||||
CFG_LiveRoomCfg = "LiveRoomCfg.csv"
|
||||
CFG_LiveRoomQuestionCfg = "LiveRoomQuestionCfg.csv"
|
||||
CFG_LiveRoomSellCfg = "LiveRoomSellCfg.csv"
|
||||
@ -237,6 +238,7 @@ func configNameListInit(){
|
||||
CFGNameList["KeepSakeCfg"] = KeepSakeCfgLoad
|
||||
CFGNameList["LevelCfg"] = LevelCfgLoad
|
||||
CFGNameList["LineMissionCfg"] = LineMissionCfgLoad
|
||||
CFGNameList["LiveRoomBidCfg"] = LiveRoomBidCfgLoad
|
||||
CFGNameList["LiveRoomCfg"] = LiveRoomCfgLoad
|
||||
CFGNameList["LiveRoomQuestionCfg"] = LiveRoomQuestionCfgLoad
|
||||
CFGNameList["LiveRoomSellCfg"] = LiveRoomSellCfgLoad
|
||||
@ -425,6 +427,7 @@ func ConfigInit(path string) {
|
||||
KeepSakeCfgLoad(path)
|
||||
LevelCfgLoad(path)
|
||||
LineMissionCfgLoad(path)
|
||||
LiveRoomBidCfgLoad(path)
|
||||
LiveRoomCfgLoad(path)
|
||||
LiveRoomQuestionCfgLoad(path)
|
||||
LiveRoomSellCfgLoad(path)
|
||||
@ -2139,10 +2142,31 @@ func LineMissionCfgLoad(path string) {
|
||||
}
|
||||
}
|
||||
|
||||
var LiveRoomBidCfgLoader map[int32]*LiveRoomBidCfg
|
||||
type LiveRoomBidCfg struct{
|
||||
Id int32 `csv:"Id"` //序号
|
||||
Name string `csv:"Name"` //名字
|
||||
Desp string `csv:"Desp"` //描述
|
||||
Icon string `csv:"Icon"` //图标
|
||||
Price string `csv:"Price"` //原价
|
||||
AddPrice int32 `csv:"AddPrice"` //秒杀价格
|
||||
Items []string `csv:"Items"` //包含物品(物品ID:数量;物品ID:数量)
|
||||
}
|
||||
func LiveRoomBidCfgLoad(path string) {
|
||||
cfg := []*LiveRoomBidCfg{}
|
||||
LiveRoomBidCfgLoader = map[int32]*LiveRoomBidCfg{}
|
||||
loadCsvCfg(path + "LiveRoomBidCfg.csv", &cfg)
|
||||
for _,row := range cfg{
|
||||
LiveRoomBidCfgLoader[row.Id] = row
|
||||
}
|
||||
}
|
||||
|
||||
var LiveRoomCfgLoader map[int32]*LiveRoomCfg
|
||||
type LiveRoomCfg struct{
|
||||
Id int32 `csv:"Id"` //序号
|
||||
Type int32 `csv:"Type"` //房间类型:1-抽卡,2-带货,3-答题,4-游戏
|
||||
Streamer string `csv:"Streamer"` //主播名字
|
||||
StreamerHead string `csv:"StreamerHead"` //主播头像
|
||||
RoomDesp string `csv:"RoomDesp"` //房间描述
|
||||
MaxGiftPoint int32 `csv:"MaxGiftPoint"` //直播开启礼物点数
|
||||
ReadyCost []string `csv:"ReadyCost"` //准备开销(物品ID:数量;物品ID:数量)
|
||||
@ -2188,6 +2212,7 @@ func LiveRoomQuestionCfgLoad(path string) {
|
||||
var LiveRoomSellCfgLoader map[int32]*LiveRoomSellCfg
|
||||
type LiveRoomSellCfg struct{
|
||||
Id int32 `csv:"Id"` //序号
|
||||
Name string `csv:"Name"` //名字
|
||||
Desp string `csv:"Desp"` //描述
|
||||
SellNum int32 `csv:"SellNum"` //售卖数量
|
||||
Icon string `csv:"Icon"` //图标
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -3940,7 +3940,7 @@ message SCLiveRoomCMDTalkNtf { //project game|fruit //RouteRule game
|
||||
message SCLiveRoomCMDPlayNtf { //project game|fruit //RouteRule game
|
||||
uint64 uid = 1;
|
||||
uint32 room_id = 2;
|
||||
repeated KeyValueType64Str play_data_list = 3;
|
||||
repeated KeyValueType64 play_data_list = 3;
|
||||
}
|
||||
message SCLiveRoomStageNtf { //project game|fruit //RouteRule game
|
||||
uint64 uid = 1;
|
||||
@ -3982,5 +3982,5 @@ message SCLiveRoomResultNtf { //project game|fruit //RouteRule game
|
||||
uint64 uid = 1;
|
||||
uint32 room_id = 2;
|
||||
repeated LiveRoomPlayerInfo player_result_list = 3;
|
||||
repeated KeyValueType64Str player_reward_list = 4;
|
||||
repeated KeyValueType64 player_reward_list = 4;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user