Gogs 4 mesiacov pred
rodič
commit
4ec9531763

+ 4 - 1
bin/client_msg/common.proto

@@ -133,7 +133,10 @@ message  ReqPlayer {
   string Id = 1;
   repeated ReqCard HandCards =2;
   optional int32 SitPos = 3;
-  bool IsDealer = 4;
+  optional bool IsDealer = 4;
+  optional bool IsSeen = 5;
+  optional bool IsPacked = 6;
+  optional bool IsShow = 7;
 }
 
 message ReqPlayerList {

+ 2 - 0
src/server/game/room/room.go

@@ -60,6 +60,8 @@ type Player struct {
 	IsDealer bool
 	// 是否获胜
 	IsWin bool
+	// 上一次操作
+	LastOpt *msg.PlayerOpt
 }
 
 // 获取玩家ID

+ 7 - 4
src/server/game/teen/buildRoom.go

@@ -21,10 +21,13 @@ func convertToMsgPlayerList(players []*room.Player) []*msg.ReqPlayer {
 	msgPlayers := make([]*msg.ReqPlayer, len(players))
 	for i, player := range players {
 		msgPlayers[i] = &msg.ReqPlayer{
-			Id:        player.Id,
-			HandCards: convertToMsgCardList(player.HandCards),
-			SitPos:    &player.SitPos,
-			IsDealer:  player.IsDealer,
+			Id: player.Id,
+			// HandCards: convertToMsgCardList(player.HandCards),
+			SitPos:   &player.SitPos,
+			IsDealer: &player.IsDealer,
+			IsSeen:   &player.IsSeen,
+			IsPacked: &player.IsPacked,
+			IsShow:   &player.IsShow,
 		}
 	}
 	return msgPlayers

+ 1 - 1
src/server/game/teen/robot.go

@@ -82,7 +82,7 @@ func robotChaal(r *room.Room, sitPos int32) {
 	//获取1-5的随机数
 	chaalAmount := rand.Intn(5) + 1
 	game.Module.Skeleton.AfterFunc(time.Second*time.Duration(chaalAmount), func() {
-		chaal(r, sitPos)
+		recvPlayerOptAction(r, sitPos, msg.PlayerOptType_OPT_CHAAL)
 	})
 }
 

+ 20 - 9
src/server/game/teen/round.go

@@ -102,18 +102,20 @@ func addPlayerOptTimeout(room *room.Room, player *room.Player, timeout time.Dura
 func recvPlayerOptAction(room *room.Room, sitPos int32, optType msg.PlayerOptType) {
 	player := room.GetPlayerBySitPos(sitPos)
 	log.Debug("recvPlayerOptAction, optType:%v", optType)
+	player.LastOpt = &msg.PlayerOpt{OptType: optType}
 	if optType == msg.PlayerOptType_OPT_SEEN { // 看牌
 		seen(room, sitPos)
-		return
-	}
-	cancelOptTimeout(player, sitPos)
-	if optType == msg.PlayerOptType_OPT_PACKED { // 弃牌
-		packed(room, sitPos)
-	} else if optType == msg.PlayerOptType_OPT_CHAAL { // 跟注
-		chaal(room, sitPos)
-	} else if optType == msg.PlayerOptType_OPT_SHOW { // 亮牌
-		show(room, sitPos)
+	} else {
+		cancelOptTimeout(player, sitPos)
+		if optType == msg.PlayerOptType_OPT_PACKED { // 弃牌
+			packed(room, sitPos)
+		} else if optType == msg.PlayerOptType_OPT_CHAAL { // 跟注
+			chaal(room, sitPos)
+		} else if optType == msg.PlayerOptType_OPT_SHOW { // 亮牌
+			show(room, sitPos)
+		}
 	}
+	updateAllPlayerInfo(room)
 }
 
 // 发送消息给所有玩家
@@ -130,3 +132,12 @@ func SendRoundMsgToAll(room *room.Room, mg *msg.ReqRound) {
 	}
 	room.AddPlayerOpt(mg)
 }
+
+// 更新所有玩家的操作
+func updateAllPlayerInfo(room *room.Room) {
+	for _, player := range room.Players {
+		if player.Agent != nil {
+			player.Agent.WriteMsg(&msg.ReqPlayerList{ReqPlayers: convertToMsgPlayerList(room.Players)})
+		}
+	}
+}

+ 40 - 7
src/server/msg/common.pb.go

@@ -1219,7 +1219,10 @@ type ReqPlayer struct {
 	Id        string     `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"`
 	HandCards []*ReqCard `protobuf:"bytes,2,rep,name=HandCards,proto3" json:"HandCards,omitempty"`
 	SitPos    *int32     `protobuf:"varint,3,opt,name=SitPos,proto3,oneof" json:"SitPos,omitempty"`
-	IsDealer  bool       `protobuf:"varint,4,opt,name=IsDealer,proto3" json:"IsDealer,omitempty"`
+	IsDealer  *bool      `protobuf:"varint,4,opt,name=IsDealer,proto3,oneof" json:"IsDealer,omitempty"`
+	IsSeen    *bool      `protobuf:"varint,5,opt,name=IsSeen,proto3,oneof" json:"IsSeen,omitempty"`
+	IsPacked  *bool      `protobuf:"varint,6,opt,name=IsPacked,proto3,oneof" json:"IsPacked,omitempty"`
+	IsShow    *bool      `protobuf:"varint,7,opt,name=IsShow,proto3,oneof" json:"IsShow,omitempty"`
 }
 
 func (x *ReqPlayer) Reset() {
@@ -1276,8 +1279,29 @@ func (x *ReqPlayer) GetSitPos() int32 {
 }
 
 func (x *ReqPlayer) GetIsDealer() bool {
-	if x != nil {
-		return x.IsDealer
+	if x != nil && x.IsDealer != nil {
+		return *x.IsDealer
+	}
+	return false
+}
+
+func (x *ReqPlayer) GetIsSeen() bool {
+	if x != nil && x.IsSeen != nil {
+		return *x.IsSeen
+	}
+	return false
+}
+
+func (x *ReqPlayer) GetIsPacked() bool {
+	if x != nil && x.IsPacked != nil {
+		return *x.IsPacked
+	}
+	return false
+}
+
+func (x *ReqPlayer) GetIsShow() bool {
+	if x != nil && x.IsShow != nil {
+		return *x.IsShow
 	}
 	return false
 }
@@ -1669,15 +1693,24 @@ var file_common_proto_rawDesc = []byte{
 	0x71, 0x43, 0x61, 0x72, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x01,
 	0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x50,
 	0x6f, 0x69, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x50, 0x6f, 0x69, 0x6e,
-	0x74, 0x22, 0x87, 0x01, 0x0a, 0x09, 0x52, 0x65, 0x71, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x12,
+	0x74, 0x22, 0x97, 0x02, 0x0a, 0x09, 0x52, 0x65, 0x71, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x12,
 	0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x64, 0x12,
 	0x26, 0x0a, 0x09, 0x48, 0x61, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03,
 	0x28, 0x0b, 0x32, 0x08, 0x2e, 0x52, 0x65, 0x71, 0x43, 0x61, 0x72, 0x64, 0x52, 0x09, 0x48, 0x61,
 	0x6e, 0x64, 0x43, 0x61, 0x72, 0x64, 0x73, 0x12, 0x1b, 0x0a, 0x06, 0x53, 0x69, 0x74, 0x50, 0x6f,
 	0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x06, 0x53, 0x69, 0x74, 0x50, 0x6f,
-	0x73, 0x88, 0x01, 0x01, 0x12, 0x1a, 0x0a, 0x08, 0x49, 0x73, 0x44, 0x65, 0x61, 0x6c, 0x65, 0x72,
-	0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x49, 0x73, 0x44, 0x65, 0x61, 0x6c, 0x65, 0x72,
-	0x42, 0x09, 0x0a, 0x07, 0x5f, 0x53, 0x69, 0x74, 0x50, 0x6f, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x52,
+	0x73, 0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x49, 0x73, 0x44, 0x65, 0x61, 0x6c, 0x65, 0x72,
+	0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48, 0x01, 0x52, 0x08, 0x49, 0x73, 0x44, 0x65, 0x61, 0x6c,
+	0x65, 0x72, 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x49, 0x73, 0x53, 0x65, 0x65, 0x6e, 0x18,
+	0x05, 0x20, 0x01, 0x28, 0x08, 0x48, 0x02, 0x52, 0x06, 0x49, 0x73, 0x53, 0x65, 0x65, 0x6e, 0x88,
+	0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x49, 0x73, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x18, 0x06,
+	0x20, 0x01, 0x28, 0x08, 0x48, 0x03, 0x52, 0x08, 0x49, 0x73, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x64,
+	0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x49, 0x73, 0x53, 0x68, 0x6f, 0x77, 0x18, 0x07, 0x20,
+	0x01, 0x28, 0x08, 0x48, 0x04, 0x52, 0x06, 0x49, 0x73, 0x53, 0x68, 0x6f, 0x77, 0x88, 0x01, 0x01,
+	0x42, 0x09, 0x0a, 0x07, 0x5f, 0x53, 0x69, 0x74, 0x50, 0x6f, 0x73, 0x42, 0x0b, 0x0a, 0x09, 0x5f,
+	0x49, 0x73, 0x44, 0x65, 0x61, 0x6c, 0x65, 0x72, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x49, 0x73, 0x53,
+	0x65, 0x65, 0x6e, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x49, 0x73, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x64,
+	0x42, 0x09, 0x0a, 0x07, 0x5f, 0x49, 0x73, 0x53, 0x68, 0x6f, 0x77, 0x22, 0x3b, 0x0a, 0x0d, 0x52,
 	0x65, 0x71, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x0a,
 	0x52, 0x65, 0x71, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
 	0x32, 0x0a, 0x2e, 0x52, 0x65, 0x71, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x52, 0x0a, 0x52, 0x65,