refactor items logic

This commit is contained in:
Peter Stockings
2026-01-22 22:04:23 +11:00
parent 4129f5390f
commit d2039df8c8
8 changed files with 220 additions and 118 deletions

View File

@@ -2,7 +2,12 @@ import { type World, type EntityId, type RunState, type Tile, type Actor, type V
import { TileType } from "../../core/terrain";
import { idx } from "./world-logic";
import { GAME_CONFIG } from "../../core/config/GameConfig";
import { ITEMS } from "../../core/config/Items";
import {
createConsumable,
createMeleeWeapon,
createRangedWeapon,
createArmour
} from "../../core/config/Items";
import { seededRandom } from "../../core/math";
import * as ROT from "rot-js";
@@ -53,11 +58,11 @@ export function generateWorld(floor: number, runState: RunState): { world: World
...runState.inventory.items,
// Add starting items for testing if empty
...(runState.inventory.items.length === 0 ? [
{ ...ITEMS["health_potion"], quantity: 2 },
ITEMS["iron_sword"],
{ ...ITEMS["throwing_dagger"], quantity: 3 },
ITEMS["pistol"],
ITEMS["leather_armor"]
createConsumable("health_potion", 2),
createMeleeWeapon("iron_sword"),
createConsumable("throwing_dagger", 3),
createRangedWeapon("pistol"),
createArmour("leather_armor")
] : [])
]
},