Class RoulettePost
java.lang.Object
io.github.sigmacasino.HTTPRoute
io.github.sigmacasino.PostRoute
io.github.sigmacasino.routes.games.RoulettePost
- All Implemented Interfaces:
spark.Route
Handles the "/games/roulette" POST request, processing user bets, updating the user's balance,
and registering a new roulette game result. Redirects the user to the replay page with the game results.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.slf4j.Logger
The logger for the RoulettePost class.A map of roulette numbers and their corresponding colors.Fields inherited from class io.github.sigmacasino.HTTPRoute
app, loginRequired, path
-
Constructor Summary
ConstructorsConstructorDescriptionRoulettePost
(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 roulette game.Methods inherited from class io.github.sigmacasino.PostRoute
handle, parseBodyParams, registerSparkRoute
-
Field Details
-
logger
private org.slf4j.Logger loggerThe logger for the RoulettePost class. -
rouletteItems
A map of roulette numbers and their corresponding colors.
-
-
Constructor Details
-
RoulettePost
Initializes the route handler with the app instance and sets the route path. Also initializes the roulette items map with predefined colors for each number.- Parameters:
app
- The main application instance.
-
-
Method Details
-
handlePost
Handles the POST request for the roulette game. It validates the user's balance, simulates the roulette spin, stores the result in the database, and updates the user's balance. Finally, it redirects the user to the replay page with the game result.- 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.
-