Skip to content

ChenMoGe2/SnakeLadder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

蛇梯游戏

通信协议基于websocket,客户端和服务端所有的数据交互基于protobuf进行封装。

1.父数据包

所有数据的传递都遵照父数据包的格式

参数名称 参数类型 参数说明
sessionId int32 会话ID,用来标识用户
crc32 int32 当前数据的类型
reqCrc32 int32 请求数据的类型
object bytes 数据报文的具体内容

2.子数据包

SignIn(CRC32:10001)

参数名称 参数类型 参数说明
username string 用户名

Match(CRC32:10002)

参数名称 参数类型 参数说明
num int32 匹配人数(目前只有2)

Doll(CRC32:10003)

参数名称 参数类型 参数说明

User(CRC32:20001)

参数名称 参数类型 参数说明
id int32 用户ID
username string 用户名
score int32 分数

Bool(CRC32:20002)

参数名称 参数类型 参数说明
value bool 布尔值

MatchResult(CRC32:20003)

参数名称 参数类型 参数说明
id int32 游戏ID
users repeated User 匹配到的所有用户
map string 地图中蛇梯的位置
curUserId int32 第一个先走的用户ID

DollResult(CRC32:20004)

参数名称 参数类型 参数说明
num int32 骰子点数
curPos int32 当前位置
curPlayer int32 当前玩家ID
nextPlayer int32 下一个回合玩家ID

3.数据表

用户表

CREATE TABLE user (
id int NOT NULL AUTO_INCREMENT,
username varchar(32) COLLATE utf8mb4_bin NOT NULL,
score int NOT NULL,
create_at timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE KEY unique_idx (username) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

游戏表

CREATE TABLE game (
id int NOT NULL AUTO_INCREMENT,
map varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '[]',
process varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '[]',
cur_user_id int NOT NULL,
victory int NOT NULL,
create_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

游戏用户关联表

CREATE TABLE game_user (
id int NOT NULL AUTO_INCREMENT,
game_id int NOT NULL,
user_id int NOT NULL,
cur_pos int NOT NULL,
create_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published