diff --git a/Container.ts b/Container.ts index ed1fa69..d5ad8f3 100644 --- a/Container.ts +++ b/Container.ts @@ -15,7 +15,8 @@ export default class Container { .map(({ name }, i) => { let anItem = `${vowels.includes(name[0]) ? "an" : "a"} ${name}`; - if (i + 1 === items.length) { + // if we have more than one item, and this is the last item... + if (i > 1 && i + 1 === items.length) { anItem = `and ${anItem}`; } diff --git a/Scene.ts b/Scene.ts index 277675e..8ab7974 100644 --- a/Scene.ts +++ b/Scene.ts @@ -1,23 +1,24 @@ import { GameData, Item } from "./data/data.ts"; -import User from "./User.ts"; import Container from "./Container.ts"; export default class Scene extends Container { - #user: User; + #roomDescription: string; constructor(gameData: GameData) { super(gameData.items); - this.#user = new User(); + + this.#roomDescription = gameData.description; } look(): string { - const description = super.description(this.items); + const itemsDescription = super.description(this.items); + let description = this.#roomDescription; - if (description) { - return `There is ${description}`; - } else { - return "There is nothing around..."; + if (itemsDescription) { + description += `\n\nThere is ${itemsDescription}`; } + + return description; } get(target: string): Item | null { diff --git a/data/data.ts b/data/data.ts index 7674d32..f6fd938 100644 --- a/data/data.ts +++ b/data/data.ts @@ -5,5 +5,6 @@ export interface Item { } export interface GameData { + description: string; items: Item[]; } diff --git a/data/rooms.ts b/data/rooms.ts index a21b0a4..d118e1b 100644 --- a/data/rooms.ts +++ b/data/rooms.ts @@ -1,3 +1,8 @@ -export const hall = { +import { GameData } from "./data.ts"; + +export const hall: GameData = { + description: + "You are standing in a big hall. There's lots of nooks, crannies, and" + + "room for general testing. Aw yeah... sweet testing!", items: [{ name: "flashlight" }], };