Class GameLogic


  • @Component
    @Service
    @WithStateMachine
    public class GameLogic
    extends java.lang.Object
    • 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: