diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2026-04-30 19:55:51 -0300 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2026-04-30 19:56:19 -0300 |
| commit | b320d174be0b114b70cae64112f3e584033d9e93 (patch) | |
| tree | f257e000a81fb489dd3a0ede9aa27ad2df31c6c4 /src/data/things/flash/FlashAct.js | |
| parent | 6c4c1eb9e963aa71a65a7d6f1b2cbdfa0f4416de (diff) | |
content, data: FlashSide.isolateActs, previous{Flash,Act}, etc preview
Diffstat (limited to 'src/data/things/flash/FlashAct.js')
| -rw-r--r-- | src/data/things/flash/FlashAct.js | 108 |
1 files changed, 107 insertions, 1 deletions
diff --git a/src/data/things/flash/FlashAct.js b/src/data/things/flash/FlashAct.js index 19412fdc..5d243241 100644 --- a/src/data/things/flash/FlashAct.js +++ b/src/data/things/flash/FlashAct.js @@ -1,4 +1,5 @@ import {input, V} from '#composite'; +import {atOffset} from '#sugar'; import Thing from '#thing'; import {isColor, isContentString, isString} from '#validators'; @@ -19,7 +20,8 @@ import { soupyFind, soupyReverse, thing, - thingList + thingList, + wikiData, } from '#composite/wiki-properties'; export class FlashAct extends Thing { @@ -85,9 +87,113 @@ export class FlashAct extends Thing { find: soupyFind(), reverse: soupyReverse(), + // used for nearbyActs + flashActData: wikiData(V(FlashAct)), + // Expose only isFlashAct: exposeConstant(V(true)), + + previousAct: { + flags: {expose: true}, + expose: { + dependencies: ['this', 'side', '_flashActData'], + compute({ + ['this']: thisFlashAct, + ['side']: ownSide, + ['_flashActData']: flashActData, + }) { + const indexIn = array => array.indexOf(thisFlashAct); + const isFirstIn = array => indexIn(array) === 0; + const previousIn = array => atOffset(array, indexIn(array), -1); + + if (isFirstIn(flashActData)) { + return null; + } + + if (isFirstIn(ownSide.acts)) { + if (ownSide.isolateActs) { + return null; + } else { + const lastInPreviousSide = previousIn(flashActData); + if (lastInPreviousSide.side.isolateActs) { + return null; + } else { + return lastInPreviousSide; + } + } + } + + return previousIn(ownSide.acts); + }, + }, + }, + + nextAct: { + flags: {expose: true}, + expose: { + dependencies: ['this', 'side', '_flashActData'], + compute({ + ['this']: thisFlashAct, + ['side']: ownSide, + ['_flashActData']: flashActData, + }) { + const indexIn = array => array.indexOf(thisFlashAct); + const isLastIn = array => indexIn(array) === array.length - 1; + const nextIn = array => atOffset(array, indexIn(array), +1); + + if (isLastIn(flashActData)) { + return null; + } + + if (isLastIn(ownSide.acts)) { + if (ownSide.isolateActs) { + return null; + } else { + const firstInNextSide = nextIn(flashActData); + if (firstInNextSide.side.isolateActs) { + return null; + } else { + return firstInNextSide; + } + } + } + + return nextIn(ownSide.acts); + }, + }, + }, + + previousActs: { + flags: {expose: true}, + expose: { + dependencies: ['previousAct'], + compute: ({previousAct}) => + (previousAct + ? [...previousAct.previousActs, previousAct] + : []), + }, + }, + + nextActs: { + flags: {expose: true}, + expose: { + dependencies: ['nextAct'], + compute: ({nextAct}) => + (nextAct + ? [nextAct, ...nextAct.nextActs] + : []), + }, + }, + + nearbyActs: { + flags: {expose: true}, + expose: { + dependencies: ['previousActs', 'nextActs', 'this'], + compute: ({previousActs, nextActs, this: thisAct}) => + [...previousActs, thisAct, ...nextActs], + }, + }, }); static [Thing.findSpecs] = { |