2022-01-09 19:28:09 -08:00
< template >
2022-01-09 20:33:09 -08:00
< div class = "page container max-h-full h-full w-full mx-auto bg-gray-400 px-4" >
2022-01-09 22:08:59 -08:00
< main
class = "grid w-full h-full overflow-auto relative"
: class = "`bg-${$store.getters.activeTab.color}`"
>
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-09 20:33:09 -08:00
< div class = "tabs grid w-full text-gray-400 h-10 relative" >
2022-01-09 19:28:09 -08:00
< game-tab
v - for = "(tab, index) in $store.state.tabs"
: key = "index"
: index = "index"
: 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
class = "w-full text-2xl text-center pt-1 pb-2"
v - text = "$store.getters.activeTab.title"
/ >
2022-01-09 19:28:09 -08:00
< nuxt / >
< / div >
< / main >
< / div >
< / template >
< script >
export default {
name : 'IndexPage' ,
computed : {
activeTabColorClasses ( ) {
const { lightColor , darkColor } = this . $store . getters . activeTab
return ` bg- ${ lightColor } text- ${ darkColor } `
} ,
} ,
mounted ( ) {
window . setInterval ( ( ) => {
this . gametick ( )
} , 1000 )
window . setInterval ( ( ) => {
this . $store . commit ( 'tickGameDate' )
2022-01-09 22:25:55 -08:00
} , 1000 )
2022-01-09 19:28:09 -08:00
} ,
methods : {
gametick ( ) {
for ( let i = 0 ; i < this . $store . state . processes . length ; i ++ ) {
const p = this . $store . state . processes [ i ]
// const step = 100.0 / (6.0 * (i + 1)) // go at different rates
const step = p . workerRate * p . workerCount
let newValue = p . completion + step
while ( newValue >= 100 ) {
newValue = newValue - 100
this . $store . commit ( 'addCurrency' , p . reward )
}
this . $store . commit ( 'setProcessCompletion' , {
processIndex : i ,
value : newValue ,
} )
}
} ,
} ,
}
< / script >
< style >
html ,
body ,
# _ _nuxt ,
# _ _layout {
height : 100 % ; /* 100vh is broken on mobile. this is the fix. */
width : 100 vw ;
}
html {
background : # e5e7eb ;
overflow - y : hidden ;
}
< / style >
< style scoped >
. page {
2022-01-09 20:33:09 -08:00
grid - template - rows : 1 fr ;
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-09 20:33:09 -08:00
. tabs {
grid - template - columns : repeat ( 6 , 1 fr ) ;
grid - gap : 0.25 rem ;
}
2022-01-09 19:28:09 -08:00
< / style >