diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-05-01 09:15:29 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-05-01 09:15:29 +0900 |
| commit | d0c8d537f59a1e25394407f963be78de2d80f0fa (patch) | |
| tree | 192613c8ceb98c4ecd6a306572b2aeeb152c59ff /src | |
| parent | Improve API doc (diff) | |
| download | sharkey-d0c8d537f59a1e25394407f963be78de2d80f0fa.tar.gz sharkey-d0c8d537f59a1e25394407f963be78de2d80f0fa.tar.bz2 sharkey-d0c8d537f59a1e25394407f963be78de2d80f0fa.zip | |
Refactor
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/app/common/scripts/aiscript.ts | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/client/app/common/scripts/aiscript.ts b/src/client/app/common/scripts/aiscript.ts index 99caec8c15..765d740e23 100644 --- a/src/client/app/common/scripts/aiscript.ts +++ b/src/client/app/common/scripts/aiscript.ts @@ -80,16 +80,22 @@ const funcDefs = { dailyRandomPick: { in: [0], out: 0, category: 'random', icon: faDice, }, }; +const literalDefs = { + text: { out: 'string', category: 'value', icon: faQuoteRight, }, + multiLineText: { out: 'string', category: 'value', icon: faAlignLeft, }, + textList: { out: 'stringArray', category: 'value', icon: faList, }, + number: { out: 'number', category: 'value', icon: faSortNumericUp, }, + ref: { out: null, category: 'value', icon: faSuperscript, }, + in: { out: null, category: 'value', icon: faSuperscript, }, + fn: { out: 'function', category: 'value', icon: faSuperscript, }, +}; + const blockDefs = [ - { type: 'text', out: 'string', category: 'value', icon: faQuoteRight, }, - { type: 'multiLineText', out: 'string', category: 'value', icon: faAlignLeft, }, - { type: 'textList', out: 'stringArray', category: 'value', icon: faList, }, - { type: 'number', out: 'number', category: 'value', icon: faSortNumericUp, }, - { type: 'ref', out: null, category: 'value', icon: faSuperscript, }, - { type: 'in', out: null, category: 'value', icon: faSuperscript, }, - { type: 'fn', out: 'function', category: 'value', icon: faSuperscript, }, + ...Object.entries(literalDefs).map(([k, v]) => ({ + type: k, out: v.out, category: v.category, icon: v.icon + })), ...Object.entries(funcDefs).map(([k, v]) => ({ - type: k, out: v.out || null, category: v.category, icon: v.icon + type: k, out: v.out, category: v.category, icon: v.icon })) ]; @@ -170,13 +176,7 @@ export class AiScript { @autobind public static isLiteralBlock(v: Block) { if (v.type === null) return true; - if (v.type === 'text') return true; - if (v.type === 'multiLineText') return true; - if (v.type === 'textList') return true; - if (v.type === 'number') return true; - if (v.type === 'ref') return true; - if (v.type === 'fn') return true; - if (v.type === 'in') return true; + if (literalDefs[v.type]) return true; return false; } |