Class CaptainsState
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.people.impl.CaptainsState
-
@Component @Lazy @DependentInitialisation(StartNewGameBean.class) public class CaptainsState extends java.lang.Object
Containing the states of the captains- Author:
- Andi Hotz, (c) Sahits GmbH, 2013 Created on Feb 2, 2013
-
-
Constructor Summary
Constructors Constructor Description CaptainsState()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCaptain(ICity city, java.time.LocalDateTime arrival, ICaptain captain)voidassignCaptainToCity(ICaptain captain, ICity city, java.time.LocalDateTime arrivalDate)Assign the captain to a new town.java.util.Optional<ICity>findCaptainsCurrentCity(ICaptain captain)Find the current city of a captain.java.util.List<ICaptain>getAllFreeCaptains()Retrieve a list of all captains that are not assigned to a town.java.time.LocalDateTimegetArrivalDate(ICaptain captain)Retrieve the arrival date of a captain in a town.java.util.Optional<ICaptain>getCaptain(ICity city)Return a captain for a town if there is one.intgetMaxDaysPresent()voidhireCaptain(ICaptain captain, ICity city)Remove the captain from the availables.
-
-
-
Method Detail
-
assignCaptainToCity
public void assignCaptainToCity(ICaptain captain, ICity city, java.time.LocalDateTime arrivalDate)
Assign the captain to a new town. The arrival there is delayed due to traveling time.- Parameters:
city- current town that the captain is leavingcaptain- which travels to a new town.
-
getCaptain
public java.util.Optional<ICaptain> getCaptain(ICity city)
Return a captain for a town if there is one. There may be more than one.- Parameters:
city- for which the captain is retrieved- Returns:
- absent if no captain is in the town.
-
getArrivalDate
public java.time.LocalDateTime getArrivalDate(ICaptain captain)
Retrieve the arrival date of a captain in a town. The captain must be present in a town, otherwise an IllegalStateException is thrown.- Parameters:
captain- captain residing in a town- Returns:
- time of his arrival.
-
hireCaptain
public void hireCaptain(ICaptain captain, ICity city)
Remove the captain from the availables.- Parameters:
captain- that is hired.city- where the captain was hired.
-
getAllFreeCaptains
public java.util.List<ICaptain> getAllFreeCaptains()
Retrieve a list of all captains that are not assigned to a town.- Returns:
- List of all free captains
-
findCaptainsCurrentCity
public java.util.Optional<ICity> findCaptainsCurrentCity(ICaptain captain)
Find the current city of a captain.- Parameters:
captain- for which city is checked- Returns:
- absent if the captain is in no town because he is hired on a ship.
-
getMaxDaysPresent
public int getMaxDaysPresent()
-
-