From 919de0d5dd63e67bcdf7b9c812aada2ecf8b52a4 Mon Sep 17 00:00:00 2001 From: Damnae Date: Fri, 2 Feb 2024 17:40:28 +0100 Subject: [PATCH] Add global task templates. --- src/main.ts | 11 +++++ src/sources/ability.ts | 47 +++++++++++++++---- src/views/abilities/AnyTaskTemplate.vue | 17 +++++++ src/views/abilities/TaskTemplate.vue | 42 +++++++++++++++++ .../components/ProvideTaskTemplateContext.vue | 39 +++++++++++++++ src/views/navigation-main/CommitNav.vue | 10 +++- src/views/navigation-main/TaskTemplateNav.vue | 30 ++++++++++++ 7 files changed, 185 insertions(+), 11 deletions(-) create mode 100644 src/views/abilities/AnyTaskTemplate.vue create mode 100644 src/views/abilities/TaskTemplate.vue create mode 100644 src/views/abilities/components/ProvideTaskTemplateContext.vue create mode 100644 src/views/navigation-main/TaskTemplateNav.vue diff --git a/src/main.ts b/src/main.ts index 37ab7d1..f3dc857 100644 --- a/src/main.ts +++ b/src/main.ts @@ -42,6 +42,8 @@ import RogueBuffModifier from './views/abilities/RogueBuffModifier.vue' import AnyAbility from './views/abilities/AnyAbility.vue' import AnyModifier from './views/abilities/AnyModifier.vue' +import AnyTaskTemplate from './views/abilities/AnyTaskTemplate.vue' + import TargetAlias from './views/pages/TargetAlias.vue' import TargetAliases from './views/pages/TargetAliases.vue' @@ -195,6 +197,13 @@ const routes:Readonly = meta: { mainNav: 'Modifier', mainNavTab:'Global', } }, + // Task Templates + { path: '/tasktemplate-:taskTemplateId/@:commitId', + name: 'tasktemplate', components: { default: AnyTaskTemplate, }, + props:{ default:toRouteProps({ }) }, + meta: { mainNav: 'TaskTemplate', mainNavTab:'Global', } + }, + // Misc Pages { path: '/targetalias-:aliasId/@:commitId', name: 'targetAlias', components: { default: TargetAlias, }, @@ -241,6 +250,8 @@ const routes:Readonly = { path: '/ability-:abilityId', meta: { redirectName:'ability' }, redirect: redirectToLatestCommit }, { path: '/modifier-:modifierId', meta: { redirectName:'modifier' }, redirect: redirectToLatestCommit }, + { path: '/tasktemplate-:tasktemplateId', meta: { redirectName:'tasktemplate' }, redirect: redirectToLatestCommit }, + { path: '/targetalias-:aliasId', meta: { redirectName:'targetAlias' }, redirect: redirectToLatestCommit }, { path: '/targetaliases', meta: { redirectName:'targetAliases' }, redirect: redirectToLatestCommit }, diff --git a/src/sources/ability.ts b/src/sources/ability.ts index f90787b..ddd26b6 100644 --- a/src/sources/ability.ts +++ b/src/sources/ability.ts @@ -152,6 +152,7 @@ export enum TaskContextType BattleEvent = 'BattleEvent', Level = 'Level', Rogue = 'Rogue', + TaskTemplate = 'TaskTemplate', } const contextTypeToPaths = @@ -305,6 +306,15 @@ const contextTypeToPaths = 'Config/ConfigGlobalTaskListTemplate/GlobalTaskListTemplate.json', ], }, + TaskTemplate: + { + Abilities: [], + Modifiers: [], + TaskListTemplates: + [ + 'Config/ConfigGlobalTaskListTemplate/GlobalTaskListTemplate.json', + ], + }, Empty: { Abilities: [], @@ -357,6 +367,12 @@ if (settings.includeWhiteBox) 'Config/ConfigAbility/WhiteBox/BattleEvent', 'Config/ConfigAbility/WhiteBox/Monster', ]) + contextTypeToPaths.All.TaskListTemplates = contextTypeToPaths.All.TaskListTemplates.concat([ + 'Config/ConfigGlobalTaskListTemplate', + ]) + contextTypeToPaths.TaskTemplate.TaskListTemplates = contextTypeToPaths.TaskTemplate.TaskListTemplates.concat([ + 'Config/ConfigGlobalTaskListTemplate', + ]) } const taskContextCache:{[commitId: string]: {[type: string]: TaskContext}} = {} @@ -407,7 +423,17 @@ export async function getTaskContext(commitId:string, type:TaskContextType) : Pr } for (const path of paths.TaskListTemplates) + if (path.endsWith('.json')) mergeTaskListTemplateConfig(context, await getTaskListTemplates(commitId, path) as TaskListTemplateConfig) + else + { + const response = await retrieveJson(`git/trees/${commitId}:${path}`, commitId, true) + const tree = response.tree + if (tree !== undefined) + for (const treePath of tree.map((t:any) => t.path)) + if (treePath.endsWith('.json')) + mergeTaskListTemplateConfig(context, await getTaskListTemplates(commitId, `${path}/${treePath}`) as TaskListTemplateConfig) + } result = container[type] = context console.log(`cached ${type} ability context for ${commitId}`) @@ -480,15 +506,16 @@ function mergeAbilityConfig(into:TaskContext, from:AbilityConfig) if (!from) return; - for (const ability of from.AbilityList) - { - let nameIndex = 2 - const originalName = ability.Name - while (ability.Name in into.Abilities) - ability.Name = `${originalName}#${nameIndex++}` + if (from.AbilityList !== undefined) + for (const ability of from.AbilityList) + { + let nameIndex = 2 + const originalName = ability.Name + while (ability.Name in into.Abilities) + ability.Name = `${originalName}#${nameIndex++}` - into.Abilities[ability.Name] = ability - } + into.Abilities[ability.Name] = ability + } if (from.GlobalModifiers !== undefined) for (const modifier of Object.values(from.GlobalModifiers)) @@ -515,7 +542,7 @@ function mergeAbilityConfig(into:TaskContext, from:AbilityConfig) function mergeModifierConfig(into:TaskContext, from:ModifierConfig) { - if (!from) + if (!from?.ModifierMap) return; for (const modifier of Object.values(from.ModifierMap)) @@ -531,7 +558,7 @@ function mergeModifierConfig(into:TaskContext, from:ModifierConfig) function mergeTaskListTemplateConfig(into:TaskContext, from:TaskListTemplateConfig) { - if (!from) + if (!from?.TaskListTemplate) return; for (const template of from.TaskListTemplate) diff --git a/src/views/abilities/AnyTaskTemplate.vue b/src/views/abilities/AnyTaskTemplate.vue new file mode 100644 index 0000000..20f44ec --- /dev/null +++ b/src/views/abilities/AnyTaskTemplate.vue @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file diff --git a/src/views/abilities/TaskTemplate.vue b/src/views/abilities/TaskTemplate.vue new file mode 100644 index 0000000..6d8afa5 --- /dev/null +++ b/src/views/abilities/TaskTemplate.vue @@ -0,0 +1,42 @@ + + + + + \ No newline at end of file diff --git a/src/views/abilities/components/ProvideTaskTemplateContext.vue b/src/views/abilities/components/ProvideTaskTemplateContext.vue new file mode 100644 index 0000000..e1e9a22 --- /dev/null +++ b/src/views/abilities/components/ProvideTaskTemplateContext.vue @@ -0,0 +1,39 @@ + + + + + \ No newline at end of file diff --git a/src/views/navigation-main/CommitNav.vue b/src/views/navigation-main/CommitNav.vue index a105600..f085385 100644 --- a/src/views/navigation-main/CommitNav.vue +++ b/src/views/navigation-main/CommitNav.vue @@ -10,6 +10,7 @@ import StatusNav from './StatusNav.vue' import AbilityNav from './AbilityNav.vue' import ModifierNav from './ModifierNav.vue' + import TaskTemplateNav from './TaskTemplateNav.vue' import RogueBuffNav from './RogueBuffNav.vue' import NavTabs from '@/components/NavTabs.vue' @@ -29,7 +30,7 @@ All: ['Avatar', 'Monster', 'BattleEvent', 'Equipment', 'RelicSet', 'Status', 'Ability', 'Modifier', 'RogueBuff', 'RogueMiracle', 'Misc'], Players: ['Avatar', 'Equipment', 'RelicSet'], NPC: ['Monster', 'BattleEvent'], - Global: ['Status', 'Ability', 'Modifier'], + Global: ['Status', 'Ability', 'Modifier', 'TaskTemplate'], 'Simulated Universe': ['RogueBuff', 'RogueMiracle'], } @@ -106,6 +107,13 @@ + + + + + + + diff --git a/src/views/navigation-main/TaskTemplateNav.vue b/src/views/navigation-main/TaskTemplateNav.vue new file mode 100644 index 0000000..b62e2a4 --- /dev/null +++ b/src/views/navigation-main/TaskTemplateNav.vue @@ -0,0 +1,30 @@ + + + + + \ No newline at end of file