ch.sahits.game.openpatrician.model.product
Enum EWare

java.lang.Object
  extended by java.lang.Enum<EWare>
      extended by ch.sahits.game.openpatrician.model.product.EWare
All Implemented Interfaces:
IAmountable, IPriceCalculation, IWare, Serializable, Comparable<EWare>

public enum EWare
extends Enum<EWare>
implements IWare, IPriceCalculation

Define the different type of wares that are produced and can be traded.

Author:
Andi Hotz, (c) Sahits GmbH, 2011 Created on Nov 20, 2011

Enum Constant Summary
BEER
          Beer in barrels
BRICK
          Brick in burden
CLOTH
          Cloth in barrels
FISH
          Fish in burden
FISH_OIL
          Fish oil in barrels
FUR
          Fur in barrels
GRAIN
          Grain in burden
HEMP
          Hemp in burden
HONEY
          Honey in barrels
IRON
          Iron in barrels
IRONORE
          Iron ore in burden
LEATHER
          Leather in barrels
MEAT
          Meat in burden
PITCH
          Pitch in barrels
POTTERY
          Pottery in barrels
SALT
          Salt in barrels
SPICE
          Spices in barrels
WINE
          Wine in barrels
WOOD
          Wood in burden
WOOL
          Wool in burden
 
Field Summary
private  IPriceCalculation calculation
           
private  Locale locale
           
private  int maxValueBuy
           
private  int maxValueSell
           
private  int minValueBuy
           
private  int minValueSell
           
private  int saturation
           
private  EWareSize size
           
private  String wareID
           
 
Method Summary
 int computeBuyPrice(int availableAmount, int amountToBuy)
          Compute the price for the wares to be bought.
 double computePrice(int min, int max, int available, int saturation, int productionRate, IPopulationStructure pop, ECityState state)
          Compute the price for one item of the ware.
 int computeSellPrice(int availableAmount, int amountToSell)
          Compute the price for the wares to be soled.
 String getLocalDisplayName()
           
private  String getLocalDisplayName(String id)
          Retrieve the localized display name for id.
 int getMarketSaturation()
          Retrieve the amount of units which is considered infinite.
 int getMaxValueBuy()
          Retrieve the value that is maximal payed for one unit of this ware if no ware is available.
 int getMaxValueSell()
          Retrieve the highest price of this ware when only on item is available
 int getMinValueBuy()
          Retrieve the value of the minimal payed sum for on unit if an infinitly amount of the ware exists.
 int getMinValueSell()
          Retrieve the lowest price this ware is soled (at market saturation)
 short getSizeAsBarrels()
          Retrieve the size of the ware converted into the smallest size unit (barrels)
static EWare valueOf(String name)
          Returns the enum constant of this type with the specified name.
