package entertainment import ( "go_dreamfactory/comm" "go_dreamfactory/pb" "go.mongodb.org/mongo-driver/bson/primitive" "google.golang.org/protobuf/proto" ) //游戏房间 type Room struct { Id string player1 *Player // 玩家1 player2 *Player // 玩家2 chessboard *MapData } func (this *Room) InitRoom(s1 comm.IUserSession, s2 comm.IUserSession) *Room { this.chessboard = new(MapData) this.chessboard.InitMap() // 初始化棋盘 return &Room{ Id: primitive.NewObjectID().Hex(), player1: &Player{}, player2: &Player{}, chessboard: this.chessboard, } } func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, req proto.Message) (errdata *pb.ErrorData) { switch stype { case "opertor": // 操作消息 //req1 := req.(*pb.BattleCmd) } return } // 玩家操作 func (this *Room) Opertor(set int32, iType int32, old int32, new int32) (errdata *pb.ErrorData) { if iType == 1 { this.chessboard.SwapGirde(old, new) // 交换格子 } return }