import { CityWithLocation, CityRepository } from "../repository/city";
import * as _ from 'lodash';
+function percent(curr: number, max: number, cap?: number): number {
+ const val = Math.ceil((curr/max) * 100);
+ if(cap && val > cap) {
+ return cap;
+ }
+
+ return val;
+}
+
type Usage = {
foodUsagePerTick: number;
foodProductionPerTick: number;
</tr>
<tr>
<th>Food</th>
- <td>${city.food.toLocaleString()} (<span class="rate-of-change ${foodRateOfChange < 0 ? 'danger-text' : 'success-text'}">${foodRateOfChange.toLocaleString()}</span>)</td>
+ <td>
+ ${city.food.toLocaleString()} (<span class="rate-of-change ${foodRateOfChange < 0 ? 'danger-text' : 'success-text'}">${foodRateOfChange.toLocaleString()}</span>) @ ${percent(city.food, city.warehouses, 100)}% Warehouse utilization
+ </td>
</tr>
</table>
</div>