From: Skullheadx Date: Mon, 8 Jun 2026 02:04:50 +0000 (-0400) Subject: fix merge conflicts X-Git-Url: http://git.skullheadx.com/nixos/static/gitweb.js?a=commitdiff_plain;h=33847f9fc1e80dc0b6a863b8f082044adac50e7e;p=monopoly-web.git fix merge conflicts --- diff --git a/main.go b/main.go index b718378..42fb8d6 100644 --- a/main.go +++ b/main.go @@ -23,80 +23,6 @@ func main() { } } -func run() error { - l, err := net.Listen("tcp", "127.0.0.1:8443") - if err != nil { - return err - } - log.Printf("listening on ws://%v", l.Addr()) - - cs := game.NewMonopolyServer() - s := &http.Server{ - Handler: cs, - ReadTimeout: time.Second * 10, - WriteTimeout: time.Second * 10, - } - -const UUID = "abc" // TODO: UUID in cookie - -func (r *Room) rollDiceHandler(w http.ResponseWriter, req *http.Request) { - if r.gameCtx.ValidateCanRoll(UUID) { - r.gameCtx.RollDice() - r.gameCtx.ProcessMovement() - } -} - -func (r *Room) endTurnHandler(w http.ResponseWriter, req *http.Request) { - if r.gameCtx.ValidateCanEndTurn(UUID) { - r.gameCtx.EndTurn() - } -} - -func (r *Room) exitJailHandler(w http.ResponseWriter, req *http.Request) { - err := req.ParseForm() - if err != nil { - http.Error(w, "Bad Request: Failed to parse form data", http.StatusBadRequest) - return - } - - if !r.gameCtx.ValidateCanExitJail(UUID) { - w.WriteHeader(http.StatusForbidden) - w.Write([]byte(`{"status": "forbidden", "message": "Not your turn or not in jail"}`)) - } - - method := req.PostForm.Get("method") - - switch method { - case "buyout": - err = r.gameCtx.JailBuyout() - if err == game.ErrNotEnoughMoney { - http.Error(w, "error: Insufficient funds", http.StatusUnprocessableEntity) - } - - case "jail_free_card": - err = r.gameCtx.JailUseCard() - if err == game.ErrNotEnoughJailCards { - http.Error(w, "error: Insufficient jail cards", http.StatusUnprocessableEntity) - } - default: - w.WriteHeader(http.StatusBadRequest) - w.Write([]byte(`{"status": "bad req", "message": "escape jail method does not exist"}`)) - return - } - - w.WriteHeader(http.StatusOK) - w.Write([]byte(`{"status": "success", "message": "Action processed"}`)) -} - -func main() { - log.SetFlags(0) - - err := run() - if err != nil { - log.Fatal(err) - } -} - func run() error { l, err := net.Listen("tcp", "127.0.0.1:8443") if err != nil { @@ -130,3 +56,53 @@ func run() error { return s.Shutdown(ctx) } + +// func (r *Room) rollDiceHandler(w http.ResponseWriter, req *http.Request) { +// if r.gameCtx.ValidateCanRoll(UUID) { +// r.gameCtx.RollDice() +// r.gameCtx.ProcessMovement() +// } +// } +// +// func (r *Room) endTurnHandler(w http.ResponseWriter, req *http.Request) { +// if r.gameCtx.ValidateCanEndTurn(UUID) { +// r.gameCtx.EndTurn() +// } +// } +// +// func (r *Room) exitJailHandler(w http.ResponseWriter, req *http.Request) { +// err := req.ParseForm() +// if err != nil { +// http.Error(w, "Bad Request: Failed to parse form data", http.StatusBadRequest) +// return +// } +// +// if !r.gameCtx.ValidateCanExitJail(UUID) { +// w.WriteHeader(http.StatusForbidden) +// w.Write([]byte(`{"status": "forbidden", "message": "Not your turn or not in jail"}`)) +// } +// +// method := req.PostForm.Get("method") +// +// switch method { +// case "buyout": +// err = r.gameCtx.JailBuyout() +// if err == game.ErrNotEnoughMoney { +// http.Error(w, "error: Insufficient funds", http.StatusUnprocessableEntity) +// } +// +// case "jail_free_card": +// err = r.gameCtx.JailUseCard() +// if err == game.ErrNotEnoughJailCards { +// http.Error(w, "error: Insufficient jail cards", http.StatusUnprocessableEntity) +// } +// default: +// w.WriteHeader(http.StatusBadRequest) +// w.Write([]byte(`{"status": "bad req", "message": "escape jail method does not exist"}`)) +// return +// } +// +// w.WriteHeader(http.StatusOK) +// w.Write([]byte(`{"status": "success", "message": "Action processed"}`)) +// } +//