Files
detective/Player.ts

32 lines
709 B
TypeScript

import { Effect, Item, VesselProperties } from "./types.ts";
import Vessel from "./Vessel.ts";
export default class Player extends Vessel<VesselProperties> {
#effects: Effect<VesselProperties>[];
constructor(items: Item[] = [], effects: Effect<VesselProperties>[] = []) {
super({ items }, { effects: [] });
this.#effects = effects;
}
get effects() {
return this.#effects;
}
look(): string {
const description = super.description(this._properties.items || []);
if (description) {
return `You have ${description}`;
} else {
return "You have nothing.";
}
}
put(item: Item) {
if (!this._properties.items) this._properties.items = [];
this._properties.items.push(item);
}
}