Class NativeDemandSession


  • public class NativeDemandSession
    extends TimedSession
    A type of session to handle trading with a native settlement.
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • unit

        private Unit unit
      • colony

        private Colony colony
      • amount

        private int amount
    • Constructor Detail

      • NativeDemandSession

        public NativeDemandSession​(Unit unit,
                                   Colony colony,
                                   GoodsType goodsType,
                                   int amount,
                                   long timeout)
        Creates a new NativeDemandSession.
        Parameters:
        unit - The Unit making the demand.
        colony - The Colony where the demand is made.
        goodsType - The GoodsType to demand.
        amount - The amount of goods.
        timeout - The amount of time to wait for a response.
    • Method Detail

      • getGame

        private ServerGame getGame()
        Get the game.
        Returns:
        The ServerGame.
      • completeInternal

        private void completeInternal​(boolean result,
                                      ChangeSet cs)
        Primitive level to finishing the session with the given result.
        Parameters:
        result - The result of the demand.
        cs - A ChangeSet to update.
      • complete

        public boolean complete​(boolean result,
                                ChangeSet cs)
        Explicit completion of the session with a given result. Called from the controller when the player returns a definite response.
        Parameters:
        result - Whether to accept or reject the demand.
        cs - A ChangeSet to update.
        Returns:
        Whether the session was already complete.
      • complete

        protected boolean complete​(boolean result)
        Complete this task with the given result. By default this will be called (with value == false) when the timer expires.
        Specified by:
        complete in class TimedSession
        Parameters:
        result - The result to complete the session with.
        Returns:
        The result of the session.
      • complete

        public boolean complete​(ChangeSet cs)
        All transaction types must implement a completion action. This is called by the controller at the end of turn to complete any sessions that have not yet completed, or if the controller gets the required response to complete the session.
        Overrides:
        complete in class TimedSession
        Parameters:
        cs - A ChangeSet to update with changes that occur when completing this session.
        Returns:
        True if the session was already complete.
      • toString

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