Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
fix: charna updates merged
Browse files Browse the repository at this point in the history
  • Loading branch information
villetakanen committed Dec 2, 2021
1 parent 1a1cd06 commit af8ae8f
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 20 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@vuelidate/validators": "^2.0.0-alpha.21",
"algoliasearch": "^4.10.5",
"axios": "^0.21.4",
"charna": "^0.1.2",
"charna": "^0.1.3",
"downscale": "^1.0.6",
"firebase": "^9.0.2",
"luxon": "^2.0.2",
Expand Down
42 changes: 32 additions & 10 deletions src/components/character/CharacterSheet.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<template>
<div class="CharacterSheet">
<div
v-for="key in character.statKeys()"
:key="key"
<template
v-for="k in Object.keys(layout)"
:key="k"
>
<CharacterStat
:character="character"
:stat="key"
/>
</div>
<template v-if="typeof layout[k] === 'string'">
<CharacterStat
:character="character"
:stat="k"
/>
</template>
</template>
</div>
</template>

Expand All @@ -17,8 +19,22 @@ import { useAuth } from '@/state/authz'
import { useCharacters } from '@/state/characters'
import { Character } from '@/state/characters/Character'
import { logDebug } from '@/utils/eventLogger'
import { computed, defineComponent } from 'vue'
import { computed, ComputedRef, defineComponent } from 'vue'
import CharacterStat from './CharacterStat.vue'
import defautsheet from '@/layouts/default.layout.json'
import ddsheet from '@/layouts/dd5.layout.json'
interface ThirdLevelNode {
[key: string]: string | Array<string>
}
interface SecondLevelNode {
[key: string]: string | Array<string> | ThirdLevelNode
}
interface LayoutNode {
[key: string]: string | SecondLevelNode | Array<string | SecondLevelNode>
}
export default defineComponent({
name: 'CharacterSheet',
Expand All @@ -37,7 +53,13 @@ export default defineComponent({
const c = characters.value.get(props.id) || new Character('-')
return c
})
return { character, profileData }
const layout:ComputedRef<LayoutNode> = computed(() => {
if (character.value.characterSheetType === 'dd') {
return ddsheet
}
return defautsheet
})
return { character, profileData, layout }
}
})
</script>
Expand Down
5 changes: 5 additions & 0 deletions src/layouts/dd5.layout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"top": [
{ "abilities": [ "strength" ] }
]
}
3 changes: 3 additions & 0 deletions src/layouts/default.layout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "description"
}
2 changes: 1 addition & 1 deletion src/state/characters/basicCharacterSheet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "Basic Charactersheet",
"name": "Basic Charactersheet",
"stats": {
"description": {
"type": "string",
Expand Down
6 changes: 5 additions & 1 deletion src/state/characters/ddCharSheet.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"id": "D&D 5th edition sheet redacted variant",
"name": "D&D 5th edition sheet redacted variant",
"stats": {
"description": {
"type": "string",
"initialValue": "..."
},
"strength": {
"type": "number",
"initialValue": 10
Expand Down

0 comments on commit af8ae8f

Please sign in to comment.