From 9ba08ba637a9c3d32c2a4530a6e799082e9d5e86 Mon Sep 17 00:00:00 2001 From: Damnae Date: Sat, 21 Oct 2023 09:59:35 +0200 Subject: [PATCH] Display avatar auto factors. --- src/sources/autofactorgroup.ts | 48 ++++++++++++++++++++++ src/sources/character.ts | 20 +++++----- src/views/aside/AvatarAI.vue | 51 +++++++++--------------- src/views/aside/components/AIWeight.vue | 24 +++++++++++ src/views/aside/components/AIWeights.vue | 18 +++++++++ 5 files changed, 119 insertions(+), 42 deletions(-) create mode 100644 src/sources/autofactorgroup.ts create mode 100644 src/views/aside/components/AIWeight.vue create mode 100644 src/views/aside/components/AIWeights.vue diff --git a/src/sources/autofactorgroup.ts b/src/sources/autofactorgroup.ts new file mode 100644 index 0000000..32f366c --- /dev/null +++ b/src/sources/autofactorgroup.ts @@ -0,0 +1,48 @@ +import { retrieveJson } from '@/common/datasource'; +import { GamecoreTask } from './gamecore'; +import { Mutex } from '@/common/mutex'; + +export interface AIFactor +{ + CombineOperator: string + Source: GamecoreTask + Mapper: GamecoreTask +} + +export interface AIFactorGroup +{ + CombineOperator: string + Factors: AIFactor[] + IsBpGroup: boolean +} + +export interface AIFactorGroupConfig +{ + GroupsMap: + { + [key:string]: AIFactorGroup + } +} + +const aiFactorGroupConfigCache:{[commitId: string]: AIFactorGroupConfig} = {} +const aiFactorGroupConfigMutex = new Mutex() +export async function getAIFactorGroups(commitId:string) : Promise +{ + return aiFactorGroupConfigMutex.runExclusive(async () => + { + let config = aiFactorGroupConfigCache[commitId] + if (config == undefined) + { + const aiFactorGroups = await retrieveJson('Config/ConfigAI/ComplexSkillAIGlobalGroup/Global_FactorGroups.json', commitId, false) as AIFactorGroupConfig + + config = aiFactorGroupConfigCache[commitId] = aiFactorGroups + console.log('cached auto ai config for ' + commitId) + } + return config + }) +} + +export async function getAIFactorGroup(commitId:string, id:string) : Promise +{ + return (await getAIFactorGroups(commitId)).GroupsMap[id] +} \ No newline at end of file diff --git a/src/sources/character.ts b/src/sources/character.ts index bcb2ede..14137e9 100644 --- a/src/sources/character.ts +++ b/src/sources/character.ts @@ -4,22 +4,22 @@ import { Monster } from './monster'; import { DynamicValues } from './gamecore'; import { BattleEvent } from './battleevent'; +export interface CharacterSkillAIWeightGroup +{ + GroupName:string + Weight?: + { + Value: number + } +} + export interface CharacterSkillAIWeightData { SkillBasicPower?: { Value: number } - Groups: - [ - { - GroupName:string - Weight?: - { - Value: number - } - } - ] + Groups:CharacterSkillAIWeightGroup[] } export interface CharacterSkill diff --git a/src/views/aside/AvatarAI.vue b/src/views/aside/AvatarAI.vue index 6a4293e..565bbcf 100644 --- a/src/views/aside/AvatarAI.vue +++ b/src/views/aside/AvatarAI.vue @@ -6,7 +6,8 @@ import { Character, getCharacterByAvatar } from '@/sources/character'; import LoadingNav from '@/components/LoadingNav.vue'; -import { cleanupNumber } from '@/common/common'; + import ProvideEmptyContext from '@/views/abilities/components/ProvideEmptyContext.vue'; + import AIWeights from './components/AIWeights.vue'; const commitId = inject('commitId') as string @@ -47,42 +48,28 @@ import { cleanupNumber } from '@/common/common'; {{ Object.keys(character.AITagList.Values).map(hash => hashStore.translate(parseInt(hash)) ?? hash).join(', ') }} - diff --git a/src/views/aside/components/AIWeight.vue b/src/views/aside/components/AIWeight.vue new file mode 100644 index 0000000..709450c --- /dev/null +++ b/src/views/aside/components/AIWeight.vue @@ -0,0 +1,24 @@ + + + \ No newline at end of file diff --git a/src/views/aside/components/AIWeights.vue b/src/views/aside/components/AIWeights.vue new file mode 100644 index 0000000..946ccd2 --- /dev/null +++ b/src/views/aside/components/AIWeights.vue @@ -0,0 +1,18 @@ + + + \ No newline at end of file