implement game turn logic

This commit is contained in:
2026-11-02 21:24:32 +03:00
parent 153dc74ff6
commit 189b027a11
7 changed files with 896 additions and 13 deletions
+10
View File
@@ -291,6 +291,16 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.log.Debug("place ships rejected", "match", match.ID, "user", uc.UserID, "err", err)
continue
}
case protocol.OpFire:
x, y, err := protocol.ParseFire(args)
if err != nil {
h.log.Debug("malformed Fire", "match", match.ID, "user", uc.UserID, "err", err)
continue
}
if _, err := h.Manager.Fire(ctx, match, slotIdx, x, y); err != nil {
h.log.Debug("fire rejected or ignored", "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)