Class HorsesPost
java.lang.Object
io.github.sigmacasino.HTTPRoute
io.github.sigmacasino.PostRoute
io.github.sigmacasino.routes.games.HorsesPost
- All Implemented Interfaces:
spark.Route
Handles the "/games/horses" POST request, managing user bets, updating the user's balance,
and registering a new horse racing game. It also redirects to the replay page with the game results.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.slf4j.Logger
The logger used to log the user's horse racing games.Fields inherited from class io.github.sigmacasino.HTTPRoute
app, loginRequired, path
-
Constructor Summary
ConstructorsConstructorDescriptionHorsesPost
(App app) Initializes the route handler with the app instance and sets the route path. -
Method Summary
Modifier and TypeMethodDescriptionvoid
handlePost
(spark.Request request, spark.Response response) Handles the POST request for the horse racing game.Methods inherited from class io.github.sigmacasino.PostRoute
handle, parseBodyParams, registerSparkRoute
-
Field Details
-
logger
private org.slf4j.Logger loggerThe logger used to log the user's horse racing games.
-
-
Constructor Details
-
HorsesPost
Initializes the route handler with the app instance and sets the route path.- Parameters:
app
- The main application instance.
-
-
Method Details
-
handlePost
Handles the POST request for the horse racing game. It validates user balance, generates random race data according to the database schema, stores the result in the database, and updates the user's balance based on the outcome of the game. Redirects the user to the replay page with the race results.- Specified by:
handlePost
in classPostRoute
- Parameters:
request
- The HTTP request containing the game parameters.response
- The HTTP response used to redirect the user.- Throws:
SQLException
- If any errors occur during the request handling.
-