2022-01-09 19:28:09 -08:00
< template >
2022-01-14 22:03:41 -08:00
< div
class = "wrapper container max-h-full h-full w-full mx-auto px-4"
: class = "`bg-${activeTab.darkColor}`"
>
2022-01-09 22:08:59 -08:00
< main
class = "grid w-full h-full overflow-auto relative"
2022-01-10 02:16:25 -08:00
: class = "`bg-${activeTab.color}`"
2022-01-09 22:08:59 -08:00
>
2022-01-09 20:33:09 -08:00
< time-header / >
2022-01-09 19:28:09 -08:00
2022-01-09 23:11:55 -08:00
< key-art-stage / >
2022-01-09 19:28:09 -08:00
2022-01-10 02:16:25 -08:00
< div class = "grid grid-cols-6 gap-1 w-full h-10 relative" >
2022-01-09 19:28:09 -08:00
< game-tab
2022-01-10 02:16:25 -08:00
v - for = "tab in $store.state.tabs"
: key = "tab.route"
2022-01-09 19:28:09 -08:00
: tab - data = "tab"
/ >
< / div >
< div
2022-01-09 23:11:55 -08:00
class = "tab-content px-4 w-full relative overflow-y-scroll"
2022-01-09 19:28:09 -08:00
: class = "activeTabColorClasses"
>
2022-01-09 23:11:55 -08:00
< div
2022-01-13 13:02:43 -08:00
class = "tab-title w-full text-2xl text-center pt-1 pb-2"
2022-01-10 02:16:25 -08:00
v - text = "activeTab.title"
2022-01-09 23:11:55 -08:00
/ >
2022-01-09 19:28:09 -08:00
< nuxt / >
< / div >
< / main >
2022-01-13 23:15:32 -08:00
< narrative-modal v-if = "$store.state.modalIsOpen" / >
2022-01-09 19:28:09 -08:00
< / div >
< / template >
< script >
2022-01-10 02:16:25 -08:00
import { mapGetters } from 'vuex'
2022-01-09 19:28:09 -08:00
export default {
computed : {
2022-01-10 02:16:25 -08:00
... mapGetters ( [ 'activeTab' ] ) ,
2022-01-09 19:28:09 -08:00
activeTabColorClasses ( ) {
2022-01-10 02:16:25 -08:00
return ` bg- ${ this . activeTab . lightColor } text- ${ this . activeTab . darkColor } `
2022-01-09 19:28:09 -08:00
} ,
} ,
mounted ( ) {
window . setInterval ( ( ) => {
2022-01-13 23:15:32 -08:00
if ( this . $store . state . modalIsOpen || this . $store . state . gameStopped ) return
if ( this . $store . state . playerAge < this . $store . state . playerAgeMax ) {
2022-01-10 18:38:43 -05:00
this . gametick ( )
2022-01-13 23:15:32 -08:00
} else {
this . checkLossCondition ( )
}
2022-01-10 02:16:25 -08:00
} , 100 )
2022-01-09 19:28:09 -08:00
window . setInterval ( ( ) => {
2022-01-13 23:15:32 -08:00
if ( this . $store . state . modalIsOpen || this . $store . state . gameStopped ) return
2022-01-10 18:38:43 -05:00
if ( this . $store . state . playerAge < this . $store . state . playerAgeMax )
this . $store . commit ( 'tickGameDate' )
2022-01-09 22:25:55 -08:00
} , 1000 )
2022-01-09 19:28:09 -08:00
} ,
methods : {
gametick ( ) {
2022-01-11 22:23:41 -08:00
// Instruments tick
2022-01-10 02:16:25 -08:00
this . $store . state . processes
. filter ( ( p ) => p . created )
2022-01-13 23:15:32 -08:00
. forEach ( ( process ) => {
2022-01-10 02:16:25 -08:00
if ( process . completion >= process . completionRequired ) {
2022-01-10 22:06:03 -08:00
const reward = process . baseReward * ( 1 + process . workerLevel )
this . $store . commit ( 'addCurrency' , reward )
2022-01-11 20:24:29 -08:00
this . $store . commit ( 'resetProcess' , { process } )
2022-01-10 02:16:25 -08:00
}
2022-01-11 20:24:29 -08:00
this . $store . commit ( 'tickProcess' , { process } )
2022-01-09 19:28:09 -08:00
} )
2022-01-11 22:23:41 -08:00
// Energy ticks
if (
this . $store . getters . isTabUnlocked ( 'Time Machine' ) &&
this . $store . state . energy < this . $store . state . energyMax
) {
this . $store . commit ( 'tickEnergy' )
}
2022-01-09 19:28:09 -08:00
} ,
2022-01-13 23:15:32 -08:00
checkLossCondition ( ) {
this . $store . commit ( 'stopGame' )
// End state
const lostTheGame =
this . $store . state . playerAge === this . $store . state . playerAgeMax &&
! this . $store . getters . isTabUnlocked ( 'Time Machine' )
if ( lostTheGame ) {
const message =
'You wasted your precious time your whole life with nothing to show for it.' +
'<br><br>' +
'You have lost the game. Reload the page and try again.'
this . $store . commit ( 'openModal' , message )
} else {
const message =
"You are too frail to continue. It's time to gather your knowledge into a book and " +
'send it, along with the time machine and your timekeeping instruments, to your younger self. ' +
'Hopefully they will know what to do with this valuable wisdom.' +
'<br><br>' +
'Go to the <b>Missions</b> tab to continue.'
this . $store . commit ( 'openModal' , message )
}
} ,
2022-01-09 19:28:09 -08:00
} ,
}
< / script >
< style >
2022-01-13 19:57:35 -08:00
@ import url ( 'https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;800&family=Roboto+Slab:wght@600&display=swap' ) ;
2022-01-13 13:02:43 -08:00
2022-01-09 19:28:09 -08:00
html ,
body ,
# _ _nuxt ,
# _ _layout {
height : 100 % ; /* 100vh is broken on mobile. this is the fix. */
width : 100 vw ;
}
html {
background : # e5e7eb ;
overflow - y : hidden ;
2022-01-13 13:02:43 -08:00
font - family : 'Manrope' , sans - serif ;
2022-01-09 19:28:09 -08:00
}
< / style >
< style scoped >
2022-01-14 22:03:41 -08:00
. wrapper {
transition : background - color 2000 ms ;
}
2022-01-09 19:28:09 -08:00
main {
2022-01-09 23:11:55 -08:00
grid - template - rows : auto minmax ( 0 , 2 fr ) auto minmax ( 0 , 3 fr ) ;
2022-01-09 22:08:59 -08:00
transition : background - color 2000 ms ;
2022-01-09 19:28:09 -08:00
}
2022-01-13 13:02:43 -08:00
. tab - title {
font - family : 'Roboto Slab' , serif ;
}
2022-01-09 19:28:09 -08:00
< / style >