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 22:08:59 -08:00
< div class = "units p-8 relative" >
2022-01-09 19:28:09 -08:00
< div class = "units-background absolute top-8 left-0 right-0" > < / div >
< div
class = "absolute top-0 bottom-0 left-0 right-0 flex items-center justify-center"
@ click = "$store.commit('addCurrency', 1)"
>
< span
2022-01-09 22:08:59 -08:00
class = "spare-time flex flex-row items-center font-bold rounded-2xl p-2"
2022-01-09 20:33:09 -08:00
: class = "`text-${$store.getters.activeTab.darkColor}`"
2022-01-09 19:28:09 -08:00
>
< span class = "text-3xl md:text-5xl" v-text = "$store.state.currency" / >
< span
class = "fas fa-hourglass-half text-xl pt-1 pl-2 md:text-3xl md:pt-2"
/ >
< / span >
< / div >
< / div >
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 20:33:09 -08:00
class = "w-full text-2xl text-center pt-1 pb-2 relative"
2022-01-09 19:28:09 -08:00
: class = "activeTabColorClasses"
>
{ { $store . getters . activeTab . title } }
< / div >
< div
class = "tab-content px-4 w-full overflow-y-scroll"
: class = "activeTabColorClasses"
>
< 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' )
} , 100 )
} ,
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 {
grid - template - rows : auto minmax ( 0 , 2 fr ) auto 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
. units - background {
background : url ( 'https://freesvg.org/img/johnny_automatic_hourglass.png' ) ;
background - size : contain ;
background - repeat : no - repeat ;
background - position : center ;
opacity : 0.4 ;
height : calc ( 100 % - 4 rem ) ; /* 4rem = top padding + bottom padding */
}
. spare - time {
background : rgba ( 2555 , 255 , 255 , 0.6 ) ;
box - shadow : 0 px 0 px 21 px 3 px # fff ;
2022-01-09 22:18:15 -08:00
transition : color 2000 ms ;
2022-01-09 19:28:09 -08:00
}
< / style >