rails.game.action
Class SetDividend

java.lang.Object
  extended by rails.game.action.PossibleAction
      extended by rails.game.action.PossibleORAction
          extended by rails.game.action.SetDividend
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class SetDividend
extends PossibleORAction
implements java.lang.Cloneable

Action class that comprises the earnings setting and distribution steps. In the current versions, the earnings must always be calculated and entered by the user. In a later version, the earnings may have been calculated by the back-end; in that case, the user can only select the earnings distribution method.

Author:
Erik Vos
See Also:
Serialized Form

Field Summary
protected  int actualRevenue
          The revenue as set (or accepted, or just seen) by the user.
static java.lang.String[] allocationNameKeys
          Allocation name keys in the resource bundle
protected  int[] allowedRevenueAllocations
          The revenue allocations that the user may select from.
protected  boolean mayUserSetRevenue
          Is the user allowed to set the revenue? Currently, this will aways be true, except if the company has no trains (the revenue is then 0).
static int NO_TRAIN
           
static int NUM_OPTIONS
           
static int PAYOUT
           
protected  int presetRevenue
          The revenue as proposed by the back-end.
protected  int requiredCash
          Cash that should be minimally raised as revenue (for instance, to pay loan interest as in 1856).
protected  int revenueAllocation
          The revenue destination selected by the user (if he has a choice at all).
static long serialVersionUID
           
static int SPLIT
           
static int UNKNOWN
           
static int WITHHOLD
           
 
Fields inherited from class rails.game.action.PossibleORAction
company, companyName
 
Fields inherited from class rails.game.action.PossibleAction
acted, gameManager, log, playerIndex, playerName
 
Constructor Summary
  SetDividend(int presetRevenue, boolean mayUserSetRevenue, int[] allowedAllocations)
           
  SetDividend(int presetRevenue, boolean mayUserSetRevenue, int[] allowedAllocations, int requiredCash)
           
protected SetDividend(SetDividend action)
          Clone an instance (used by clone)
 
Method Summary
 java.lang.Object clone()
           
 boolean equalsAsAction(PossibleAction action)
          Compare the chosen actions of two action objects.
 boolean equalsAsOption(PossibleAction action)
          Compare the choice options of two action objects, without regard to whatever choice has been made, if any.
 int getActualRevenue()
           
static java.lang.String getAllocationNameKey(int allocationType)
           
 int[] getAllowedAllocations()
           
 int getPresetRevenue()
           
 int getRequiredCash()
           
 int getRevenueAllocation()
           
 boolean isAllocationAllowed(int allocationType)
           
 void setActualRevenue(int revenue)
           
 void setRevenueAllocation(int allocation)
           
 java.lang.String toString()
           
 
Methods inherited from class rails.game.action.PossibleORAction
getCompany, getCompanyName, setCompany
 
Methods inherited from class rails.game.action.PossibleAction
getCompanyManager, getGameManager, getPlayerIndex, getPlayerName, hasActed, setActed, setPlayerName, toMenu
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values

WITHHOLD

public static final int WITHHOLD
See Also:
Constant Field Values

SPLIT

public static final int SPLIT
See Also:
Constant Field Values

PAYOUT

public static final int PAYOUT
See Also:
Constant Field Values

NO_TRAIN

public static final int NO_TRAIN
See Also:
Constant Field Values

NUM_OPTIONS

public static final int NUM_OPTIONS
See Also:
Constant Field Values

allocationNameKeys

public static final java.lang.String[] allocationNameKeys
Allocation name keys in the resource bundle


presetRevenue

protected int presetRevenue
The revenue as proposed by the back-end. Currently this is always the previous revenue. In the future, this could be the calculated revenue.


mayUserSetRevenue

protected boolean mayUserSetRevenue
Is the user allowed to set the revenue? Currently, this will aways be true, except if the company has no trains (the revenue is then 0). In the future, it will only be true if the user has some influence on it (e.g., in 1844, the user may opt for less that maximum revenue is some cases).


allowedRevenueAllocations

protected int[] allowedRevenueAllocations
The revenue allocations that the user may select from. If only one value is provided, the user has no option (e.g. minor companies always split in most games).


requiredCash

protected int requiredCash
Cash that should be minimally raised as revenue (for instance, to pay loan interest as in 1856). If actual revenue is below this value, the dividend will be zero, and no dividend allocation should be requested.


actualRevenue

protected int actualRevenue
The revenue as set (or accepted, or just seen) by the user.


revenueAllocation

protected int revenueAllocation
The revenue destination selected by the user (if he has a choice at all).


serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

SetDividend

public SetDividend(int presetRevenue,
                   boolean mayUserSetRevenue,
                   int[] allowedAllocations)

SetDividend

public SetDividend(int presetRevenue,
                   boolean mayUserSetRevenue,
                   int[] allowedAllocations,
                   int requiredCash)

SetDividend

protected SetDividend(SetDividend action)
Clone an instance (used by clone)

Method Detail

getPresetRevenue

public int getPresetRevenue()

setActualRevenue

public void setActualRevenue(int revenue)

getActualRevenue

public int getActualRevenue()

getAllowedAllocations

public int[] getAllowedAllocations()

isAllocationAllowed

public boolean isAllocationAllowed(int allocationType)

getRequiredCash

public int getRequiredCash()

setRevenueAllocation

public void setRevenueAllocation(int allocation)

getRevenueAllocation

public int getRevenueAllocation()

getAllocationNameKey

public static java.lang.String getAllocationNameKey(int allocationType)

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

equalsAsOption

public boolean equalsAsOption(PossibleAction action)
Description copied from class: PossibleAction
Compare the choice options of two action objects, without regard to whatever choice has been made, if any. In other words: only the server-set (prior) attributes must be compared.

This method is used by the server (engine) to validate the incoming action that has actually been chosen in the client (GUI), but only for the purpose to check if the chosen option was really on offer, not to check if the chosen action is actually valid. These perspectives could give different results in cases where the PossibleAction does not fully restrict choices to valid values only (such as the blanket LayTile that does no restrict the hex to lay a tile on, or the SetDividend that will accept any revenue value).

Specified by:
equalsAsOption in class PossibleAction
Parameters:
action - Another PossibleAction to compare with.
Returns:
True if the compared PossibleAction object has equal choice options.

equalsAsAction

public boolean equalsAsAction(PossibleAction action)
Description copied from class: PossibleAction
Compare the chosen actions of two action objects. In other words: the client-set (posterior) attributes must be compared, in addition to those server-set (prior) attributes that sufficiently identify the action.

This method is used by the server (engine) to check if two action objects represent the same actual action, as is done when reloading a saved file (i.e. loading a later stage of the same game).

Specified by:
equalsAsAction in class PossibleAction
Parameters:
action - Another PossibleAction to compare with.
Returns:
True if the compared PossibleAction object has equal selected action values.

toString

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