implement game turn logic
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user