diff --git a/src/hud/Resources.svelte b/src/hud/Resources.svelte
index e8bee8b..f475c55 100644
--- a/src/hud/Resources.svelte
+++ b/src/hud/Resources.svelte
@@ -31,6 +31,7 @@
{ Math.floor($village.resources.culture) }
+ ({ production.culture >= 0 ? '+' : '' }{ production.culture })
diff --git a/src/update.ts b/src/update.ts
index 8f0ba6a..2b975ac 100644
--- a/src/update.ts
+++ b/src/update.ts
@@ -76,12 +76,6 @@ export default function update(timestamp: number) {
}
});
- // Make philosophers produce culture.
- const philosopher = getUnitSource('philosopher');
- const outputPerMinute = philosopher.behavior.culturePerMinute;
- const outputPerMilisecond = outputPerMinute / 60.0 / 1000.0;
- V.resources.culture += outputPerMilisecond * delta * (V.units.philosopher || 0);
-
// Check if the game is won.
if (V.resources.culture >= 2000) {
V.victory = true;
diff --git a/src/utils.ts b/src/utils.ts
index 2603802..af511d0 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,29 +1,31 @@
import units from "./data/units";
-import type { BuildingType, CostType, ProductionType } from "./types";
+import type { BuildingType, CostType, ProductionType, ResourcesType } from "./types";
import type { VillageState } from "./village";
-function _reduceResources(acc: ProductionType, item: ProductionType): ProductionType {
+function _reduceResources(acc: ResourcesType, item: ResourcesType): ResourcesType {
return {
wood: acc.wood + item.wood,
stone: acc.stone + item.stone,
iron: acc.iron + item.iron,
food: acc.food + item.food,
+ culture: acc.culture + item.culture,
};
}
-export function getEmptyResources(): ProductionType {
+export function getEmptyResources(): ResourcesType {
return {
wood: 0,
stone: 0,
iron: 0,
food: 0,
+ culture: 0,
};
}
-export function getProduction(villageState: VillageState): ProductionType {
+export function getProduction(villageState: VillageState): ResourcesType {
let production = getEmptyResources();
// Add buildings production and intake.
@@ -36,12 +38,20 @@ export function getProduction(villageState: VillageState): ProductionType {
})
.reduce(_reduceResources, production);
- // Add units intake.
+ // Add units production and intake.
['philosopher'].forEach(type => {
const unit = getUnitSource(type);
const unitCount = villageState.units[type] || 0;
+
+ // Add food intake.
const intakePerMinute = unit.behavior.foodIntakePerMinute * unitCount;
production.food -= intakePerMinute;
+
+ // Add culture production for Philosophers.
+ if (type === 'philosopher') {
+ const outputPerMinute = unit.behavior.culturePerMinute;
+ production.culture += outputPerMinute * unitCount;
+ }
});
return production;