2022-01-10 03:28:09 +00:00
|
|
|
<template>
|
2022-01-13 05:37:30 +00:00
|
|
|
<div class="md:pt-4 pt-2 pb-16">
|
2022-01-12 06:23:41 +00:00
|
|
|
<div
|
|
|
|
class="energy-bar relative mx-auto rounded-full overflow-hidden border-2"
|
|
|
|
:class="`text-${$store.getters.activeTab.color} border-${$store.getters.activeTab.darkColor}`"
|
|
|
|
>
|
|
|
|
<progress
|
|
|
|
class="absolute top-0 right-0 left-0 w-full h-full"
|
|
|
|
:max="$store.state.energyMax"
|
|
|
|
:value="$store.state.energy"
|
|
|
|
/>
|
|
|
|
<span
|
|
|
|
class="relative block pt-1 pb-2 text-center text-lg font-semibold"
|
|
|
|
:class="`text-${$store.getters.activeTab.darkColor}`"
|
|
|
|
>
|
|
|
|
<span class="mr-1"
|
|
|
|
>{{ $store.state.energy }} / {{ $store.state.energyMax }}</span
|
|
|
|
>
|
|
|
|
<span class="text-base pt-1 ml-2 fas fa-bolt" />
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
|
2022-01-14 03:57:35 +00:00
|
|
|
<p class="text-lg text-center py-2 border-b-2 border-current">
|
|
|
|
<b><span class="fas fa-bolt text-base" /> Energy</b>
|
|
|
|
is generated over time
|
|
|
|
</p>
|
|
|
|
|
2022-01-14 03:30:59 +00:00
|
|
|
<h2 class="text-xl font-semibold text-center pt-8">Upgrades</h2>
|
2022-01-13 05:37:30 +00:00
|
|
|
|
2022-01-13 21:02:43 +00:00
|
|
|
<responsive-grid class="pt-2 md:pt-4">
|
2022-01-13 05:37:30 +00:00
|
|
|
<max-energy-upgrade-button />
|
|
|
|
</responsive-grid>
|
|
|
|
|
2022-01-14 03:30:59 +00:00
|
|
|
<h2 class="text-xl font-semibold text-center pt-8">Time Travel</h2>
|
2022-01-13 05:37:30 +00:00
|
|
|
|
2022-01-13 21:02:43 +00:00
|
|
|
<responsive-grid class="pt-2 md:pt-4">
|
2022-01-12 06:23:41 +00:00
|
|
|
<progress-button
|
2022-01-13 05:37:30 +00:00
|
|
|
v-for="process in $store.state.processes"
|
|
|
|
:key="process.instrument"
|
|
|
|
:label="getLabel(process)"
|
|
|
|
:max="process.travelCost"
|
2022-01-12 06:23:41 +00:00
|
|
|
:value="$store.state.energy"
|
2022-01-13 05:37:30 +00:00
|
|
|
unit="energy"
|
|
|
|
:disabled="!isEnabled(process)"
|
|
|
|
@click="travelToEra(process)"
|
2022-01-12 06:23:41 +00:00
|
|
|
/>
|
|
|
|
</responsive-grid>
|
|
|
|
</div>
|
2022-01-10 03:28:09 +00:00
|
|
|
</template>
|
2022-01-12 06:23:41 +00:00
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
methods: {
|
2022-01-13 05:37:30 +00:00
|
|
|
getLabel(process) {
|
|
|
|
if (process.unlockEra === this.$store.state.gameEra) {
|
|
|
|
return process.unlockEra + ' (You Are Here)'
|
|
|
|
} else if (this.isEnabled(process)) {
|
|
|
|
return process.unlockEra
|
|
|
|
} else {
|
|
|
|
return '???'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
isEnabled(process) {
|
|
|
|
const isCurrentEra = process.unlockEra === this.$store.state.gameEra
|
2022-01-14 07:15:32 +00:00
|
|
|
|
2022-01-13 05:37:30 +00:00
|
|
|
if (isCurrentEra) {
|
|
|
|
return false
|
|
|
|
} else if (process.visited) {
|
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
const processes = this.$store.state.processes
|
|
|
|
const processIndex = processes.findIndex(
|
|
|
|
(p) => p.unlockEra === process.unlockEra
|
|
|
|
)
|
|
|
|
|
|
|
|
const earliestEraIndex = processes.findIndex((p) => p.visited)
|
|
|
|
const nextEarliestEraIndex = earliestEraIndex - 1
|
|
|
|
|
|
|
|
const latestEraIndex = processes.map((p) => p.visited).lastIndexOf(true)
|
|
|
|
const nextLatestEraIndex = latestEraIndex + 1
|
|
|
|
|
2022-01-14 07:15:32 +00:00
|
|
|
const middleAges = this.$store.state.processes.find(
|
|
|
|
(p) => p.unlockEra === 'Middle Ages'
|
|
|
|
)
|
|
|
|
|
2022-01-13 05:37:30 +00:00
|
|
|
return (
|
|
|
|
processIndex === nextEarliestEraIndex ||
|
2022-01-14 07:15:32 +00:00
|
|
|
(middleAges.visited && processIndex === nextLatestEraIndex)
|
2022-01-13 05:37:30 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
},
|
2022-01-12 06:23:41 +00:00
|
|
|
doAction(action) {
|
|
|
|
this.$store.commit('spendEnergy', action.cost)
|
|
|
|
if (action.name === 'Activate!') {
|
|
|
|
// do action-specific things
|
|
|
|
}
|
|
|
|
},
|
2022-01-13 05:37:30 +00:00
|
|
|
travelToEra(process) {
|
2022-01-14 07:15:32 +00:00
|
|
|
const hadBeenVisited = process.visited // save this before we time travel
|
|
|
|
|
2022-01-13 05:37:30 +00:00
|
|
|
this.$store.commit('spendEnergy', process.travelCost)
|
|
|
|
this.$store.commit('timeTravel', {
|
|
|
|
era: process.unlockEra,
|
|
|
|
month: process.minDateUnlocked,
|
|
|
|
})
|
2022-01-14 07:15:32 +00:00
|
|
|
|
|
|
|
if (process.unlockEra === 'Middle Ages' && !hadBeenVisited) {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
const message =
|
|
|
|
'Congratulations! ' +
|
|
|
|
"You've successfully traveled through time and landed in the year 1100" +
|
|
|
|
'... though it was rather hard on your body.'
|
|
|
|
|
|
|
|
this.$store.commit('openModal', message)
|
|
|
|
})
|
2022-01-13 05:37:30 +00:00
|
|
|
}
|
|
|
|
},
|
2022-01-12 06:23:41 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.energy-bar {
|
|
|
|
width: 75%;
|
|
|
|
}
|
|
|
|
/* progress bars for all browsers */
|
|
|
|
progress::-webkit-progress-bar {
|
|
|
|
background-color: rgba(255, 255, 255, 0.1);
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
progress {
|
|
|
|
color: currentColor;
|
|
|
|
background-color: rgba(255, 255, 255, 0.1);
|
|
|
|
}
|
|
|
|
progress::-webkit-progress-value {
|
|
|
|
background-color: currentColor;
|
|
|
|
}
|
|
|
|
progress::-moz-progress-bar {
|
|
|
|
background-color: currentColor;
|
|
|
|
}
|
|
|
|
</style>
|