UNPKG

doggo-quest-logic

Version:

The game logic for the Doggo Quest text-based game sample project

44 lines (43 loc) 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const GameObjectBase_1 = require("../GameObjectBase"); const Room_1 = require("../Room"); class CrateDoorObject extends GameObjectBase_1.GameObjectBase { constructor(room) { super('door'); this.room = room; this.smell = 'It smells like metal.'; this.lick = 'It tastes smooth, cold, and boring.'; this.push = this.handlePushed; this.look = this.handleLook; } handlePushed(context) { if (context.world.isCrateOpen) { if (this.room === Room_1.Room.InCrate) { context.addText('The door is already open. In order to push it, you\'d have to leave the crate first.'); } else { context.addText('You don\'t really want to push it. It could pinch you and besides, you\'re already out of the crate.'); } } else { context.addText('You push the door and it flies open. You\'re free!'); context.world.isCrateOpen = true; context.increaseScore(1); } } handleLook(context) { if (context.world.isCrateOpen) { if (this.room === Room_1.Room.InCrate) { context.addText('The door is open and the house practically invites you to explore it.'); } else { context.addText('The door is open and leads back to the crate to the south.'); } } else { context.addText('Something about the door looks different. It doesn\'t look as shut as it usually is. Could it be they forgot to actually lock it?'); } } } exports.CrateDoorObject = CrateDoorObject;