Package net.sf.freecol.server.model
Class NativeDemandSession
- java.lang.Object
-
- net.sf.freecol.server.model.Session
-
- net.sf.freecol.server.model.TimedSession
-
- net.sf.freecol.server.model.NativeDemandSession
-
public class NativeDemandSession extends TimedSession
A type of session to handle trading with a native settlement.
-
-
Constructor Summary
Constructors Constructor Description NativeDemandSession(Unit unit, Colony colony, GoodsType goodsType, int amount, long timeout)
Creates a newNativeDemandSession
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
complete(boolean result)
Complete this task with the given result.boolean
complete(boolean result, ChangeSet cs)
Explicit completion of the session with a given result.boolean
complete(ChangeSet cs)
All transaction types must implement a completion action.private void
completeInternal(boolean result, ChangeSet cs)
Primitive level to finishing the session with the given result.private ServerPlayer
getColonyOwner()
private ServerGame
getGame()
Get the game.private ServerPlayer
getUnitOwner()
java.lang.String
toString()
-
Methods inherited from class net.sf.freecol.server.model.TimedSession
cancel
-
Methods inherited from class net.sf.freecol.server.model.Session
clearAll, completeAll, findSession, getKey, lookup, lookup, lookup, makeSessionKey, makeSessionKey, register
-
-
-
-
Constructor Detail
-
NativeDemandSession
public NativeDemandSession(Unit unit, Colony colony, GoodsType goodsType, int amount, long timeout)
Creates a newNativeDemandSession
.- Parameters:
unit
- TheUnit
making the demand.colony
- TheColony
where the demand is made.goodsType
- TheGoodsType
to demand.amount
- The amount of goods.timeout
- The amount of time to wait for a response.
-
-
Method Detail
-
getColonyOwner
private ServerPlayer getColonyOwner()
-
getUnitOwner
private ServerPlayer getUnitOwner()
-
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
- AChangeSet
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
- AChangeSet
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 classTimedSession
- 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 classTimedSession
- Parameters:
cs
- AChangeSet
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 classjava.lang.Object
-
-