UNPKG

3.05 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../src/reducers/stars.js"],"names":["stars","config","currentStars","action","state","type","answerAction","payload","instructions","isCorrect","starsPerCorrectAnswer","requestedClueAction","slideRef","content","ref","requestedClues","starsPerAskingClue","contentResourceViewedAction","contentRef","contentType","contentResourceAlreadyViewed","Boolean","viewedResources","starsPerResourceViewed"],"mappings":";;AAaA,eAAe,SAASA,KAAT,CAAeC,MAAf,EAAkE;AAC/E,SAAO,CAACC,YAAoB,GAAG,CAAxB,EAA2BC,MAA3B,EAA2CC,KAA3C,KAAoE;AACzE,YAAQD,MAAM,CAACE,IAAf;AACE,WAAK,QAAL;AAAe;AACb,gBAAMC,YAAY,GAAIH,MAAtB;AACA,iBAAO,CAACG,YAAY,CAACC,OAAb,CAAqBC,YAAtB,IAAsCF,YAAY,CAACC,OAAb,CAAqBE,SAA3D,GACHP,YAAY,GAAGD,MAAM,CAACS,qBADnB,GAEHR,YAFJ;AAGD;;AACD,WAAK,MAAL;AAAa;AACX,gBAAMS,mBAAmB,GAAIR,MAA7B;AACA,gBAAMS,QAAQ,GAAGD,mBAAmB,CAACJ,OAApB,CAA4BM,OAA5B,CAAoCC,GAArD;AACA,iBAAO,UAASF,QAAT,EAAmBR,KAAK,CAACW,cAAzB,IACHb,YADG,GAEHA,YAAY,GAAGD,MAAM,CAACe,kBAF1B;AAGD;;AACD,WAAK,UAAL;AAAiB;AACf,gBAAMC,2BAA2B,GAAId,MAArC;AACA,gBAAMe,UAAU,GAAGD,2BAA2B,CAACV,OAA5B,CAAoCM,OAApC,CAA4CC,GAA/D;AACA,gBAAMK,WAAW,GAAGF,2BAA2B,CAACV,OAA5B,CAAoCM,OAApC,CAA4CR,IAAhE;AACA,gBAAMe,4BAA4B,GAAGC,OAAO,CAC1C,MAAK;AAAChB,YAAAA,IAAI,EAAEc,WAAP;AAAoBL,YAAAA,GAAG,EAAEI;AAAzB,WAAL,EAA2Cd,KAAK,CAACkB,eAAjD,CAD0C,CAA5C;;AAGA,cAAIF,4BAAJ,EAAkC;AAChC,mBAAOlB,YAAP;AACD;;AACD,iBAAOA,YAAY,GAAGD,MAAM,CAACsB,sBAA7B;AACD;;AACD;AACE,eAAOrB,YAAP;AA3BJ;AA6BD,GA9BD;AA+BD","sourcesContent":["// @flow\n\nimport {find, includes} from 'lodash/fp';\n\nimport type {\n Action,\n AnswerAction,\n AskClueAction,\n Config,\n ContentResourceViewedAction,\n State\n} from '../types';\n\nexport default function stars(config: Config): (number, Action, State) => number {\n return (currentStars: number = 0, action: Action, state: State): number => {\n switch (action.type) {\n case 'answer': {\n const answerAction = (action: AnswerAction);\n return !answerAction.payload.instructions && answerAction.payload.isCorrect\n ? currentStars + config.starsPerCorrectAnswer\n : currentStars;\n }\n case 'clue': {\n const requestedClueAction = (action: AskClueAction);\n const slideRef = requestedClueAction.payload.content.ref;\n return includes(slideRef, state.requestedClues)\n ? currentStars\n : currentStars + config.starsPerAskingClue;\n }\n case 'resource': {\n const contentResourceViewedAction = (action: ContentResourceViewedAction);\n const contentRef = contentResourceViewedAction.payload.content.ref;\n const contentType = contentResourceViewedAction.payload.content.type;\n const contentResourceAlreadyViewed = Boolean(\n find({type: contentType, ref: contentRef}, state.viewedResources)\n );\n if (contentResourceAlreadyViewed) {\n return currentStars;\n }\n return currentStars + config.starsPerResourceViewed;\n }\n default:\n return currentStars;\n }\n };\n}\n"],"file":"stars.js"}
\No newline at end of file