Skip to content

Commit

Permalink
add SR/WH difficulty
Browse files Browse the repository at this point in the history
  • Loading branch information
swantzter committed Aug 24, 2024
1 parent 6bd3b9a commit faf1e01
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 4 deletions.
24 changes: 21 additions & 3 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function servoSpeedConverter (scoresheet: ServoIntermediateScoresheet<import('./

const models: Model[] = [
{
rulesId: ['[email protected]', '[email protected]', '[email protected]', '[email protected]', 'svgf-rh@2020', '[email protected]', 'svgf-vh@2023', 'ijru.speed.2020'],
rulesId: ['[email protected]', '[email protected]', '[email protected]', 'ijru.speed@4.0.0', 'svgf-rh@2020', '[email protected]', 'svgf-vh@2023', 'ijru.speed.2020'],
judgeType: 'S',
name: 'Speed',
component: defineAsyncComponent(async () => await import('./views/scoring/[email protected]/Speed.vue')),
Expand All @@ -109,7 +109,7 @@ const models: Model[] = [
}
},
{
rulesId: ['[email protected]', '[email protected]', '[email protected]', '[email protected]', 'svgf-rh@2020', '[email protected]', 'ijru.speed.2020'],
rulesId: ['[email protected]', '[email protected]', '[email protected]', 'ijru.speed@4.0.0', 'svgf-rh@2020', '[email protected]', 'ijru.speed.2020'],
judgeType: 'Shj',
name: 'Speed Head Judge',
component: defineAsyncComponent(async () => await import('./views/scoring/[email protected]/Speed.vue')),
Expand Down Expand Up @@ -199,6 +199,24 @@ const models: Model[] = [
}
}
},
// {
// rulesId: ['[email protected]'],
// judgeType: 'Dt',
// name: 'Turner Difficulty (Double Dutch)',
// component: defineAsyncComponent(async () => await import('./views/scoring/[email protected]/DDTurnerDifficulty.vue'))
// },
// {
// rulesId: ['[email protected]'],
// judgeType: 'Dj',
// name: 'Jumper Difficulty (Double Dutch)',
// component: defineAsyncComponent(async () => await import('./views/scoring/[email protected]/DDJumperDifficulty.vue'))
// },
{
rulesId: ['[email protected]', '[email protected]'],
judgeType: ['Dp', 'Dm', 'Dr', 'Da', 'Db'],
name: 'Difficulty (Single Rope and Wheel)',
component: defineAsyncComponent(async () => await import('./views/scoring/[email protected]/SRWHDifficulty.vue'))
},

{
rulesId: ['[email protected]', '[email protected]'],
Expand Down Expand Up @@ -377,7 +395,7 @@ const models: Model[] = [
}
},
{
rulesId: ['[email protected]'],
rulesId: ['ijru[email protected]', '[email protected]', 'ijru.freestyle.wh@4.0.0'],
judgeType: 'P',
name: 'Presentation',
component: defineAsyncComponent(async () => await import('./views/scoring/[email protected]/Presentation.vue')),
Expand Down
4 changes: 3 additions & 1 deletion src/views/Score.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ watch(() => route.params, async (next, prev) => {
const model = computed(() => {
const sc = scsh.scoresheet.value
if (!sc) return null
const model = models.find(model => model.rulesId.includes(sc.rulesId) && model.judgeType === sc.judgeType)
const model = models.find(model => model.rulesId.includes(sc.rulesId) && (
Array.isArray(model.judgeType) ? model.judgeType.includes(sc.judgeType) : model.judgeType === sc.judgeType
))
if (!model) return null
if (model.allowScroll) {
Expand Down
83 changes: 83 additions & 0 deletions src/views/scoring/[email protected]/SRWHDifficulty.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<template>
<main class="grid grid-cols-3 grid-rows-score">
<score-button
color="orange"
label="Rep. Skill"
:value="tally('rep')"
:disabled="!!scoresheet?.completedAt"
single-row
@click="addMark({ schema: 'rep' })"
/>
<score-button
color="none"
label="Score"
:value="result"
single-row
/>
<score-button
color="orange"
label="Rep. Skill"
:value="tally('rep')"
:disabled="!!scoresheet?.completedAt"
single-row
@click="addMark({ schema: 'rep' })"
/>

<score-button
v-for="[schema, level] in levels"
:key="schema"
:color="level < 7 ? 'green' : 'indigo'"
:label="`Level ${level}`"
:value="tally(schema)"
:disabled="!!scoresheet?.completedAt"
@click="addMark({ schema })"
/>
</main>
</template>

<script lang="ts" setup>
import { computed } from 'vue'
import ScoreButton from '../../../components/ScoreButton.vue'
import { useScoresheet } from '../../../hooks/scoresheet'
import type { Model } from '../../../models'
import type { PropType } from 'vue'
export type Schema = `diffL${'0.5' | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}` | 'rep'
defineProps({
model: {
type: Object as PropType<Model>,
required: true
}
})
const { addMark, tally, scoresheet } = useScoresheet<Schema>()
function L (level: number): number {
if (level === 0) return 0
return Math.round(Math.pow(1.5, level) * 10) / 100
}
const levels = computed((): Array<[Schema, number]> => [
['diffL1', 1],
['diffL0.5', 0.5],
['diffL4', 4],
['diffL2', 2],
['diffL7', 7],
['diffL5', 5],
['diffL3', 3],
['diffL8', 8],
['diffL6', 6]
])
const result = computed(() => {
let res = 0
for (const [schema, level] of levels.value) {
res += L(level) * tally(schema)
}
return res
})
</script>

0 comments on commit faf1e01

Please sign in to comment.