Class Player
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.impl.Player
-
- All Implemented Interfaces:
ICreditor
,ICitizen
,IPlayer
,IShipOwner
- Direct Known Subclasses:
AIPlayer
,HumanPlayer
public abstract class Player extends java.lang.Object implements IPlayer
-
-
Field Summary
Fields Modifier and Type Field Description private ICareer
careerLevel
private java.util.List<IChild>
children
private com.google.common.eventbus.AsyncEventBus
clientServerEventBus
private ICompany
company
private int
criminalDrive
private javafx.collections.ObservableList<IShip>
fleet
private LUIDProvider
luidProvider
private IPersonalData
personalData
private ESocialRank
rank
private MapSegmentedImage
segmentedMap
private javafx.collections.ObservableList<INavigableVessel>
selectableVessel
private java.util.Optional<ISpouseData>
spouse
private java.lang.String
uuid
-
Constructor Summary
Constructors Constructor Description Player(ICity homeTown, IPersonalData personalData, ESocialRank rank, ICompany company)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSelectableVessel(INavigableVessel vessel)
Add a selectable vessel to the list.void
addShip(IShip ship)
Add a new ship for the playerboolean
equals(java.lang.Object o)
java.util.List<IBuilding>
findBuildings(ICity city)
Find all buildings of the player in the city<T extends IBuilding>
java.util.List<T>findBuildings(ICity city, java.lang.Class<T> buildingClass)
Find all buildings in the city that are some subtype of the indicated classjava.util.List<INavigableVessel>
findShips(ICity city)
Find all ships in a cityjava.util.Optional<ITradingOffice>
findTradingOffice(ICity city)
Find the trading office of the player in the city.java.util.List<IShip>
getFleet()
Get a list of all shipsICity
getHometown()
Retreive the hometown of the citizen.java.lang.String
getLastName()
Get a players last namejava.lang.String
getName()
Retrieve the players nameIPersonalData
getPersonalData()
Retrieve the personal data of the playerjava.util.List<INavigableVessel>
getSelectableVessels()
Provide a different view on the fleet by containing all the vessels that can be selected.java.util.Optional<ISpouseData>
getSpouseData()
Retrieve the personal data of the players spouse.int
hashCode()
private void
init()
void
marry(ISpouseData spouse)
Marry a spousevoid
receiveSum(long amount)
Handle method for recieving a paymentvoid
removeSelectableVessel(INavigableVessel vessel)
Remove a selectable vessel from the list.void
removeShip(IShip ship)
Remove a ship for the playervoid
spouseDies()
Widow and become unmarried again.java.lang.String
toString()
void
updateCrimialDrive(int value)
Update the new value indicating the level of criminallity of the playervoid
updateRank(ESocialRank rank)
Update to the new social rank-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ch.sahits.game.openpatrician.model.IPlayer
getCareerLevel, getChildren, getCompany, getCriminalDrive, getSegmentedMap, getUuid, setCareerLevel, setSegmentedMap
-
-
-
-
Field Detail
-
uuid
private java.lang.String uuid
-
fleet
private final javafx.collections.ObservableList<IShip> fleet
-
selectableVessel
private final javafx.collections.ObservableList<INavigableVessel> selectableVessel
-
rank
private ESocialRank rank
-
careerLevel
private ICareer careerLevel
-
personalData
private IPersonalData personalData
-
spouse
private java.util.Optional<ISpouseData> spouse
-
company
private final ICompany company
-
segmentedMap
private MapSegmentedImage segmentedMap
-
clientServerEventBus
@Autowired @Qualifier("serverClientEventBus") private com.google.common.eventbus.AsyncEventBus clientServerEventBus
-
luidProvider
@Autowired private LUIDProvider luidProvider
-
criminalDrive
private int criminalDrive
-
children
private java.util.List<IChild> children
-
-
Constructor Detail
-
Player
public Player(ICity homeTown, IPersonalData personalData, ESocialRank rank, ICompany company)
-
-
Method Detail
-
init
@PostConstruct @IgnoreOnDeserialisation private void init()
-
getName
public java.lang.String getName()
Description copied from interface:ICitizen
Retrieve the players name- Specified by:
getName
in interfaceICitizen
- Specified by:
getName
in interfaceIShipOwner
- Returns:
- first name of the citizen.
-
getLastName
public java.lang.String getLastName()
Description copied from interface:ICitizen
Get a players last name- Specified by:
getLastName
in interfaceICitizen
- Specified by:
getLastName
in interfaceIShipOwner
- Returns:
- last name of the citizen
-
getHometown
public ICity getHometown()
Description copied from interface:ICitizen
Retreive the hometown of the citizen.- Specified by:
getHometown
in interfaceICitizen
- Returns:
- home city of the citizen.
-
getFleet
public java.util.List<IShip> getFleet()
Description copied from interface:IPlayer
Get a list of all ships
-
getSelectableVessels
public java.util.List<INavigableVessel> getSelectableVessels()
Description copied from interface:IPlayer
Provide a different view on the fleet by containing all the vessels that can be selected.- Specified by:
getSelectableVessels
in interfaceIPlayer
- Returns:
- list of vessels that can be activated.
-
addSelectableVessel
public void addSelectableVessel(INavigableVessel vessel)
Description copied from interface:IPlayer
Add a selectable vessel to the list.- Specified by:
addSelectableVessel
in interfaceIPlayer
- Parameters:
vessel
- to be added
-
removeSelectableVessel
public void removeSelectableVessel(INavigableVessel vessel)
Description copied from interface:IPlayer
Remove a selectable vessel from the list.- Specified by:
removeSelectableVessel
in interfaceIPlayer
- Parameters:
vessel
- to be removed.
-
addShip
public void addShip(IShip ship)
Description copied from interface:IPlayer
Add a new ship for the player
-
removeShip
public void removeShip(IShip ship)
Description copied from interface:IPlayer
Remove a ship for the player- Specified by:
removeShip
in interfaceIPlayer
- Parameters:
ship
- to be removed from the fleet.
-
findBuildings
public java.util.List<IBuilding> findBuildings(ICity city)
Description copied from interface:IPlayer
Find all buildings of the player in the city- Specified by:
findBuildings
in interfaceIPlayer
- Parameters:
city
- where to search for buildings.- Returns:
- list of buildings in
city
owned by the player.
-
findTradingOffice
public java.util.Optional<ITradingOffice> findTradingOffice(ICity city)
Description copied from interface:IPlayer
Find the trading office of the player in the city.- Specified by:
findTradingOffice
in interfaceIPlayer
- Parameters:
city
- where to look for a trading office- Returns:
- Optional trading office. Empty if there is none in the
city
.
-
findBuildings
public <T extends IBuilding> java.util.List<T> findBuildings(ICity city, java.lang.Class<T> buildingClass)
Description copied from interface:IPlayer
Find all buildings in the city that are some subtype of the indicated class- Specified by:
findBuildings
in interfaceIPlayer
- Parameters:
city
- in which to look for buildingsbuildingClass
- class of the building that is searched- Returns:
- type cast list of the buildings in
city
.
-
marry
public void marry(ISpouseData spouse)
Marry a spouse
-
spouseDies
public void spouseDies()
Description copied from interface:IPlayer
Widow and become unmarried again.- Specified by:
spouseDies
in interfaceIPlayer
-
getPersonalData
public IPersonalData getPersonalData()
Description copied from interface:IPlayer
Retrieve the personal data of the player- Specified by:
getPersonalData
in interfaceIPlayer
- Returns:
- personal data of the player.
-
getSpouseData
public java.util.Optional<ISpouseData> getSpouseData()
Description copied from interface:IPlayer
Retrieve the personal data of the players spouse.- Specified by:
getSpouseData
in interfaceIPlayer
- Returns:
- Optional spouse data. Empty if the player is not married.
-
updateRank
public void updateRank(ESocialRank rank)
Description copied from interface:IPlayer
Update to the new social rank- Specified by:
updateRank
in interfaceIPlayer
- Parameters:
rank
- new social rank.
-
findShips
public java.util.List<INavigableVessel> findShips(ICity city)
Description copied from interface:IPlayer
Find all ships in a city
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
receiveSum
public void receiveSum(long amount)
Description copied from interface:ICreditor
Handle method for recieving a payment- Specified by:
receiveSum
in interfaceICreditor
- Parameters:
amount
- paid money amount.
-
updateCrimialDrive
public void updateCrimialDrive(int value)
Description copied from interface:IPlayer
Update the new value indicating the level of criminallity of the player- Specified by:
updateCrimialDrive
in interfaceIPlayer
- Parameters:
value
- new criminal drive value.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-