Class ContractBrokers
- java.lang.Object
-
- ch.sahits.game.openpatrician.engine.land.city.ContractBrokers
-
- All Implemented Interfaces:
IContractBrokers
@Component public class ContractBrokers extends java.lang.Object implements IContractBrokers
List of all contract brokers- Author:
- Andi Hotz, (c) Sahits GmbH, 2018 Created on Apr 30, 2018
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<ContractBrokerConnections>
brokers
private com.google.common.eventbus.AsyncEventBus
clientServerEventBus
private DialogTemplateFactory
dialogTemplateFactory
private ModelTranslations
translationService
-
Constructor Summary
Constructors Constructor Description ContractBrokers()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(IContractBroker broker, ICity city)
void
assignPlayer(IPlayer player, IContractBroker broker, java.time.LocalDateTime deadline)
Assign a player to a contract broker.java.util.Optional<IContractBroker>
findContractBroker(ICity city, IPlayer player)
Retrieve the contract broker in the city, who is waiting for a delivery by the player.boolean
hasContractBroker(ICity city)
Check if there is a contract broker defined for the city.private void
init()
void
remove(IContractBroker broker)
Remove the connections matching a specific broker.void
removePastDeadline(PeriodicalDailyUpdate event)
Daily checking if the deadline has passed.
-
-
-
Field Detail
-
brokers
private java.util.List<ContractBrokerConnections> brokers
-
clientServerEventBus
@Autowired @Qualifier("serverClientEventBus") private com.google.common.eventbus.AsyncEventBus clientServerEventBus
-
translationService
@Autowired private ModelTranslations translationService
-
dialogTemplateFactory
@Autowired private DialogTemplateFactory dialogTemplateFactory
-
-
Method Detail
-
init
@PostConstruct private void init()
-
add
public void add(IContractBroker broker, ICity city)
- Specified by:
add
in interfaceIContractBrokers
-
assignPlayer
public void assignPlayer(IPlayer player, IContractBroker broker, java.time.LocalDateTime deadline)
Assign a player to a contract broker.- Parameters:
player
- to be assignedbroker
- to whom the player is assigned.deadline
- until when the wares have to be delivered.
-
remove
public void remove(IContractBroker broker)
Remove the connections matching a specific broker.- Parameters:
broker
- to be removed.
-
removePastDeadline
public void removePastDeadline(PeriodicalDailyUpdate event)
Daily checking if the deadline has passed.- Parameters:
event
-
-
findContractBroker
public java.util.Optional<IContractBroker> findContractBroker(ICity city, IPlayer player)
Description copied from interface:IContractBrokers
Retrieve the contract broker in the city, who is waiting for a delivery by the player.- Specified by:
findContractBroker
in interfaceIContractBrokers
- Parameters:
city
- for which to look up the contract broker.player
- from whom the broker awaits d deliver.- Returns:
- optional of the broker, if one is found, empty otherwise.
-
hasContractBroker
public boolean hasContractBroker(ICity city)
Description copied from interface:IContractBrokers
Check if there is a contract broker defined for the city. It does not matter, if the broker has an assigned player or not.- Specified by:
hasContractBroker
in interfaceIContractBrokers
- Parameters:
city
- for which to check the contract broker- Returns:
- true if there is a contract broker defined for the city.
-
-