Remove leading number from move message.
This commit is contained in:
parent
f303a572cc
commit
b0db6145e8
@ -21,9 +21,13 @@ func parseMove(received string) (*chessMove, error) {
|
||||
|
||||
splitReceived := strings.Split(received, " ")
|
||||
|
||||
realMoveString := splitReceived[1]
|
||||
startSquareString := splitReceived[2]
|
||||
endSquareString := splitReceived[3]
|
||||
if len(splitReceived) != 3 {
|
||||
return nil, errors.New("invalid move command")
|
||||
}
|
||||
|
||||
realMoveString := splitReceived[0]
|
||||
startSquareString := splitReceived[1]
|
||||
endSquareString := splitReceived[2]
|
||||
|
||||
if strings.Compare(realMoveString, "mv") == 0 {
|
||||
move.realMove = true
|
||||
|
@ -67,12 +67,13 @@ func (game *chessGame) handle() {
|
||||
return
|
||||
}
|
||||
move, err = parseMove(string(receivedMessage))
|
||||
log.Println("Player 1 moved: ", move)
|
||||
|
||||
if err != nil {
|
||||
log.Println("Game: ", game.id, err)
|
||||
return
|
||||
}
|
||||
log.Println("Player 1 moved: ", move)
|
||||
|
||||
gameState = CheckPlayerChange
|
||||
|
||||
case CheckPlayerChange:
|
||||
|
Loading…
Reference in New Issue
Block a user