Class CityPlayerProxyJFX
- java.lang.Object
-
- ch.sahits.game.openpatrician.display.model.CityPlayerProxyJFX
-
- All Implemented Interfaces:
ICityPlayerProxyJFX
public class CityPlayerProxyJFX extends java.lang.Object implements ICityPlayerProxyJFX
State information of the player, the city and the ships. This instance is tied to the ClientViewState.
-
-
Field Summary
Fields Modifier and Type Field Description private javafx.beans.property.ObjectProperty<INavigableVessel>
activeShip
Reference the active ship of the playerprivate javafx.beans.property.ObjectProperty<ICity>
city
private com.google.common.eventbus.AsyncEventBus
clientEventBus
private com.google.common.eventbus.AsyncEventBus
clientServerEventBus
private DependentAnnotationConfigApplicationContext
context
private IHumanPlayer
player
private javafx.beans.binding.ListBinding<IShip>
playersShips
private javafx.collections.ObservableList<INavigableVessel>
playersVessels
List holding all ships owned by the player currently present in the city
-
Constructor Summary
Constructors Constructor Description CityPlayerProxyJFX(ICity city, IHumanPlayer player, INavigableVessel activeShip)
/** Constructor initializing the city and the player with one ship in port.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateShip(INavigableVessel ship)
Activate a ship.javafx.beans.property.ObjectProperty<INavigableVessel>
activeShipProperty()
Property holding the active ship.void
arrive(INavigableVessel ship)
A ship arrives in the cityjavafx.beans.property.ObjectProperty<ICity>
cityProperty()
Current city property.INavigableVessel
getActiveShip()
Retrieve the players active vesselICity
getCity()
Retrieve the city reference.javafx.collections.ObservableList<INavigableVessel>
getPlayersNavalVessels()
Retrieve the list of all ships of the player currently in the port.javafx.collections.ObservableList<IShip>
getPlayersShips()
Retrieve the actual ships of the player.void
handleShipBecomesUnavailable(ShipBecomesUnavailableEvent event)
void
handleShipConstructionFinished(ShipConstructionFinishedEvent event)
Handle the event where a ships construction is finished, by adding the ship to the players ships, if the city is the current city.void
handleShipEntersPort(ShipEntersPortEvent event)
void
handleShipLeavesPort(ShipLeavingPort event)
void
leave(INavigableVessel ship)
Ship leave the cityvoid
postLoad()
Execute after savegame was loaded triggered from the ClientViewState.private void
register()
void
setCity(ICity city)
Set the current city.private void
unregister()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ch.sahits.game.openpatrician.clientserverinterface.client.ICityPlayerProxyJFX
getPlayer
-
-
-
-
Field Detail
-
city
private javafx.beans.property.ObjectProperty<ICity> city
-
player
private IHumanPlayer player
-
playersVessels
private javafx.collections.ObservableList<INavigableVessel> playersVessels
List holding all ships owned by the player currently present in the city
-
playersShips
private javafx.beans.binding.ListBinding<IShip> playersShips
-
clientServerEventBus
@Autowired @Qualifier("serverClientEventBus") private com.google.common.eventbus.AsyncEventBus clientServerEventBus
-
clientEventBus
@Autowired @Qualifier("clientEventBus") private com.google.common.eventbus.AsyncEventBus clientEventBus
-
activeShip
private javafx.beans.property.ObjectProperty<INavigableVessel> activeShip
Reference the active ship of the player
-
context
@Autowired private DependentAnnotationConfigApplicationContext context
-
-
Constructor Detail
-
CityPlayerProxyJFX
public CityPlayerProxyJFX(ICity city, IHumanPlayer player, INavigableVessel activeShip)
/** Constructor initializing the city and the player with one ship in port.- Parameters:
city
- behind the proxyplayer
- human player behind the proxyactiveShip
- active ship behind the proxy.
-
-
Method Detail
-
register
@PostConstruct private void register()
-
unregister
@PreDestroy private void unregister()
-
activateShip
public void activateShip(INavigableVessel ship)
Activate a ship. If the ship is not one of the players or not in port or not available anIllegalArgumentException
will be thrown- Specified by:
activateShip
in interfaceICityPlayerProxyJFX
- Parameters:
ship
- that is to be activated.- Throws:
java.lang.IllegalArgumentException
- if the ship cannot be activated due to its non existence
-
getPlayersNavalVessels
public javafx.collections.ObservableList<INavigableVessel> getPlayersNavalVessels()
Description copied from interface:ICityPlayerProxyJFX
Retrieve the list of all ships of the player currently in the port. This list may also contain for examples convoys that are not owned by the player, but the player has a ship in that convoy.- Specified by:
getPlayersNavalVessels
in interfaceICityPlayerProxyJFX
- Returns:
- list of the players ships
-
arrive
public void arrive(INavigableVessel ship)
A ship arrives in the city- Specified by:
arrive
in interfaceICityPlayerProxyJFX
- Parameters:
ship
- that arrives
-
leave
public void leave(INavigableVessel ship)
Ship leave the city- Specified by:
leave
in interfaceICityPlayerProxyJFX
- Parameters:
ship
- that leaves
-
getPlayersShips
public javafx.collections.ObservableList<IShip> getPlayersShips()
Description copied from interface:ICityPlayerProxyJFX
Retrieve the actual ships of the player.- Specified by:
getPlayersShips
in interfaceICityPlayerProxyJFX
- Returns:
- Observable list of the player's ships.
-
handleShipLeavesPort
public void handleShipLeavesPort(ShipLeavingPort event)
-
handleShipEntersPort
public void handleShipEntersPort(ShipEntersPortEvent event)
-
handleShipBecomesUnavailable
public void handleShipBecomesUnavailable(ShipBecomesUnavailableEvent event)
-
postLoad
public void postLoad()
Execute after savegame was loaded triggered from the ClientViewState.
-
getActiveShip
public INavigableVessel getActiveShip()
Description copied from interface:ICityPlayerProxyJFX
Retrieve the players active vessel- Specified by:
getActiveShip
in interfaceICityPlayerProxyJFX
- Returns:
- currently active vessel.
-
activeShipProperty
public javafx.beans.property.ObjectProperty<INavigableVessel> activeShipProperty()
Description copied from interface:ICityPlayerProxyJFX
Property holding the active ship.- Specified by:
activeShipProperty
in interfaceICityPlayerProxyJFX
- Returns:
- Object property of the active vessel.
-
getCity
public ICity getCity()
Description copied from interface:ICityPlayerProxyJFX
Retrieve the city reference.- Specified by:
getCity
in interfaceICityPlayerProxyJFX
- Returns:
- current city.
-
cityProperty
public javafx.beans.property.ObjectProperty<ICity> cityProperty()
Description copied from interface:ICityPlayerProxyJFX
Current city property.- Specified by:
cityProperty
in interfaceICityPlayerProxyJFX
-
setCity
public void setCity(ICity city)
Description copied from interface:ICityPlayerProxyJFX
Set the current city.- Specified by:
setCity
in interfaceICityPlayerProxyJFX
- Parameters:
city
- which to set.
-
handleShipConstructionFinished
public void handleShipConstructionFinished(ShipConstructionFinishedEvent event)
Handle the event where a ships construction is finished, by adding the ship to the players ships, if the city is the current city. At this point the new ship has been added to the fleet.- Parameters:
event
- for the finishing of a ship construction
-
-