Compare commits
2 Commits
e044a590d4
...
b186967189
Author | SHA1 | Date |
---|---|---|
|
b186967189 | |
|
d82c5ed055 |
|
@ -35,6 +35,7 @@ const (
|
|||
ThirteenWaterPlayerOpReset = 4 // 重新选牌
|
||||
ThirteenWaterPlayerJoin = 5 // 加入游戏
|
||||
ThirteenWaterPlayerOpSelect = 6 // 预选牌
|
||||
ThirteenWaterPlayerOpAuto = 7 // 自动摆牌 1自动 2手动
|
||||
)
|
||||
const (
|
||||
ThirteenWaterSceneWaitTimeout = time.Second * 2 //等待倒计时
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package thirteen
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
|
||||
"mongo.games.com/game/gamerule/thirteen"
|
||||
|
@ -26,6 +28,9 @@ type PlayerEx struct {
|
|||
totalScore int64
|
||||
defGroup *thirteen.Group
|
||||
playerPool int // 个人水池分
|
||||
AutoState int // 是否自动模式
|
||||
AutoMill time.Duration // 自动时长
|
||||
HandMill time.Duration // 手动时长
|
||||
}
|
||||
|
||||
func (this *PlayerEx) Clear() {
|
||||
|
@ -42,6 +47,9 @@ func (this *PlayerEx) Clear() {
|
|||
this.gainCoin = 0
|
||||
this.taxCoin = 0
|
||||
this.deterMine = false
|
||||
this.AutoState = 0
|
||||
this.AutoMill = time.Duration(0)
|
||||
this.HandMill = time.Duration(0)
|
||||
this.score = [7]int64{0, 0, 0, 0, 0, 0, 0}
|
||||
this.tableScore = [6]int64{}
|
||||
this.winThreePos = make(map[int]int64)
|
||||
|
|
|
@ -86,6 +86,7 @@ type SceneEx struct {
|
|||
ctrlType int // 1控赢 2控输 0不控
|
||||
cardsArr [][13]int
|
||||
cardsGroup []map[int]*rule.Group
|
||||
timestamp time.Time
|
||||
}
|
||||
|
||||
func NewThirteenWaterSceneData(s *base.Scene) *SceneEx {
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"mongo.games.com/goserver/core"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
|
||||
|
@ -11,6 +12,7 @@ import (
|
|||
rule "mongo.games.com/game/gamerule/thirteen"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/mq"
|
||||
"mongo.games.com/game/proto"
|
||||
"mongo.games.com/game/protocol/thirteen"
|
||||
)
|
||||
|
@ -808,6 +810,11 @@ func (this *StateOp) OnEnter(s *base.Scene) {
|
|||
logger.Logger.Tracef("(this *StateOp) OnEnter, sceneid=%v", s.GetSceneId())
|
||||
this.BaseState.OnEnter(s)
|
||||
ThirteenWaterBroadcastRoomState(s)
|
||||
sceneEx, ok := s.ExtraData.(*SceneEx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
sceneEx.timestamp = time.Now()
|
||||
}
|
||||
|
||||
// 玩家操作
|
||||
|
@ -869,6 +876,7 @@ func (this *StateOp) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, param
|
|||
playerEx.Trusteeship = 0
|
||||
playerEx.UnmarkFlag(base.PlayerState_Auto)
|
||||
playerEx.deterMine = true
|
||||
playerEx.AutoState = 0
|
||||
//如果所有玩家都确认牌之后 可以直接开始下一阶段
|
||||
a := true
|
||||
for _, v := range sceneEx.players {
|
||||
|
@ -942,6 +950,13 @@ func (this *StateOp) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, param
|
|||
playerEx.deterMine = false
|
||||
returnFunc(thirteen.OpResultCode_OPRC_Sucess, true)
|
||||
|
||||
case rule.ThirteenWaterPlayerOpAuto:
|
||||
if len(params) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
playerEx.AutoState = int(params[0])
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
@ -958,6 +973,15 @@ func (this *StateOp) OnLeave(s *base.Scene) {
|
|||
|
||||
for _, player := range sceneEx.players {
|
||||
if player != nil && player.IsGameing() {
|
||||
|
||||
mq.Write(model.ThirteenAutoLog{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
LogId: sceneEx.logid,
|
||||
SnId: player.SnId,
|
||||
AutoTime: player.AutoMill.Milliseconds(),
|
||||
HandTime: player.HandMill.Milliseconds(),
|
||||
}, mq.BackThirteenAutoLog)
|
||||
|
||||
// 使用预选牌
|
||||
if player.preCardsO != nil && player.preCardsO.PokerType != -1 && (player.cardsO == nil || player.cardsO.PokerType == -1) {
|
||||
player.cardsO = player.preCardsO
|
||||
|
@ -1137,7 +1161,23 @@ func (this *StateOp) OnLeave(s *base.Scene) {
|
|||
func (this *StateOp) OnTick(s *base.Scene) {
|
||||
this.BaseState.OnTick(s)
|
||||
if sceneEx, ok := s.ExtraData.(*SceneEx); ok {
|
||||
if time.Now().Sub(sceneEx.StateStartTime) > sceneEx.GetBaiPai() {
|
||||
now := time.Now()
|
||||
addTime := now.Sub(sceneEx.timestamp)
|
||||
for _, v := range sceneEx.seats {
|
||||
if v != nil && v.IsGameing() {
|
||||
switch v.AutoState {
|
||||
case 2:
|
||||
v.AutoMill += addTime
|
||||
case 1:
|
||||
v.HandMill += addTime
|
||||
default:
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
sceneEx.timestamp = now
|
||||
|
||||
if now.Sub(sceneEx.StateStartTime) > sceneEx.GetBaiPai() {
|
||||
s.ChangeSceneState(rule.ThirteenWaterSceneStateShowCards)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package model
|
||||
|
||||
type ThirteenAutoLog struct {
|
||||
Id string
|
||||
LogId string
|
||||
SnId int32
|
||||
AutoTime int64 // 自动时长,毫秒
|
||||
HandTime int64 // 手动时长,毫秒
|
||||
}
|
19
mq/export.go
19
mq/export.go
|
@ -55,18 +55,18 @@ type RabbitMQData struct {
|
|||
Data interface{}
|
||||
}
|
||||
|
||||
func (c *MessageMgr) Send(data interface{}, name ...string) error {
|
||||
func (c *MessageMgr) Send(data interface{}, name string, options ...broker.PublishOption) error {
|
||||
if msg, ok := data.(*RabbitMQData); ok {
|
||||
return Send(msg.MQName, msg.Data)
|
||||
return Send(msg.MQName, msg.Data, options...)
|
||||
}
|
||||
if len(name) > 0 && name[0] != "" {
|
||||
return Send(name[0], data)
|
||||
if len(name) > 0 {
|
||||
return Send(name, data, options...)
|
||||
}
|
||||
key := c.getName(data)
|
||||
if key == "" {
|
||||
key = "_null_"
|
||||
}
|
||||
return Send(key, data)
|
||||
return Send(key, data, options...)
|
||||
}
|
||||
|
||||
type RegisterHandlerParam struct {
|
||||
|
@ -132,7 +132,14 @@ func RegisterMessage(param *RegisterMessageParam) {
|
|||
// Write 发送消息
|
||||
// 默认队列名称规则:队列前缀_消息结构体名称
|
||||
func Write(data interface{}, name ...string) error {
|
||||
return MessageMgrSingle.Send(data, name...)
|
||||
if len(name) > 0 && name[0] != "" {
|
||||
return MessageMgrSingle.Send(data, name[0])
|
||||
}
|
||||
return MessageMgrSingle.Send(data, "")
|
||||
}
|
||||
|
||||
func WriteWithOptions(data interface{}, name string, opts ...broker.PublishOption) error {
|
||||
return MessageMgrSingle.Send(data, name, opts...)
|
||||
}
|
||||
|
||||
// RegisterHandler 注册消息处理函数
|
||||
|
|
|
@ -21,9 +21,11 @@ const (
|
|||
BackOnlineGame = "back_onlinegame"
|
||||
)
|
||||
|
||||
// mgrsrv
|
||||
// go后端
|
||||
|
||||
const ()
|
||||
const (
|
||||
BackThirteenAutoLog = "b_thirteenautolog"
|
||||
)
|
||||
|
||||
// worldsrv 消息
|
||||
|
||||
|
|
|
@ -386,7 +386,7 @@ type CSThirteenPlayerOp struct {
|
|||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
OpCode int32 `protobuf:"varint,1,opt,name=OpCode,proto3" json:"OpCode,omitempty"` // 1:确定牌 2站起状态 3test 4重新选牌 5加入游戏 6预选
|
||||
OpCode int32 `protobuf:"varint,1,opt,name=OpCode,proto3" json:"OpCode,omitempty"` // 1:确定牌 2站起状态 3test 4重新选牌 5加入游戏 6预选 7自动手动切换(1自动,2手动)
|
||||
// 确定牌时,两种参数规则,都可以
|
||||
// 第一种:玩家从推荐牌型中选择一个,把Poker.IndexType发过来(减少数据传输)
|
||||
// 第二种:按头墩中墩尾墩顺序把牌发过来
|
||||
|
|
|
@ -73,7 +73,7 @@ message SCThirteenPlayerCards {
|
|||
//玩家操作
|
||||
//PACKET_CSThirteenPlayerOp
|
||||
message CSThirteenPlayerOp {
|
||||
int32 OpCode = 1; // 1:确定牌 2站起状态 3test 4重新选牌 5加入游戏 6预选
|
||||
int32 OpCode = 1; // 1:确定牌 2站起状态 3test 4重新选牌 5加入游戏 6预选 7自动手动切换(1自动,2手动)
|
||||
|
||||
// 确定牌时,两种参数规则,都可以
|
||||
// 第一种:玩家从推荐牌型中选择一个,把Poker.IndexType发过来(减少数据传输)
|
||||
|
|
Loading…
Reference in New Issue