Started organization

main
Ashelyn Dawn 4 years ago
parent 952e3cba4e
commit 549f7dfc3b

@ -51,7 +51,6 @@ export default function Help({parentRef}) {
<li>drop [thing]</li>
<li>open [thing]</li>
<li>close [thing]</li>
<li>put [thing] in [thing]</li>
</ul>
</>
}

@ -27,6 +27,7 @@ export default function(parser : Parser, rules : RulesEngine, game : Game) {
parser.understand('openItem')
.as('open [item]')
.as('open [item] with [item]')
rules.onCommand('openItem', () => {
game.say(`You don't believe that can be opened!`)

@ -0,0 +1,20 @@
import {game, rules} from '../engine'
// Initial player location
game.getState().player.location = 'cabin'
// Mark room visited when ending a turn there
const markRoomVisited = () => {game.getCurrentRoom()!.visited = true}
rules.onGameStart(markRoomVisited)
rules.onAfterCommand(markRoomVisited)
// Mark items as seen when ending a turn in their room
const setItemsSeen = () => game.findObjectsInRoom(game.getCurrentRoom()!.name).forEach(item => {item.seen = true})
rules.onGameStart(setItemsSeen)
rules.onAfterCommand(setItemsSeen)
// Track items' last seen location
const setItemLastLoc = () => game.findObjectsInRoom(game.getCurrentRoom()!.name).forEach(item => {item.lastKnownLocation = game.getCurrentRoom()!.name})
rules.onGameStart(setItemLastLoc)
rules.onAfterCommand(setItemLastLoc)

@ -1,4 +1,4 @@
import {game} from './engine'
import {game} from '../engine'
game.addRoom('cabin', 'Crew Cabin', `
A dark and dingy room with a single bunk bed along the starboard side.

@ -0,0 +1,43 @@
import {game} from '../engine'
export enum Phase {
wakeUp,
hasFlashlight,
openedSinkPanel,
droppedBelow,
fixedLifeSupport,
examinedEngine,
examinedMainframe,
examinedDoor,
examinedChair,
destroyedChair,
openedDoor,
examinedLocker,
examinedHoleCannotGetUp,
hasNewChair,
returnedUpToBathroom,
hasKey,
unlockedLocker
}
// TODO: Replace [thing]
export const hints : Map<Phase, string> = new Map()
hints.set(Phase.wakeUp, 'You may be able to assess your situation better if you retrieve your flashlight.')
hints.set(Phase.hasFlashlight, 'With the security door shut and power cut off, you\'ll have to find another way into the rest of the ship.')
hints.set(Phase.openedSinkPanel, 'You can get to the lower deck through the panel under the sink, but be sure not to leave anything behind!')
hints.set(Phase.droppedBelow, 'You need to re-start the CO2 scrubber before you run out of clean air.')
hints.set(Phase.fixedLifeSupport, 'While the immediate threat to your life has been solved, you need to bring the engine back on so you can restore power to your ship.')
hints.set(Phase.examinedEngine, 'The engine itself seems to be in good repair, time to go to the mainframe and start up its control systems.')
hints.set(Phase.examinedMainframe, 'The engine control systems are missing [thing]. There\'s a spare in the comm room locker, but you\'ll have to find a way to get there.')
hints.set(Phase.examinedDoor, 'You need to find a way into the comms room to retrieve [thing] - the door looks like it could be pried open with enough leverage.')
hints.set(Phase.examinedChair, 'The chair looks sturdy enough to work as a lever to get in the door, but it will have to be disassembled first.')
hints.set(Phase.destroyedChair, 'You have a bar that should be strong enough to open the door to the comms room - go retrieve the [thing] so you can start the engine again!')
hints.set(Phase.openedDoor, 'You found a way into the comms room - retrieve the [thing] from the comms room locker so you can restart the engine.')
hints.set(Phase.examinedLocker, 'Someone locked the comms room locker. There\'s a spare key in your overalls - they\'re back in your cabin.')
hints.set(Phase.examinedHoleCannotGetUp, 'You can\'t reach up into the bathroom any more - you\'ll have to find something else to use to climb up')
hints.set(Phase.hasNewChair, 'You found another chair you can use to reach the bathroom - go get the spare locker key from your cabin.')
hints.set(Phase.returnedUpToBathroom, 'Someone locked the comms room locker. There\'s a spare key in your overalls - they\'re back in your cabin.')
hints.set(Phase.hasKey, `You've retrieved the spare key to the comms locker, and can finally get the [thing] to repair the mainframe.`)
hints.set(Phase.unlockedLocker, 'Locker is empty - whoever was in your ship made sure you wouldn\'t be able to repair it.')
game.createProperty('gamePhase', Phase.wakeUp)

@ -1,24 +1,9 @@
import {game, rules, renderer} from './engine/'
import './rooms.tsx'
import './gameSetup/0-item-visibility'
import './gameSetup/1-rooms'
import './gameSetup/2-phases-and-hints'
// Initial player location
game.getState().player.location = 'cabin'
// Mark room visited when ending a turn there
const markRoomVisited = () => {game.getCurrentRoom()!.visited = true}
rules.onGameStart(markRoomVisited)
rules.onAfterCommand(markRoomVisited)
// Mark items as seen when ending a turn in their room
const setItemsSeen = () => game.findObjectsInRoom(game.getCurrentRoom()!.name).forEach(item => {item.seen = true})
rules.onGameStart(setItemsSeen)
rules.onAfterCommand(setItemsSeen)
// Track items' last seen location
const setItemLastLoc = () => game.findObjectsInRoom(game.getCurrentRoom()!.name).forEach(item => {item.lastKnownLocation = game.getCurrentRoom()!.name})
rules.onGameStart(setItemLastLoc)
rules.onAfterCommand(setItemLastLoc)
game.addItem('block', 'A boring wooden block', 'comms')

Loading…
Cancel
Save