цикл день-ночь, кролики, кровавая луна

This commit is contained in:
azykov@mail.ru
2026-09-04 20:31:53 +03:00
parent 982bbce813
commit 396a604671
17 changed files with 1061 additions and 171 deletions
+11 -5
View File
@@ -1,10 +1,10 @@
import type { Inventory, ResourceDrop, ResourceNode, Vec2 } from './types';
import type { Inventory, RabbitState, ResourceDrop, ResourceNode, Vec2 } from './types';
import type { UpgradeId } from './upgrades';
const STORAGE_KEY = 'forest-save-v1';
export interface SaveData {
version: 2;
version: 3;
inventory: Inventory;
upgradeLevels: Record<UpgradeId, number>;
/** World state (character/nodes/drops) is optional so older saves without it still load fine —
@@ -12,8 +12,14 @@ export interface SaveData {
character?: Vec2;
nodes?: ResourceNode[];
resourceDrops?: ResourceDrop[];
/** Absent on older saves, which are treated as level 1. */
level?: number;
/** Absent on saves from before rabbits existed, which get a freshly spawned batch instead. */
rabbits?: RabbitState[];
/** Absent on older saves, which are treated as day 1. */
day?: number;
/** In-game clock hour (0-24). Absent on older saves, which are treated as noon. */
hour?: number;
/** Absent on saves from before the character had hp, which default to a full characterMaxHp. */
characterHp?: number;
}
function isValidSave(value: unknown): value is SaveData {
@@ -21,7 +27,7 @@ function isValidSave(value: unknown): value is SaveData {
return false;
const data = value as Partial<SaveData>;
return (
data.version === 2
data.version === 3
&& typeof data.inventory === 'object' && data.inventory !== null
&& typeof data.inventory.logs === 'number'
&& typeof data.inventory.twigs === 'number'