Class PlayerVsPlayerController
- java.lang.Object
-
- com.neven.ticTacToeGame.controller.PlayerVsPlayerController
-
@Controller @RequestMapping("game/players") @SessionAttributes("game") public class PlayerVsPlayerController extends java.lang.Object
ClassPlayerVsPlayerController
is a Spring Boot Controller class witch allow to serve HTTP requests from pages with Player versus Player game.
Path for requests "{pageContext}/game/players"- Author:
- Arterm Koliushko, https://www.linkedin.com/in/artem-koliushko/
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
GAME_MODEL_ATTRIBUTE_NAME
Constant with a name of the model attribute for game.private static java.lang.String
GAME_PAGE_NAME
Constant with a name of player versus algorithm game view.
-
Constructor Summary
Constructors Constructor Description PlayerVsPlayerController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) org.springframework.web.servlet.ModelAndView
game(org.springframework.ui.Model model, int cell)
Allow to serve HTTP requests for requests "{pageContext}/game/players" by method POST.(package private) org.springframework.web.servlet.ModelAndView
startGameWithPlayers()
Allow to serve HTTP requests for requests "{pageContext}/game/players" by method GET.
-
-
-
Field Detail
-
GAME_PAGE_NAME
private static final java.lang.String GAME_PAGE_NAME
Constant with a name of player versus algorithm game view.- See Also:
- Constant Field Values
-
GAME_MODEL_ATTRIBUTE_NAME
private static final java.lang.String GAME_MODEL_ATTRIBUTE_NAME
Constant with a name of the model attribute for game.- See Also:
- Constant Field Values
-
-
Method Detail
-
startGameWithPlayers
@GetMapping org.springframework.web.servlet.ModelAndView startGameWithPlayers()
Allow to serve HTTP requests for requests "{pageContext}/game/players" by method GET.- Returns:
ModelAndView
class with mane of the view of the Player versus Player game page with newPlayerVsPlayerGame
as aModel
attribute.
-
game
@PostMapping org.springframework.web.servlet.ModelAndView game(org.springframework.ui.Model model, @RequestParam("cell") int cell)
Allow to serve HTTP requests for requests "{pageContext}/game/players" by method POST. Method will receivePlayerVsPlayerGame
from model with number of cell where user want to make a move. MethodGame.winningCheckAndMakingMove(int)
will be called with user move. Current user will be changed andPlayerVsPlayerGame
will be returned asModel
attribute to Player versus Player game page view.- Parameters:
model
- Spring framework interface which carePlayerVsPlayerGame
as session attribute.cell
- Number of cell on game field with acceptable values 1-9 where user want to make his move- Returns:
ModelAndView
with name of Player versus Player game page view andPlayerVsPlayerGame
in model.
-
-