Class CaptainState
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.people.impl.CaptainState
-
-
Field Summary
Fields Modifier and Type Field Description private java.time.LocalDateTime
birthDate
private Date
date
private IDateService
dateService
private int
fightingSkill
private static RandomNameLoader
firstNameLoader
private static RandomNameLoader
lastNameLoader
private java.lang.String
name
private int
navigationSkill
private java.util.Random
rnd
private long
sailedDistance
private int
salary
private java.util.Optional<IShip>
ship
private static com.google.common.collect.Range<java.lang.Integer>
skillRange
private int
totalProfit
private int
tradingSkill
private static java.util.Map<java.lang.Integer,java.lang.Integer>
UPGRADE_FIGHT_LIMIT_LEVEL
Limits for the level that have to be reached before upgrading fighting skill.private static java.util.Map<java.lang.Integer,java.lang.Integer>
UPGRADE_NAVIGATION_LIMIT_LEVEL
Limits for the level that have to be reached before upgrading navigation skill.private static java.util.Map<java.lang.Integer,java.lang.Integer>
UPGRADE_TRADE_LIMIT_LEVEL
Limits for the level that have to be reached before upgrading.private int
wonFights
-
Constructor Summary
Constructors Constructor Description CaptainState()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assignToShip(IShip ship)
Assign a captain to a ship.int
getAge()
Current age of the captainjava.util.Optional<IShip>
getAssignedShip()
Get the ship the captain is assigned to.int
getFightSkillLevel()
Retrieve the level in sea fights between [0,5]java.lang.String
getName()
Retrieve the name of the captainint
getNavigationSkillLevel()
Retrieve the level in navigation between [0,5]int
getSalary()
Retrieve the salary per day.int
getTradingSkillLevel()
Retrieve the level in trading between [0,5]private void
init()
private void
setFightSkillLevel(int level)
Set the new fight skill level between [0..5]private void
setNavigationSkillLevel(int level)
Set the new navigation skill level between [0..5]void
setSalary(int salary)
Set the new salaryprivate void
setTradingSkillLevel(int level)
Set the new trading skill level between [0..5]void
updatedSailedDistance(int distance)
Add the sailed distance to the totalvoid
updateFightWon()
Increase the number of won fights.void
updateProfit(int profit)
Add the profit the total profit.boolean
upgradeToNextFightingLevel()
If possible upgrade the captain fight skill to the next level.boolean
upgradeToNextNavigationLevel()
If possible upgrade the captain to the next level on navigation skill.boolean
upgradeToNextTradeLevel()
Increase the experiance level by one.
-
-
-
Field Detail
-
date
@Autowired private Date date
-
dateService
@Autowired private IDateService dateService
-
rnd
@Autowired private java.util.Random rnd
-
birthDate
private java.time.LocalDateTime birthDate
-
name
private java.lang.String name
-
salary
private int salary
-
tradingSkill
private int tradingSkill
-
navigationSkill
private int navigationSkill
-
fightingSkill
private int fightingSkill
-
totalProfit
private int totalProfit
-
sailedDistance
private long sailedDistance
-
wonFights
private int wonFights
-
ship
private java.util.Optional<IShip> ship
-
skillRange
private static final com.google.common.collect.Range<java.lang.Integer> skillRange
-
UPGRADE_NAVIGATION_LIMIT_LEVEL
private static final java.util.Map<java.lang.Integer,java.lang.Integer> UPGRADE_NAVIGATION_LIMIT_LEVEL
Limits for the level that have to be reached before upgrading navigation skill.
-
UPGRADE_FIGHT_LIMIT_LEVEL
private static final java.util.Map<java.lang.Integer,java.lang.Integer> UPGRADE_FIGHT_LIMIT_LEVEL
Limits for the level that have to be reached before upgrading fighting skill.
-
UPGRADE_TRADE_LIMIT_LEVEL
private static final java.util.Map<java.lang.Integer,java.lang.Integer> UPGRADE_TRADE_LIMIT_LEVEL
Limits for the level that have to be reached before upgrading.
-
firstNameLoader
private static RandomNameLoader firstNameLoader
-
lastNameLoader
private static RandomNameLoader lastNameLoader
-
-
Method Detail
-
init
@PostConstruct private void init()
-
getAge
public int getAge()
Description copied from interface:ICaptain
Current age of the captain
-
getName
public java.lang.String getName()
Description copied from interface:ICaptain
Retrieve the name of the captain
-
getSalary
public int getSalary()
Description copied from interface:ICaptain
Retrieve the salary per day.
-
getTradingSkillLevel
public int getTradingSkillLevel()
Description copied from interface:ICaptain
Retrieve the level in trading between [0,5]- Specified by:
getTradingSkillLevel
in interfaceICaptain
- Returns:
- trading skill of the captain.
-
getNavigationSkillLevel
public int getNavigationSkillLevel()
Description copied from interface:ICaptain
Retrieve the level in navigation between [0,5]- Specified by:
getNavigationSkillLevel
in interfaceICaptain
- Returns:
- navigation skill of the captain
-
getFightSkillLevel
public int getFightSkillLevel()
Description copied from interface:ICaptain
Retrieve the level in sea fights between [0,5]- Specified by:
getFightSkillLevel
in interfaceICaptain
- Returns:
- fighting skill of the captain.
-
setTradingSkillLevel
private void setTradingSkillLevel(int level)
Set the new trading skill level between [0..5]- Parameters:
level
- trade skill level
-
setNavigationSkillLevel
private void setNavigationSkillLevel(int level)
Set the new navigation skill level between [0..5]- Parameters:
level
- navigation skill level
-
setFightSkillLevel
private void setFightSkillLevel(int level)
Set the new fight skill level between [0..5]- Parameters:
level
- fight skill level
-
setSalary
public void setSalary(int salary)
Set the new salary- Parameters:
salary
- salary of the captain.
-
assignToShip
public void assignToShip(IShip ship)
Description copied from interface:ICaptain
Assign a captain to a ship.- Specified by:
assignToShip
in interfaceICaptain
- Parameters:
ship
- to which the captain is assigned.
-
getAssignedShip
public java.util.Optional<IShip> getAssignedShip()
Get the ship the captain is assigned to.- Specified by:
getAssignedShip
in interfaceICaptain
- Returns:
- absent if the captain is not assigned to any ship.
-
upgradeToNextTradeLevel
public boolean upgradeToNextTradeLevel()
Description copied from interface:ICaptain
Increase the experiance level by one. The highest level i 5.- Specified by:
upgradeToNextTradeLevel
in interfaceICaptain
- Returns:
- true if upgrade happened.
-
updateProfit
public void updateProfit(int profit)
Description copied from interface:ICaptain
Add the profit the total profit.- Specified by:
updateProfit
in interfaceICaptain
- Parameters:
profit
- additional profit
-
updatedSailedDistance
public void updatedSailedDistance(int distance)
Description copied from interface:ICaptain
Add the sailed distance to the total- Specified by:
updatedSailedDistance
in interfaceICaptain
- Parameters:
distance
- additional distance
-
upgradeToNextNavigationLevel
public boolean upgradeToNextNavigationLevel()
Description copied from interface:ICaptain
If possible upgrade the captain to the next level on navigation skill.- Specified by:
upgradeToNextNavigationLevel
in interfaceICaptain
- Returns:
- true if upgrade happened
-
updateFightWon
public void updateFightWon()
Description copied from interface:ICaptain
Increase the number of won fights.- Specified by:
updateFightWon
in interfaceICaptain
-
upgradeToNextFightingLevel
public boolean upgradeToNextFightingLevel()
Description copied from interface:ICaptain
If possible upgrade the captain fight skill to the next level.- Specified by:
upgradeToNextFightingLevel
in interfaceICaptain
- Returns:
- true if an upgrade happened
-
-