Fix async logging bugs.
This commit is contained in:
@ -14,9 +14,9 @@ export default class Player extends Container {
|
|||||||
this.items.push(item);
|
this.items.push(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
look(): void {
|
async look(): Promise<void> {
|
||||||
const description = super.description(this.items);
|
const description = super.description(this.items);
|
||||||
|
|
||||||
this.#user.tell(`You have ${description}`);
|
await this.#user.tell(`You have ${description}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
Scene.ts
2
Scene.ts
@ -10,7 +10,7 @@ export default class Scene extends Container {
|
|||||||
this.#user = new User();
|
this.#user = new User();
|
||||||
}
|
}
|
||||||
|
|
||||||
async look() {
|
async look(): Promise<void> {
|
||||||
const description = super.description(this.items);
|
const description = super.description(this.items);
|
||||||
|
|
||||||
await this.#user.tell(`There is ${description}`);
|
await this.#user.tell(`There is ${description}`);
|
||||||
|
17
main.ts
17
main.ts
@ -30,7 +30,7 @@ async function main() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "take":
|
case "take":
|
||||||
await pickUpItem(scene, player, target);
|
await pickUpItem(user, scene, player, target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "inventory":
|
case "inventory":
|
||||||
@ -38,8 +38,7 @@ async function main() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
statement = "I didn't understand that.\n";
|
statement = "\nI didn't understand that.\n";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,7 +54,17 @@ function quit(user: User): boolean {
|
|||||||
return true;
|
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);
|
const item = await scene.take(target);
|
||||||
|
|
||||||
if (item !== null) {
|
if (item !== null) {
|
||||||
|
Reference in New Issue
Block a user