Class Turn


  • public class Turn
    extends java.lang.Object
    Represents a given turn in the game.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int seasonNumber
      The number of seasons.
      private static int seasonYear
      The year where the seasons split (1600 in Col1).
      private static int startingYear
      The starting year (1492 in Col1).
      private int turn
      The numerical value of the Turn, never less than one.
    • Constructor Summary

      Constructors 
      Constructor Description
      Turn​(int turn)
      Creates a new Turn instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      StringTemplate getLabel()
      Gets a localization template for this turn.
      int getNumber()
      Gets the turn number.
      java.lang.String getSaveGameSuffix()
      Get the suffix for a save game name for this turn.
      int getSeason()
      Gets the season index of this turn.
      static int getSeasonNumber()
      Gets the number of seasons.
      static int getSeasonYear()
      Gets the season year (the year the seasons split).
      static int getStartingYear()
      Gets the starting year.
      static StringTemplate getTurnLabel​(int turn)
      Gets a localization template for a given turn.
      static int getTurnSeason​(int turn)
      Gets the season index of the given turn number.
      static java.lang.String getTurnsText​(int turns)
      Gets a string describing the number of turns.
      static int getTurnYear​(int turn)
      Gets the year the given turn is in.
      int getYear()
      Gets the year this turn is in.
      int hashCode()
      static void initialize​(int newStartingYear, int newSeasonYear, int newSeasonNumber)
      Initialize the fundamental Turn year constants.
      boolean isFirstSeasonTurn()
      Is this turn the season year?
      boolean isFirstTurn()
      Is this turn the first one?
      Turn next()
      Get the next turn, with a turn number one greater.
      java.lang.String toString()
      static int yearToTurn​(int year)
      Converts a year to a turn number.
      static int yearToTurn​(int year, int season)
      Converts an integer year and specified season to a turn-integer-value.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • startingYear

        private static int startingYear
        The starting year (1492 in Col1).
      • seasonYear

        private static int seasonYear
        The year where the seasons split (1600 in Col1).
      • seasonNumber

        private static int seasonNumber
        The number of seasons.
      • turn

        private int turn
        The numerical value of the Turn, never less than one.
    • Constructor Detail

      • Turn

        public Turn​(int turn)
        Creates a new Turn instance.
        Parameters:
        turn - The numeric value of the turn.
    • Method Detail

      • initialize

        public static void initialize​(int newStartingYear,
                                      int newSeasonYear,
                                      int newSeasonNumber)
        Initialize the fundamental Turn year constants. Called from the spec cleanup when the values are available and checked.
        Parameters:
        newStartingYear - The starting year for the game.
        newSeasonYear - The year at which the seasons split.
        newSeasonNumber - The number of seasons in the year.
      • getStartingYear

        public static final int getStartingYear()
        Gets the starting year.
        Returns:
        The numeric value of the starting year.
      • getSeasonYear

        public static final int getSeasonYear()
        Gets the season year (the year the seasons split).
        Returns:
        The numeric value of the season year.
      • getSeasonNumber

        public static final int getSeasonNumber()
        Gets the number of seasons.
        Returns:
        The number of seasons.
      • yearToTurn

        public static int yearToTurn​(int year)
        Converts a year to a turn number.
        Parameters:
        year - The year to convert.
        Returns:
        The integer value of the corresponding turn.
      • yearToTurn

        public static int yearToTurn​(int year,
                                     int season)
        Converts an integer year and specified season to a turn-integer-value. Public for the test suite.
        Parameters:
        year - The year to convert.
        season - The season index.
        Returns:
        The integer value of the corresponding turn.
      • next

        public Turn next()
        Get the next turn, with a turn number one greater.
        Returns:
        The new Turn.
      • getNumber

        public int getNumber()
        Gets the turn number.
        Returns:
        The number of turns.
      • getYear

        public int getYear()
        Gets the year this turn is in.
        Returns:
        The calculated year based on the turn number.
      • getTurnYear

        public static int getTurnYear​(int turn)
        Gets the year the given turn is in. Public for the test suite.
        Parameters:
        turn - The turn number to get the year for.
        Returns:
        The calculated year based on the turn number.
      • getTurnSeason

        public static int getTurnSeason​(int turn)
        Gets the season index of the given turn number. Public for the test suite.
        Parameters:
        turn - The turn number to calculate from.
        Returns:
        The season index corresponding to the turn number or negative if before the season year.
      • getSeason

        public int getSeason()
        Gets the season index of this turn.
        Returns:
        The season index corresponding to the current turn number, or negative if before the season year.
      • getLabel

        public StringTemplate getLabel()
        Gets a localization template for this turn.
        Returns:
        A StringTemplate describing the turn.
      • getTurnLabel

        public static StringTemplate getTurnLabel​(int turn)
        Gets a localization template for a given turn.
        Parameters:
        turn - The integer value of the turn to describe.
        Returns:
        A StringTemplate describing the turn.
      • isFirstTurn

        public boolean isFirstTurn()
        Is this turn the first one?
        Returns:
        True if this turn is the first turn.
      • isFirstSeasonTurn

        public boolean isFirstSeasonTurn()
        Is this turn the season year?
        Returns:
        True if this turn is the season year.
      • getSaveGameSuffix

        public java.lang.String getSaveGameSuffix()
        Get the suffix for a save game name for this turn.
        Returns:
        The save game suffix.
      • getTurnsText

        public static java.lang.String getTurnsText​(int turns)
        Gets a string describing the number of turns.
        Parameters:
        turns - The number of turns.
        Returns:
        A descriptive string.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object