Open-source interactive fiction engine, powered by React, Redux and TypeScript. _ https://discoteque.pub/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

27 lines
888 B

import * as R from 'ramda';
import { EngineConfig, NodeMap, EngineState, DayCycleFn } from './types';
import { Engine } from './Engine';
import { Reducer } from 'redux';
const defaultDayCycleFn: DayCycleFn = R.identity;
export default <GS = object, MT = undefined, ST extends string = string>(config: EngineConfig<GS, MT>, reducer: Reducer) => {
const nodeMap: NodeMap<GS, MT> = R.indexBy(R.prop('id'), config.nodes);
const state: EngineState<GS, MT, ST> = {
nodeMap,
line: 0,
node: config.startNode,
skills: config.skills,
skillPoints: config.skillPointsOnStart,
chrono: config.chrono,
protectSkills: false,
backlog: [],
ui: {
skillsOpen: false,
menuOpen: true,
isOver: false,
}
}
const supplyConfig = R.merge(config, { onDayCycle: defaultDayCycleFn });
return new Engine<GS, MT, ST>(state, reducer, supplyConfig);
}