Show culture in the HUD and make philosophers produce it.

This commit is contained in:
Adrian 2024-11-04 18:10:26 +01:00
parent 6c18870b6b
commit 04a37732d9
5 changed files with 18 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 B

View File

@ -28,6 +28,10 @@
{ Math.floor($village.resources.food) } / { capacity.food } { Math.floor($village.resources.food) } / { capacity.food }
({ production.food >= 0 ? '+' : '' }{ production.food }) ({ production.food >= 0 ? '+' : '' }{ production.food })
</div> </div>
<div>
<img src="/img/icons/culture.png" alt="Culture" />
{ Math.floor($village.resources.culture) }
</div>
</div> </div>
<style> <style>

View File

@ -15,6 +15,11 @@ export interface CostType {
export type ProductionType = CostType; export type ProductionType = CostType;
export interface ResourcesType extends CostType {
culture: number;
}
export interface BuildingSource { export interface BuildingSource {
name: string; name: string;
type: string; type: string;

View File

@ -1,6 +1,6 @@
import { produce } from 'immer'; import { produce } from 'immer';
import { getBuilding, getProduction, getStorage } from './utils'; import { getBuilding, getProduction, getStorage, getUnitSource } from './utils';
import village, { type VillageState } from "./village"; import village, { type VillageState } from "./village";
import type { ProductionType } from './types'; import type { ProductionType } from './types';
@ -67,6 +67,12 @@ 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;
return V; return V;
}); });
}); });

View File

@ -2,7 +2,7 @@ import { writable } from "svelte/store";
import { createBuilding } from "./create"; import { createBuilding } from "./create";
import { getTilesAtDistance, Hex } from "./hexgrid"; import { getTilesAtDistance, Hex } from "./hexgrid";
import type { BuildingType } from "./types"; import type { BuildingType, ResourcesType } from "./types";
import { getKeysAsNumbers, shuffle } from "./utils"; import { getKeysAsNumbers, shuffle } from "./utils";
@ -24,13 +24,7 @@ export interface VillageState {
units: { units: {
[key: string]: number; [key: string]: number;
}, },
resources: { resources: ResourcesType;
wood: number;
stone: number;
iron: number;
food: number;
culture: number;
};
villageTiles: Board; villageTiles: Board;
outsideTiles: Board; outsideTiles: Board;
queue: QueuedBuilding[]; queue: QueuedBuilding[];