]> Skullheadx's Git Forge - monopoly-web.git/commitdiff
fix merge conflicts
authorSkullheadx <admonty1@protonmail.com>
Mon, 8 Jun 2026 02:04:50 +0000 (22:04 -0400)
committerSkullheadx <admonty1@protonmail.com>
Mon, 8 Jun 2026 02:04:50 +0000 (22:04 -0400)
main.go

diff --git a/main.go b/main.go
index b718378bcde3ac1b7cc6378ef56cb28dd044f854..42fb8d649f32d0d8140b8a33ff351dd496d7c40a 100644 (file)
--- 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"}`))
+// }
+//