23 lines
413 B
TypeScript
23 lines
413 B
TypeScript
import { GameData, Item } from "./data/data.ts";
|
|
|
|
export default class Scene {
|
|
#items: Item[];
|
|
|
|
constructor(gameData: GameData) {
|
|
this.#items = gameData.items;
|
|
}
|
|
|
|
take(target: string): Item | null {
|
|
const idx = this.#items.findIndex(({ name }) => name === target);
|
|
|
|
if (idx >= 0) {
|
|
const item = this.#items[idx];
|
|
this.#items = this.#items.splice(idx, 1);
|
|
|
|
return item;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|