Player takes items and lists inventory.

This commit is contained in:
2021-04-29 22:51:52 -07:00
parent e037190c7f
commit fbf841b551
2 changed files with 48 additions and 1 deletions

16
main.ts
View File

@ -1,11 +1,13 @@
import User from "./User.ts";
import Scene from "./Scene.ts";
import Player from "./Player.ts";
import { hall } from "./data/data.ts";
import parseCommand from "./parseCommand.ts";
async function main() {
const user = new User();
const scene = new Scene(hall);
const player = new Player();
const question = "";
let running = true;
let statement = "";
@ -28,7 +30,11 @@ async function main() {
break;
case "take":
await scene.take(target);
await pickUpItem(scene, player, target);
break;
case "inventory":
await player.inventory();
break;
default:
@ -49,4 +55,12 @@ function quit(user: User): boolean {
return true;
}
async function pickUpItem(scene: Scene, player: Player, target: string) {
const item = await scene.take(target);
if (item !== null) {
player.drop(item);
}
}
main();