2022-01-06 14:28:23 -08:00
import Decimal from "break_infinity.js"
2022-01-06 18:15:51 -05:00
import currencies from "./const.js"
2022-01-06 14:28:23 -08:00
export const state = ( ) => ( {
2022-01-06 18:15:51 -05:00
// use currencies from const as keys; initialize all values to zero
currency : currencies . reduce ( function ( obj , x ) {
obj [ x ] = new Decimal ( 0 ) ;
return obj ;
} , { } ) ,
processes : [
{ device : "Star Chart" ,
worker : "Shaman" ,
boughtWith : null ,
produces : currencies . seasons ,
deviceCount : new Decimal ( 0 ) ,
workerCount : new Decimal ( 0 ) ,
2022-01-06 18:37:52 -05:00
unlockThreshold : { [ currencies . seasons ] : 0 , tech : null }
2022-01-06 18:15:51 -05:00
} ,
{ device : "Stone Calendar" ,
worker : "Stonecarver" ,
boughtWith : currencies . seasons ,
produces : currencies . months ,
deviceCount : new Decimal ( 0 ) ,
workerCount : new Decimal ( 0 ) ,
2022-01-06 18:37:52 -05:00
unlockThreshold : { [ currencies . seasons ] : 1 , tech : null }
2022-01-06 18:15:51 -05:00
} ,
{ device : "Astrolabes" ,
worker : "Mathematician" ,
boughtWith : currencies . months ,
produces : currencies . days ,
deviceCount : new Decimal ( 0 ) ,
workerCount : new Decimal ( 0 ) ,
2022-01-06 18:37:52 -05:00
unlockThreshold : { [ currencies . days ] : 10 , tech : 0 }
2022-01-06 18:15:51 -05:00
}
] ,
upgrades : [
2022-01-06 18:37:52 -05:00
{ name : "Mathematics" ,
2022-01-06 18:15:51 -05:00
boughtWith : currencies . seasons ,
price : 100 ,
purchased : false
} ,
]
2022-01-06 14:28:23 -08:00
} )
export const mutations = {
add ( state , { key , value } ) {
2022-01-06 18:15:51 -05:00
console . log ( state . currency . keys ( ) )
2022-01-06 14:28:23 -08:00
state . currency [ key ] = Decimal . add ( state . currency [ key ] , value )
} ,
set ( state , { key , value } ) {
state . currency [ key ] = value
}
}