List<IShip> ships = owner.getFleet();
for (IShip ship : ships) {
companyValue += ship.getValue();
Set<IWare> loaded = ship.getLoadedWares();
for (IWare ware : loaded) {
AmountablePrice ap = ship.getWare(ware);
companyValue+=ap.getAVGPrice()*ap.getAmount();
}
}
// Add value of all buildings
for (ECityName cityName : ECityName.values()) {
ICity city;
try {
city = CityFactory.createCityByName(cityName); // TODO refactor this as bean
List<IBuilding> buildings = owner.findBuildings(city);
for (IBuilding building : buildings) {
companyValue += building.getValue();
if (building instanceof ITradingOffice){
ITradingOffice office = (ITradingOffice) building;
for (IWare ware : EWare.values()) {
AmountablePrice ap = office.getWare(ware);
companyValue+=ap.getAVGPrice()*ap.getAmount();
}
}
}
} catch (IOException e) {
logger.error("Could not retrieve created cities",e);