Skip to content

Commit

Permalink
Display avatar auto factors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Damnae committed Feb 24, 2024
1 parent b35783a commit 9ba08ba
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 42 deletions.
48 changes: 48 additions & 0 deletions src/sources/autofactorgroup.ts
Original file line number Diff line number Diff line change
@@ -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<AIFactorGroupConfig>
{
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<AIFactorGroup>
{
return (await getAIFactorGroups(commitId)).GroupsMap[id]
}
20 changes: 10 additions & 10 deletions src/sources/character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 19 additions & 32 deletions src/views/aside/AvatarAI.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>('commitId') as string
Expand Down Expand Up @@ -47,42 +48,28 @@ import { cleanupNumber } from '@/common/common';
{{ Object.keys(character.AITagList.Values).map(hash => hashStore.translate(parseInt(hash)) ?? hash).join(', ') }}
</template>

<template v-for="skill in character.SkillList">
<template v-if="skill.ComplexSkillAIPreCheck || skill.ComplexSkillAI">
<h2>{{ skill.Name }}</h2>
<ProvideEmptyContext :commitId="commitId">
<template v-for="skill in character.SkillList">
<template v-if="skill.ComplexSkillAIPreCheck || skill.ComplexSkillAI">
<h2>{{ skill.Name }}</h2>

<template v-if="skill.ComplexSkillAIPreCheck">
<h3>Precheck Weights</h3>
<ul>
<li v-for="weightGroup in skill.ComplexSkillAIPreCheck?.Groups">
{{ weightGroup.GroupName }}
{{ cleanupNumber(weightGroup.Weight?.Value ?? 1) }}
</li>
</ul>
<div class="minor" v-if="skill.ComplexSkillAIPreCheck?.SkillBasicPower">
Power: {{ cleanupNumber(skill.ComplexSkillAIPreCheck?.SkillBasicPower.Value) }}
</div>
</template>
<template v-if="skill.ComplexSkillAIPreCheck">
<h3>Precheck Weights</h3>
<AIWeights :weightData="skill.ComplexSkillAIPreCheck" />
</template>

<template v-if="skill.ComplexSkillAI">
<h3>Weights</h3>
<ul>
<li v-for="weightGroup in skill.ComplexSkillAI?.Groups">
{{ weightGroup.GroupName }}
{{ cleanupNumber(weightGroup.Weight?.Value ?? 1) }}
</li>
</ul>
<div class="minor" v-if="skill.ComplexSkillAI?.SkillBasicPower">
Power: {{ cleanupNumber(skill.ComplexSkillAI?.SkillBasicPower.Value) }}
</div>
</template>
<template v-if="skill.ComplexSkillAI">
<h3>Weights</h3>
<AIWeights :weightData="skill.ComplexSkillAI" />
</template>

<div class="minor" v-if="skill.AIUltraSkillPriority">
Priority: {{ skill.AIUltraSkillPriority }}
</div>
<div class="minor" v-if="skill.AIUltraSkillPriority">
Priority: {{ skill.AIUltraSkillPriority }}
</div>

</template>
</template>
</template>
</ProvideEmptyContext>

</section>
</template>
Expand Down
24 changes: 24 additions & 0 deletions src/views/aside/components/AIWeight.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script setup lang="ts">
import { ref, inject, } from 'vue';
import { cleanupNumber } from '@/common/common';
import { CharacterSkillAIWeightGroup } from '@/sources/character';
import { AIFactorGroup, getAIFactorGroup } from '@/sources/autofactorgroup';
import AnyTask from '@/gamecore/AnyTask.vue';
const props = defineProps<{weightGroup:CharacterSkillAIWeightGroup}>()
const commitId = inject<string>('commitId') as string
const aiFactorGroup = ref<AIFactorGroup>(await getAIFactorGroup(commitId, props.weightGroup.GroupName))
</script>

<template>
{{ weightGroup.GroupName }}
{{ cleanupNumber(weightGroup.Weight?.Value ?? 1) }}

<!-- <div class="minor">{{ aiFactorGroup.CombineOperator ?? "Add" }}</div> -->
<template v-for="factor in aiFactorGroup.Factors">
<div class="minor">{{ factor.CombineOperator ?? "Add" }}</div>
<AnyTask :node="factor.Source" />
<AnyTask :node="factor.Mapper" />
</template>
</template>
18 changes: 18 additions & 0 deletions src/views/aside/components/AIWeights.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script setup lang="ts">
import { cleanupNumber } from '@/common/common';
import { CharacterSkillAIWeightData } from '@/sources/character';
import AIWeight from './AIWeight.vue';
defineProps<{weightData:CharacterSkillAIWeightData}>()
</script>

<template>
<ul>
<li v-for="weightGroup in weightData?.Groups">
<AIWeight :weightGroup="weightGroup" />
</li>
</ul>
<div class="minor" v-if="weightData?.SkillBasicPower">
Power: {{ cleanupNumber(weightData?.SkillBasicPower.Value) }}
</div>
</template>

0 comments on commit 9ba08ba

Please sign in to comment.