Class GameLogic
- java.lang.Object
-
- edu.cnm.deepdive.dominionendpointtestspring.service.GameLogic
-
@Component @Service @WithStateMachine public class GameLogic extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description GameLogic(GameRepository gameRepository, TurnRepository turnRepository, PlayRepository playRepository, PlayerRepository playerRepository, CardRepository cardRepository, GamePlayerRepository gamePlayerRepository)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Game
buyCard(java.lang.String cardType, Game game, Player player)
This method performs actions to buy a card.Game
discardForMilitia(Game game, Player player, java.util.List<java.lang.String> cardStrings)
This card performs the discarding functions when a player is attacked.Game
endPhase(Game game, Player player)
This method ends the current phase, called from GameController.Turn
getCurrentTurn(Game game)
This method gets the current turn.java.util.List<java.lang.String>
getListOfPlaysStrings(Game game)
This returns a list of Strings describing the plays from last turn.Turn
getPreviousTurn(Game game)
This method gets the previous turn.Game
initializeGame(Game game, Player player1, Player player2)
This method sets up the initial conditions for a game.Game
playCard(java.lang.String cardType, Game game, Player player)
This is an overload of the other playCard method which functions if no additional cards have been passed in as arguments.Game
playCard(java.lang.String cardType, Game game, Player player, java.util.ArrayList<java.lang.String> cardStrings)
This method plays a card.
-
-
-
Constructor Detail
-
GameLogic
@Autowired public GameLogic(GameRepository gameRepository, TurnRepository turnRepository, PlayRepository playRepository, PlayerRepository playerRepository, CardRepository cardRepository, GamePlayerRepository gamePlayerRepository)
-
-
Method Detail
-
getCurrentTurn
public Turn getCurrentTurn(Game game)
This method gets the current turn. It is a helper method used in several gameLogic functions.- Parameters:
game
-- Returns:
-
getPreviousTurn
public Turn getPreviousTurn(Game game)
This method gets the previous turn. It is a helper method used in several gameLogic functions.- Parameters:
game
-- Returns:
-
playCard
public Game playCard(java.lang.String cardType, Game game, Player player, java.util.ArrayList<java.lang.String> cardStrings)
This method plays a card. It calls the helper methods to calculate the change in player, turn, and game state, and returns a Game object to the player.- Parameters:
cardType
-game
-player
-cardStrings
-- Returns:
-
playCard
public Game playCard(java.lang.String cardType, Game game, Player player)
This is an overload of the other playCard method which functions if no additional cards have been passed in as arguments.- Parameters:
cardType
-game
-player
-- Returns:
-
buyCard
public Game buyCard(java.lang.String cardType, Game game, Player player)
This method performs actions to buy a card.- Parameters:
cardType
-game
-player
-- Returns:
-
endPhase
public Game endPhase(Game game, Player player)
This method ends the current phase, called from GameController.- Parameters:
game
-player
-- Returns:
-
discardForMilitia
public Game discardForMilitia(Game game, Player player, java.util.List<java.lang.String> cardStrings)
This card performs the discarding functions when a player is attacked.- Parameters:
game
-player
-cardStrings
-- Returns:
-
initializeGame
public Game initializeGame(Game game, Player player1, Player player2)
This method sets up the initial conditions for a game.- Parameters:
game
-player1
-player2
-- Returns:
-
getListOfPlaysStrings
public java.util.List<java.lang.String> getListOfPlaysStrings(Game game)
This returns a list of Strings describing the plays from last turn.- Parameters:
game
-- Returns:
-
-