Skip to content

Commit

Permalink
List avatar/monster ability modifiers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Damnae committed Sep 3, 2023
1 parent 341c802 commit 781b424
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 6 deletions.
17 changes: 15 additions & 2 deletions src/views/navigation/AvatarSubNav.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<script setup lang="ts">
import { ref, watchEffect, } from 'vue'
import { getAvatar, Avatar, } from '@/scripts/sources/avatar';
import { getAvatar, Avatar as AV, } from '@/scripts/sources/avatar';
import { getAvatarSkillsByIds, AvatarSkill, } from '@/scripts/sources/avatarskill';
import { getCharacterByAvatar, Character } from '@/scripts/sources/character';
import { AbilityContextType } from '@/scripts/sources/ability';
import CharacterSkillAbilitiesNav from './CharacterSkillAbilitiesNav.vue';
import CharacterOtherAbilitiesNav from './CharacterOtherAbilitiesNav.vue';
import CharacterModifiers from './CharacterModifiers.vue';
import NavTree from '@/components/NavTree.vue'
import NavItem from '@/components/NavItem.vue'
const props = defineProps<{commitId:string, objectId:number}>()
const avatar = ref<Avatar>()
const avatar = ref<AV>()
const avatarSkills = ref<AvatarSkill[]>([])
const character = ref<Character>()
Expand Down Expand Up @@ -99,6 +101,17 @@
</CharacterOtherAbilitiesNav>
</NavItem>

<NavItem v-if="character">
<NavTree>
<template #header>Modifiers</template>
<CharacterModifiers :character="character" :abilityContextType="AbilityContextType.Avatar" v-slot="slotProps">
<RouterLink :to="{ name:'avatarModifier', params:{ commitId: commitId, objectId: objectId, modifierId: slotProps.modifier, }}">
{{ slotProps.modifier }}
</RouterLink>
</CharacterModifiers>
</NavTree>
</NavItem>

</NavTree>
</template>
</template>
Expand Down
52 changes: 52 additions & 0 deletions src/views/navigation/CharacterModifiers.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<script setup lang="ts">
import { ref, watch, inject, } from 'vue'
import { Character } from '@/scripts/sources/character'
import { AbilityContextType, getAbilityContext, } from '@/scripts/sources/ability';
import NavItem from '@/components/NavItem.vue'
const props = defineProps<{character:Character, abilityContextType:AbilityContextType}>()
const commitId = inject<string>('commitId') as string
const modifiers = ref<string[]>([])
watch(props, async () =>
{
const abilityContext = await getAbilityContext(commitId, props.abilityContextType)
const mods:string[] = []
if (props.character)
{
for (const skillEntry of props.character.SkillAbilityList)
for (const abilityName of skillEntry.AbilityList)
{
const ability = abilityContext.Abilities[abilityName]
if (ability?.Modifiers)
for (const modifierName of Object.keys(ability.Modifiers))
mods.push(modifierName)
}
for (const abilityName of props.character.AbilityList)
{
const ability = abilityContext.Abilities[abilityName]
if (ability?.Modifiers)
for (const modifierName of Object.keys(ability.Modifiers))
mods.push(modifierName)
}
}
mods.sort((a, b) => a > b ? 1 : -1)
modifiers.value = mods
},
{ immediate:true })
</script>

<template>
<NavItem v-for="modifier in modifiers">
<span :title="modifier">
<slot :modifier="modifier" />
</span>
</NavItem>
</template>

<style scoped>
</style>
5 changes: 3 additions & 2 deletions src/views/navigation/CharacterSkillAbilitiesNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
abilities.value = []
if (props.character)
for (const sa of props.character.SkillAbilityList)
{
if (sa.Skill == props.skillTriggerKey)
{
abilities.value = sa.AbilityList
}
break
}
abilities.value.sort((a, b) => a > b ? 1 : -1)
})
</script>
Expand Down
20 changes: 18 additions & 2 deletions src/views/navigation/MonsterSubNav.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<script setup lang="ts">
import { ref, watchEffect, } from 'vue'
import { getMonster, Monster, } from '@/scripts/sources/monster.ts';
import { getMonster, Monster as MS, } from '@/scripts/sources/monster.ts';
import { getMonsterSkillsByIds, MonsterSkill, } from '@/scripts/sources/monsterskill';
import { getCharacterByMonster, Character } from '@/scripts/sources/character';
import { AbilityContextType } from '@/scripts/sources/ability';
import CharacterSkillAbilitiesNav from './CharacterSkillAbilitiesNav.vue';
import CharacterOtherAbilitiesNav from './CharacterOtherAbilitiesNav.vue';
import CharacterModifiers from './CharacterModifiers.vue';
import NavTree from '@/components/NavTree.vue'
import NavItem from '@/components/NavItem.vue'
const props = defineProps<{commitId:string, objectId:number}>()
const monster = ref<Monster>()
const monster = ref<MS>()
const monsterSkills = ref<MonsterSkill[]>([])
const character = ref<Character>()
Expand All @@ -29,6 +31,7 @@
<h1>{{ monster.MonsterName.Text }}</h1>
<span v-if="!character" class="minor">(Missing character data)</span>
<NavTree>

<NavItem>
<NavTree :startsOpen="true">
<template #header>Skills</template>
Expand All @@ -48,6 +51,7 @@
</NavItem>
</NavTree>
</NavItem>

<NavItem v-if="character">
<CharacterOtherAbilitiesNav :character="character">
<template #header>Other Abilities</template>
Expand All @@ -58,6 +62,18 @@
</template>
</CharacterOtherAbilitiesNav>
</NavItem>

<NavItem v-if="character">
<NavTree>
<template #header>Modifiers</template>
<CharacterModifiers :character="character" :abilityContextType="AbilityContextType.Monster" v-slot="slotProps">
<RouterLink :to="{ name:'monsterModifier', params:{ commitId: commitId, objectId: objectId, modifierId: slotProps.modifier, }}">
{{ slotProps.modifier }}
</RouterLink>
</CharacterModifiers>
</NavTree>
</NavItem>

</NavTree>
</template>
</template>
Expand Down

0 comments on commit 781b424

Please sign in to comment.