Adds crafted items, weapon config, generally working

This commit is contained in:
2025-08-22 13:11:47 -07:00
parent 87c908ca68
commit 7556fade3d
18 changed files with 431 additions and 71 deletions

View File

@@ -1,4 +1,4 @@
import { ItemsById } from "../lib/items";
import { ItemsById, itemsPerSlot } from "../lib/items";
import type { State } from "../lib/state";
import { Slots, type Item, type Slot } from "../lib/types";
import { ItemLink } from "./ItemLink";
@@ -12,16 +12,28 @@ export type Props = {
onUnequip: (item: Item) => void;
};
export const Equipment = ({ state, onEquip, onUnequip }: Props) => (
<div>
<ItemTypeahead value={null} onSelect={onEquip} />
<div className={styles.equipedItems}>
{Slots.map((slot) => (
<Slot state={state} slot={slot} onUnequip={onUnequip} key={slot} />
))}
export const Equipment = ({ state, onEquip, onUnequip }: Props) => {
return (
<div>
<ItemTypeahead value={null} onSelect={(item) => item && onEquip(item)} />
<div className={styles.equipedItems}>
{Slots.map((slot) => {
if (itemsPerSlot(slot, state.weaponConfig) > 0) {
return (
<Slot
state={state}
slot={slot}
onUnequip={onUnequip}
key={slot}
/>
);
}
return null;
})}
</div>
</div>
</div>
);
);
};
type SlotProps = {
state: State;