Can take apart mainframe

main
Ashelyn Dawn 4 years ago
parent fdc3dbea39
commit d1dedc1fc2

@ -50,6 +50,8 @@ export default function Help({parentRef}) {
<li>take [thing]</li>
<li>drop [thing]</li>
<li>open [thing]</li>
<li>turn on [thing]</li>
<li>take apart [thing]</li>
</ul>
</>
}

@ -55,11 +55,11 @@ export default function Map() {
<h3>{currentRoom.printableName}</h3>
{currentRoom.visited
? (<>
<ReactMarkdown>{currentRoom.description}</ReactMarkdown>
<ReactMarkdown escapeHtml={false}>{currentRoom.description}</ReactMarkdown>
{itemsInRoom.length > 0 && (<>
<p>You {(playerLocation === roomName) ? 'see' : 'recall seeing'} the following items here:</p>
<ul>
{itemsInRoom.map(({name, printableName}) => <li>{printableName || name}</li>)}
{itemsInRoom.map(({name, printableName}) => <li><ReactMarkdown escapeHtml={false}>{printableName || name}</ReactMarkdown></li>)}
</ul>
</>)}
</>)

@ -16,7 +16,7 @@ export default function Text({promptVisible, messages, currentInput, currentScro
<div ref={outputRef} className={styles.output}>
{messages.map((message, i) => {
if(message.type === 'message')
return <ReactMarkdown key={i}>{message.message}</ReactMarkdown>
return <ReactMarkdown escapeHtml={false} key={i}>{message.message}</ReactMarkdown>
if(message.type === 'command')
return <p key={i} className={styles.command}>{message.command}</p>

@ -11,5 +11,6 @@ export default [
require('./options'),
require('./map'),
require('./hint'),
require('./start')
require('./start'),
require('./take-apart')
]

@ -0,0 +1,14 @@
import Parser from "../Parser";
import RulesEngine from "../RulesEngine";
import Game from "../Game";
export default function(parser : Parser, rules : RulesEngine, game : Game) {
parser.understand('take apart')
.as('take apart [item]')
.as('disassemble [item]')
.as('dissassemble [item]')
rules.onCommand('take apart', command => {
game.say(`That isn't something you can take apart.`)
})
}

@ -62,6 +62,14 @@ Large, metal retractable doors designed to keep air from escaping through them.
medDoor.aliases = ['security doors', 'door', 'doors']
medDoor.printableName = 'security doors'
const filter = game.addItem('filter', `
Largest of the medical bay equipment, the CO<sub>2</sub> filter looks sort of
like a large air conditioning unit. It is currently switched off.
`, 'medbay')
filter.aliases = ['co2 filter', 'co2', 'life support']
filter.printableName = 'CO<sub>2</sub> filter'
game.addRoom('stairupper', 'Upper Stairwell', `
A large window in the aft wall shows the view of an unknown star system
@ -92,8 +100,7 @@ Filling almost the entire room, the mainframe serves as the ship's primary contr
computer. It regulates engine power, controls the navigation and piloting systems,
and even has a few games built in!
Of course, with the engine not running the mainframe is currently in low power
mode - you'll have to start the engine up again to restore full functionality.
Of course, with the engine not running the mainframe is currently in low power mode - you'll have to start the engine up again to restore full functionality.
`, 'mainframe')
computer.aliases.push('computer')
computer.aliases.push('engine controller')
@ -112,6 +119,15 @@ Even running on standby power, your view through the window of the engine is ove
At full power the windows have to be polarized to block the blinding glow of the engine's warp singularity - as it is, it's relatively safe to look at.
`, 'engine')
const chair = game.addItem('chair', `
An odd three-legged construction, made of one large beam curving all the way from the
back of the chair to the floor, with two side legs affixed at the sides. Your
experience has shown that this model of chair is **very** sturdy.
`, 'engine')
chair.carryable = true
game.addRoom('docking', 'Docking Bay', `
A long and wide room for loading and unloading cargo. The
dock hatch is sealed, and you definitely shouldn't go opening

@ -93,6 +93,17 @@ rules.onBeforeCommand(command => {
throw new Error(`If you put down the flashlight, you will likely not be able to find it again in the dark.`)
})
/**
* If we get "take apart" cabinet, try opening it instead
*/
rules.onBeforeCommand(command => {
if(command.verb.name !== 'take apart') return;
if(command.subject?.name === 'cabinet' || command.subject?.name === 'floor panel'){
parser.runCommand(`open ${command.subject?.name}`)
throw new Error()
}
})
/**
* When opening the cabinet, insert floor panel
@ -154,6 +165,16 @@ rules.onAfterCommand(command => {
game.say(`_Focus_, you remind yourself. _The engine is pretty but I've gotta fix that CO<sub>2</sub> filter before I'll have time to bother with this._`)
})
/**
* Add to mainframe description when CO2 not fixed
*/
rules.onAfterCommand(command => {
if(command.verb.name !== 'lookAt' || command.subject?.name !== 'mainframe') return;
if(game.getProperty('gamePhase') < Phase.fixedLifeSupport)
game.say(`Luckily the CO<sub>2</sub> filter operates independently to the rest of the ship's systems, so you can worry about that fixing first and then come back to the mainframe.`)
})
/**
* Turn on flashlight
*/
@ -180,8 +201,62 @@ rules.onBeforeCommand(command => {
if(currentPhase < Phase.fixedLifeSupport)
throw new Error(`You probably should restart the CO<sub>2</sub> filter before worrying about the engine.`)
if(currentPhase < Phase.examinedMainframe)
if(currentPhase < Phase.examinedMainframe){
game.setProperty('gamePhase', Phase.examinedEngine)
throw new Error(`As far as you can tell the engine _itself_ is fine, perhaps something is wrong with the mainframe's control systems?`)
}
throw new Error(`The mainframe's engine control systems have been damaged and will have to be repaired before the engine can be started.`)
})
/**
* Cannot start mainframe
*/
rules.onBeforeCommand(command => {
if(command.verb.name !== 'start' || command.subject?.name !== 'mainframe') return;
const currentPhase = game.getProperty('gamePhase')
if(currentPhase < Phase.fixedLifeSupport)
throw new Error(`You probably should restart the CO<sub>2</sub> filter before worrying about the mainframe.`)
if(currentPhase < Phase.examinedMainframe){
parser.runCommand(`take apart mainframe`)
throw new Error()
}
throw new Error(`The mainframe's engine control system is damaged, and will have to be repaired before you can bring it online. You believe you have a replacement part in the comms room.`)
})
/**
* Cannot start filter again
*/
rules.onBeforeCommand(command => {
if(command.verb.name !== 'start' || command.subject?.name !== 'filter') return;
const currentPhase = game.getProperty('gamePhase')
if(currentPhase >= Phase.fixedLifeSupport)
throw new Error(`The CO<sub>2</sub> filter is already running.`)
})
/**
* Taking apart engine: error saying that's dangerous, and not something you can do without a drydock
*/
rules.onBeforeCommand(command => {
if(command.verb.name !== 'take apart' || command.subject?.name !== 'engine') return;
throw new Error(`Even in non-emergency conditions, the engine is not something you can safely service without bringing the _Dawn_ down at a drydock.`)
})
/**
* Taking apart mainframe: Explain damaged part - after that, say you need the part
*/
rules.onBeforeCommand(command => {
if(command.verb.name !== 'take apart' || command.subject?.name !== 'mainframe') return;
const currentPhase = game.getProperty('gamePhase')
if(currentPhase < Phase.fixedLifeSupport)
throw new Error(`You probably should restart the CO<sub>2</sub> filter before worrying about the mainframe.`)
if(currentPhase >= Phase.examinedMainframe)
throw new Error(`You won't be able to repair the mainframe's control system without the replacement capacitor from the comms room.`)
})

@ -1,5 +1,7 @@
import {game, rules} from '../engine'
import { Phase } from './2-phases-and-hints'
import { ObjectType, Item } from '../engine/types/GameState'
import { Draft } from 'immer'
/**
* Intro
@ -117,3 +119,58 @@ rules.onAfterCommand(command => {
game.say(`As you look up the stairway you catch a glimpse of light filtering down from above - must be near a star cluster you suppose. Not really any good way to know which one until you can bring the navigation systems back online.`)
})
/**
* Starting CO2 filter
*/
rules.onAfterCommand(command => {
if(command.verb.name !== 'start' || command.subject?.name !== 'filter') return;
const currentPhase = game.getProperty('gamePhase')
if(currentPhase >= Phase.fixedLifeSupport)
throw new Error(`The CO<sub>2</sub> filter is already running.`)
const filter = game.findObjectByName('filter', ObjectType.Item) as Draft<Item>
filter.description = filter.description?.replace('switched off', 'running')
game.setProperty('gamePhase', Phase.fixedLifeSupport)
game.clear()
game.say(`Okay, with the CO2 scrubber running again, the filter should last for at least a week - plenty of time to get the _Dawn_ back to a spaceport. If the engine issue isn't that bad, maybe she'll last you all the way back to Earth so you can collect your paycheck and do a proper diagnostic.`)
game.say(`Speaking of which, examining the engine is probably the next order of business - if it's gonna keep dropping out of hyperspace on you then this is going to be a long trip home.`)
game.pause()
game.clear()
rules.printArea()
})
rules.onAfterCommand(command => {
if(command.verb.name !== 'take apart' || command.subject?.name !== 'mainframe') return;
const currentPhase = game.getProperty('gamePhase')
if(currentPhase < Phase.fixedLifeSupport)
throw new Error(`You really should worry about the CO<sub>2</sub> filter before doing anything with the mainframe.`)
if(currentPhase >= Phase.examinedMainframe)
throw new Error(`You've already taken the mainframe pretty well apart - you need that replacement capacitor.`)
game.setProperty('gamePhase', Phase.examinedMainframe)
const mainframe = game.findObjectByName('mainframe', ObjectType.Item) as Draft<Item>
mainframe.description = mainframe.description?.replace(/Of course.*/, `While the bulk of the mainframe is still there, you've currently taken apart the engine control systems. Looks like there's a faulty capacitor in the engine regulator board, and you'll have to get a replacement from the comms room locker.`)
game.clear()
game.say(`At first glance the mainframe is working as expected - you can bring up the internal atmospheric readings, the operation logs, and anything else that doesn't need engine power. The mainframe even kindly informs you there was some sort of anomalous power output from the engine before it cut from hyperjump, but when you try to bring the engine back online you hear a loud ***pop*** from behind the terminal and start to smell smoke.`)
game.pause()
game.clear()
game.say(`Upon further inspection, it looks like there's a faulty capacitor in the engine regulator board. That would explain the power anomalies - these sort of caps always act a bit weird before they blow completely.`)
game.say(`The _Dawn_ is old enough (and this issue is common with her model of ship) so you luckily have a spare capacitor or two in the comms room locker - although finding a way through the security doors might be a bit tricky.`)
game.pause()
game.clear()
rules.printArea()
})

Loading…
Cancel
Save