UNPKG

@coorpacademy/progression-engine

Version:

9 lines (7 loc) 2.23 kB
// @flow import type {Instruction} from "./types"; import type {State, Variables, Variable} from "../types"; import update from "lodash/fp/update"; import set from "lodash/fp/set"; import reduce from "lodash/fp/reduce"; declare export default function(instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}>): (fromState: {content?: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}} & {allAnswers: Array<{answer: Array<string>, isCorrect: ?boolean, slideRef: string}>, content?: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, hasViewedAResourceAtThisStep: boolean, isCorrect: ?boolean, lives: number, livesDisabled?: boolean, nextContent?: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, remainingLifeRequests: number, requestedClues: Array<string>, slides: Array<string>, stars: number, step: {current: number}, variables: {[_: string]: string | boolean | number}, viewedResources: Array<{ref: string, resources: Array<string>, type: mixed /* UNEXPECTED TYPE: EvalT */}>}) => {content?: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}} & {allAnswers: Array<{answer: Array<string>, isCorrect: ?boolean, slideRef: string}>, content?: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, hasViewedAResourceAtThisStep: boolean, isCorrect: ?boolean, lives: number, livesDisabled?: boolean, nextContent?: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, remainingLifeRequests: number, requestedClues: Array<string>, slides: Array<string>, stars: number, step: {current: number}, variables: {[_: string]: string | boolean | number}, viewedResources: Array<{ref: string, resources: Array<string>, type: mixed /* UNEXPECTED TYPE: EvalT */}>};