Resource resource = (Resource) resourceIterator.next();
int storage = settlement.getTotalCapacity(resource);
if (settlement.getResourceQuantity(resource) > storage) {
int wastedAmount = settlement.getResourceQuantity(resource) - storage;
StringBuffer messageText = new StringBuffer(wastedAmount + " units of " + resource + " is wasted in " + settlement.getName());
ResourceWastedMessage message = new ResourceWastedMessage();
message.setText(messageText);
message.setTurnSent(realm.getNumberOfTurns());
message.setSettlement(settlement);
message.setResource(resource);
player.addMessage(message);
settlement.setResourceQuantity(resource, storage);
}
}
}