| 231 | } |
| 232 | |
| 233 | void NetworkGame::back() |
| 234 | { |
| 235 | // 只允许悔自己刚走的棋(当前轮到对方,说明自己刚走完) |
| 236 | if (m_ChessSteps.size() == 0 || m_bIsOver) |
| 237 | return; |
| 238 | |
| 239 | bool currentTurnIsMyColor = (m_bIsRed == m_bIsTcpServer); |
| 240 | if (currentTurnIsMyColor) { |
| 241 | // 当前轮到自己,说明对方刚走完,不能悔对方的棋 |
| 242 | return; |
| 243 | } |
| 244 | |
| 245 | // 发送悔棋命令到对端 |
| 246 | char arry[3]; |
| 247 | arry[0] = static_cast<char>(0xFE); |
| 248 | arry[1] = 0; |
| 249 | arry[2] = 0; |
| 250 | if (m_tcpSocket) |
| 251 | m_tcpSocket->write(arry, 3); |
| 252 | |
| 253 | // 本地执行悔棋 |
| 254 | ChessBoard::back(); |
| 255 | update(); |
| 256 | } |
| 257 | |
| 258 | void NetworkGame::onBtnTryConnect() |
| 259 | { |
nothing calls this directly
no outgoing calls
no test coverage detected