Skip to content

Latest commit

 

History

History
171 lines (115 loc) · 3.75 KB

protocol.md

File metadata and controls

171 lines (115 loc) · 3.75 KB

Myomyw数据包协议 v0.8

(暂未实现)

握手

以下部分数据包使用http格式,内容均为json格式,由客户端发起

路径格式:http://server-address/action

METHOD: GET

握手 (handshake)

参数名 描述 类型
version 客户端的版本 string

应答

参数名 描述 类型
error_code 0为成功,1为版本不匹配 int
message 要向玩家展示的信息 string

游戏过程

Myomyw的游戏数据包分为action和json格式的包内容两段,格式为action$@@${"parameter":"something"}

开始匹配

action 发送方
start_matching client
参数名 描述 类型
name 玩家名称 string

匹配成功

action 发送方
matching_success server
参数名 描述 类型
side 玩家为先手(0)或后手(1) int
room_id 房间号 int
opponent_name 对手名称 string

移动球

action 发送方
move client/server
参数名 描述 类型
col 移动的列(非第一次移动可省略) int

结束回合

action 发送方
end_turn client/server

(无参数)


填充球池

开始游戏时填充到满,随后每推出一个球后填充一个

action 发送方
fill_pool server
参数名 描述 类型
ball_seq 要加入球池的球的从先出到后出的序列数组(球的具体类型见下表) int[]
id 球的类型
0 普通球
1 关键球
2 增列球
3 减列球
4 翻转球

认输

action 发送方
give_up client

(无参数)


游戏结束

action 发送方
end_game server
参数名 描述 类型
reason 结束原因(见下表) int
reason 描述
0 服务器关闭
1 对手断开连接
2 玩家胜利
3 对手胜利
4 玩家超时
5 对手超时
6 玩家认输
7 对手认输

异常

通知游戏过程中出现的异常,如玩家移动时服务器认为不是该玩家的回合,或服务器与客户端的胜负判定不符。这通常意味着客户端被修改或游戏出现bug

action 发送方
exception client/server
参数名 描述 类型
description 描述异常 string

发送聊天

action 发送方
send_chat client
参数名 描述 类型
text 聊天内容 string

广播聊天

action 发送方
chat client
参数名 描述 类型
sender 发送者 string
text 聊天内容 string