static EWare[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ch.sahits.game.openpatrician.model.product.IWare
name
 

Enum Constant Detail

BEER

public static final EWare BEER
Beer in barrels


IRONORE

public static final EWare IRONORE
Iron ore in burden


IRON

public static final EWare IRON
Iron in barrels


FUR

public static final EWare FUR
Fur in barrels


FISH

public static final EWare FISH
Fish in burden


MEAT

public static final EWare MEAT
Meat in burden


GRAIN

public static final EWare GRAIN
Grain in burden


SPICE

public static final EWare SPICE
Spices in barrels


HEMP

public static final EWare HEMP
Hemp in burden


WOOD

public static final EWare WOOD
Wood in burden


HONEY

public static final EWare HONEY
Honey in barrels


POTTERY

public static final EWare POTTERY
Pottery in barrels


LEATHER

public static final EWare LEATHER
Leather in barrels


PITCH

public static final EWare PITCH
Pitch in barrels


SALT

public static final EWare SALT
Salt in barrels


FISH_OIL

public static final EWare FISH_OIL
Fish oil in barrels


CLOTH

public static final EWare CLOTH
Cloth in barrels


WINE

public static final EWare WINE
Wine in barrels


WOOL

public static final EWare WOOL
Wool in burden


BRICK

public static final EWare BRICK
Brick in burden

Field Detail

locale

private final Locale locale

size

private final EWareSize size

maxValueBuy

private final int maxValueBuy

minValueBuy

private final int minValueBuy

maxValueSell

private final int maxValueSell

minValueSell

private final int minValueSell

wareID

private final String wareID

saturation

private final int saturation

calculation

private final IPriceCalculation calculation
Method Detail

values

public static EWare[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (EWare c : EWare.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static EWare valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

getLocalDisplayName

public final String getLocalDisplayName()
Specified by:
getLocalDisplayName in interface IWare

getLocalDisplayName

private String getLocalDisplayName(String id)
Retrieve the localized display name for id.

Parameters:
id -
Returns:

getMaxValueBuy

public int getMaxValueBuy()
Description copied from interface: IWare
Retrieve the value that is maximal payed for one unit of this ware if no ware is available.

Specified by:
getMaxValueBuy in interface IWare
Returns:

getMaxValueSell

public int getMaxValueSell()
Retrieve the highest price of this ware when only on item is available

Specified by:
getMaxValueSell in interface IWare
Returns:

getMinValueSell

public int getMinValueSell()
Retrieve the lowest price this ware is soled (at market saturation)

Specified by:
getMinValueSell in interface IWare
Returns:

getMinValueBuy

public int getMinValueBuy()
Description copied from interface: IWare
Retrieve the value of the minimal payed sum for on unit if an infinitly amount of the ware exists.

Specified by:
getMinValueBuy in interface IWare
Returns:

computeSellPrice

public int computeSellPrice(int availableAmount,
                            int amountToSell)
Description copied from interface: IWare
Compute the price for the wares to be soled. The price is computed based on the amount that is available and the amount that is sold. The price is never higher than IWare.getMaxValueBuy() and approaches IWare.getMinValueBuy() assymtotically.

Specified by:
computeSellPrice in interface IWare
Parameters:
availableAmount - Amount of the ware that is available
amountToSell - Amount of ware that is to be sold
Returns:
price of the ware.

computePrice

public double computePrice(int min,
                           int max,
                           int available,
                           int saturation,
                           int productionRate,
                           IPopulationStructure pop,
                           ECityState state)
Compute the price for one item of the ware. Though the price is only handled in further computation as integer value, this method returns its value as double so this condition can be tested:
The higher the available amount (but still below the saturation value) the smaller (strictly) the returned value.
For different starting values:
If the starting value b is below starting point a the whole curve of b is below (not necessary strictly) the curve of a. The curve is continues between 0 (inclusive) and infinity.

Specified by:
computePrice in interface IPriceCalculation
Parameters:
min - the lowest possible price (0 exclusive)
max - the highest possible price
available - amount of wares that are available in the market
saturation - amount of items at which the market is saturated (no further price change
productionRate - amount the city can produce within a week
pop - population structure that may have an influence on the calculated price
state - state of the city
Returns:
price for one item sold
See Also:
SimplePriceCalculation.computePrice(int, int, int, int, int, IPopulationStructure, ECityState)

computeBuyPrice

public int computeBuyPrice(int availableAmount,
                           int amountToBuy)
Description copied from interface: IWare
Compute the price for the wares to be bought. The price is computed on the amount that is available and the amount to be bought. The price is never highter than IWare.getMaxValueBuy() plus a ware specific constant.

Specified by:
computeBuyPrice in interface IWare
Parameters:
availableAmount - Amount of the ware that is available
amountToBuy - Amount of ware that is to be bought
Returns:
price of the ware

getSizeAsBarrels

public final short getSizeAsBarrels()
Description copied from interface: IWare
Retrieve the size of the ware converted into the smallest size unit (barrels)

Specified by:
getSizeAsBarrels in interface IWare
Returns:

getMarketSaturation

public int getMarketSaturation()
Description copied from interface: IWare
Retrieve the amount of units which is considered infinite. This influences the price because if there are so much units of the ware available the selling price will be the minimum.

Specified by:
getMarketSaturation in interface IWare
Returns:


Copyright © 2011-2012 Sahits GmbH. All Rights Reserved.