diff --git a/Player.ts b/Player.ts index 408162c..0859a91 100644 --- a/Player.ts +++ b/Player.ts @@ -14,9 +14,9 @@ export default class Player extends Container { this.items.push(item); } - look(): void { + async look(): Promise { const description = super.description(this.items); - this.#user.tell(`You have ${description}`); + await this.#user.tell(`You have ${description}`); } } diff --git a/Scene.ts b/Scene.ts index 7860177..ddf426e 100644 --- a/Scene.ts +++ b/Scene.ts @@ -10,7 +10,7 @@ export default class Scene extends Container { this.#user = new User(); } - async look() { + async look(): Promise { const description = super.description(this.items); await this.#user.tell(`There is ${description}`); diff --git a/main.ts b/main.ts index c8aff68..0a6a2a6 100644 --- a/main.ts +++ b/main.ts @@ -30,7 +30,7 @@ async function main() { break; case "take": - await pickUpItem(scene, player, target); + await pickUpItem(user, scene, player, target); break; case "inventory": @@ -38,8 +38,7 @@ async function main() { break; default: - statement = "I didn't understand that.\n"; - + statement = "\nI didn't understand that.\n"; break; } } @@ -55,7 +54,17 @@ function quit(user: User): boolean { return true; } -async function pickUpItem(scene: Scene, player: Player, target: string) { +async function pickUpItem( + user: User, + scene: Scene, + player: Player, + target?: string +) { + if (!target) { + await user.tell("What do you want me to take?"); + return; + } + const item = await scene.take(target); if (item !== null) {