add PlaceShips message
This commit is contained in:
@@ -277,6 +277,20 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
h.log.Debug("invalid ACK seq", "match", match.ID, "user", uc.UserID, "seq", seq, "err", err)
|
||||
continue
|
||||
}
|
||||
case protocol.OpPlaceShips:
|
||||
ships, err := protocol.ParsePlaceShips(args)
|
||||
if err != nil {
|
||||
h.log.Debug("malformed PlaceShips", "match", match.ID, "user", uc.UserID, "err", err)
|
||||
continue
|
||||
}
|
||||
if err := protocol.ValidateShips(ships); err != nil {
|
||||
h.log.Debug("invalid ship placement", "match", match.ID, "user", uc.UserID, "err", err)
|
||||
continue
|
||||
}
|
||||
if err := h.Manager.PlaceShips(ctx, match, slotIdx, ships); err != nil {
|
||||
h.log.Debug("place ships rejected", "match", match.ID, "user", uc.UserID, "err", err)
|
||||
continue
|
||||
}
|
||||
default:
|
||||
// Unknown opcodes are ignored for forward compatibility.
|
||||
h.log.Debug("unknown opcode", "match", match.ID, "user", uc.UserID, "opcode", opcode)
|
||||
|
||||
Reference in New Issue
Block a user