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 }
({ production.food >= 0 ? '+' : '' }{ production.food })
</div>
<div>
<img src="/img/icons/culture.png" alt="Culture" />
{ Math.floor($village.resources.culture) }
</div>
</div>
<style>

View File

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

View File

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

View File

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