Class WeaponsDealerState
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.people.impl.WeaponsDealerState
-
- All Implemented Interfaces:
IPerson
,IWeaponsDealer
public class WeaponsDealerState extends java.lang.Object implements IWeaponsDealer
Implementation of the weapons dealer.- Author:
- Andi Hotz, (c) Sahits GmbH, 2013 Created on Jan 25, 2013
-
-
Field Summary
Fields Modifier and Type Field Description private IArmory
armory
private ArmoryRegistry
armoryRegistry
private static org.slf4j.Logger
LOGGER
private DependentPropertyInitializer
propertyInitializer
private double
sellValue
-
Constructor Summary
Constructors Constructor Description WeaponsDealerState()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javafx.beans.property.ReadOnlyIntegerProperty
amountAvailableProperty(EWeapon weapon)
Property representing the amount that can be bought from the dealer.protected boolean
containsWeapon(IWeapon weapons)
Check if there is an amountable object for this wareprivate int
getWeapon(IWeapon weapon)
Retrieve the amount of the weapon that belongs to the dealer.void
init()
int
move(IWeapon weapon, int amount)
Move ware into this holding.void
setCity(ICity city)
Set the city.
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
propertyInitializer
@Autowired private DependentPropertyInitializer propertyInitializer
-
sellValue
@DependentValue("tavern.weapons.dealer.sellvalue.factor") private double sellValue
-
armoryRegistry
@Autowired private ArmoryRegistry armoryRegistry
-
armory
private IArmory armory
-
-
Method Detail
-
init
@PostConstruct public void init()
-
move
public int move(IWeapon weapon, int amount)
Move ware into this holding. The player may be null and is not used in this base implementation, but subclasses may be interested for statistical reasons. This method is thread save.- Specified by:
move
in interfaceIWeaponsDealer
- Parameters:
weapon
- to be movedamount
- of the ware that is moved- Returns:
- the effective amount that was moved. The amount may be positive if something was added, negative if the ware was removed from the holding or zero if nothing was moved.
-
containsWeapon
protected final boolean containsWeapon(IWeapon weapons)
Check if there is an amountable object for this ware- Parameters:
weapons
- to be checked- Returns:
- true if the weapon is contained.
-
getWeapon
private int getWeapon(IWeapon weapon)
Retrieve the amount of the weapon that belongs to the dealer.- Parameters:
weapon
- type of weapon- Returns:
- amount available at the time of the call of the method.
-
amountAvailableProperty
public javafx.beans.property.ReadOnlyIntegerProperty amountAvailableProperty(EWeapon weapon)
Description copied from interface:IWeaponsDealer
Property representing the amount that can be bought from the dealer.- Specified by:
amountAvailableProperty
in interfaceIWeaponsDealer
- Parameters:
weapon
- that is to be sold- Returns:
- integer binding representing the amount of the weapon that can be bought.
-
setCity
public void setCity(ICity city)
Description copied from interface:IWeaponsDealer
Set the city.- Specified by:
setCity
in interfaceIWeaponsDealer
- Parameters:
city
- in which the weapons dealer operates
-
-