From 5332f6035ad8efdf1792b4413c5f99c2f2574eba Mon Sep 17 00:00:00 2001 From: John McCardle Date: Mon, 10 Jan 2022 21:09:32 -0500 Subject: [PATCH] feat: Display year/month durations via getters --- components/MissionButton.vue | 4 ++++ components/ProgressButton.vue | 16 +++++++++++++--- components/TimeHeader.vue | 19 +++++-------------- pages/Missions.vue | 7 ++----- store/index.js | 19 ++++++++++++++++--- 5 files changed, 40 insertions(+), 25 deletions(-) diff --git a/components/MissionButton.vue b/components/MissionButton.vue index e12e1f4..de7bfdc 100644 --- a/components/MissionButton.vue +++ b/components/MissionButton.vue @@ -4,6 +4,7 @@ :description="mission.description" :max="max" :value="value" + :unit="unit" @click="complete" /> @@ -24,6 +25,9 @@ export default { ? this.mission.completionCriteria.cost : this.$store.state.playerAgeMax }, + unit() { + return 'cost' in this.mission.completionCriteria ? 'spareTime' : 'age' + }, }, methods: { complete() { diff --git a/components/ProgressButton.vue b/components/ProgressButton.vue index 1185c7a..6ae83f1 100644 --- a/components/ProgressButton.vue +++ b/components/ProgressButton.vue @@ -13,8 +13,8 @@ /> - {{ cappedValue }} / {{ max }} - + {{ cappedValueText }} / {{ maxText }} + this.max ? this.max : this.value }, + cappedValueText() { + return this.unit === 'spareTime' + ? this.cappedValue + : this.$store.getters.ageText + }, + maxText() { + return this.unit === 'spareTime' + ? this.max + : this.$store.getters.ageMaxText + }, clickable() { return this.value >= this.max }, diff --git a/components/TimeHeader.vue b/components/TimeHeader.vue index 1390e75..5163da5 100644 --- a/components/TimeHeader.vue +++ b/components/TimeHeader.vue @@ -16,28 +16,19 @@ :max="$store.state.playerAgeMax" :value="$store.state.playerAge" /> - {{ ageText }} + {{ $store.getters.ageText }} -
+