import const currencies as object properly
This commit is contained in:
parent
14c83b56b9
commit
57caa75b99
|
@ -1,12 +1,10 @@
|
|||
export default {
|
||||
currencies: {
|
||||
energy: 'energy',
|
||||
seasons: 'seasons',
|
||||
months: 'months',
|
||||
days: 'days',
|
||||
hours: 'hours',
|
||||
seconds: 'seconds',
|
||||
nanoseconds: 'nanoseconds',
|
||||
plancktime: 'plancktime',
|
||||
},
|
||||
export const currencies = {
|
||||
energy: 'energy',
|
||||
seasons: 'seasons',
|
||||
months: 'months',
|
||||
days: 'days',
|
||||
hours: 'hours',
|
||||
seconds: 'seconds',
|
||||
nanoseconds: 'nanoseconds',
|
||||
plancktime: 'plancktime',
|
||||
}
|
||||
|
|
|
@ -1,57 +1,60 @@
|
|||
import Decimal from "break_infinity.js"
|
||||
import currencies from "./const.js"
|
||||
import Decimal from 'break_infinity.js'
|
||||
import { currencies } from './const.js'
|
||||
|
||||
export const state = () => ({
|
||||
// use currencies from const as keys; initialize all values to zero
|
||||
currency: currencies.reduce(function(obj, x) {
|
||||
obj[x] = new Decimal(0);
|
||||
return obj;
|
||||
}, {}),
|
||||
// use currencies from const as keys; initialize all values to zero
|
||||
currency: Object.keys(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),
|
||||
unlockThreshold: {[currencies.seasons]: 0, tech: null}
|
||||
},
|
||||
{ device: "Stone Calendar",
|
||||
worker: "Stonecarver",
|
||||
boughtWith: currencies.seasons,
|
||||
produces: currencies.months,
|
||||
deviceCount: new Decimal(0),
|
||||
workerCount: new Decimal(0),
|
||||
unlockThreshold: {[currencies.seasons]: 1, tech: null}
|
||||
},
|
||||
{ device: "Astrolabes",
|
||||
worker: "Mathematician",
|
||||
boughtWith: currencies.months,
|
||||
produces: currencies.days,
|
||||
deviceCount: new Decimal(0),
|
||||
workerCount: new Decimal(0),
|
||||
unlockThreshold: {[currencies.days]: 10, tech: 0}
|
||||
}
|
||||
],
|
||||
processes: [
|
||||
{
|
||||
device: 'Star Chart',
|
||||
worker: 'Shaman',
|
||||
boughtWith: null,
|
||||
produces: currencies.seasons,
|
||||
deviceCount: new Decimal(0),
|
||||
workerCount: new Decimal(0),
|
||||
unlockThreshold: { [currencies.seasons]: 0, tech: null },
|
||||
},
|
||||
{
|
||||
device: 'Stone Calendar',
|
||||
worker: 'Stonecarver',
|
||||
boughtWith: currencies.seasons,
|
||||
produces: currencies.months,
|
||||
deviceCount: new Decimal(0),
|
||||
workerCount: new Decimal(0),
|
||||
unlockThreshold: { [currencies.seasons]: 1, tech: null },
|
||||
},
|
||||
{
|
||||
device: 'Astrolabes',
|
||||
worker: 'Mathematician',
|
||||
boughtWith: currencies.months,
|
||||
produces: currencies.days,
|
||||
deviceCount: new Decimal(0),
|
||||
workerCount: new Decimal(0),
|
||||
unlockThreshold: { [currencies.days]: 10, tech: 0 },
|
||||
},
|
||||
],
|
||||
|
||||
upgrades: [
|
||||
{ name: "Mathematics",
|
||||
boughtWith: currencies.seasons,
|
||||
price: 100,
|
||||
purchased: false
|
||||
},
|
||||
]
|
||||
upgrades: [
|
||||
{
|
||||
name: 'Mathematics',
|
||||
boughtWith: currencies.seasons,
|
||||
price: 100,
|
||||
purchased: false,
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
export const mutations = {
|
||||
add(state, { key, value }) {
|
||||
console.log(state.currency.keys())
|
||||
state.currency[key] = Decimal.add(state.currency[key], value)
|
||||
},
|
||||
add(state, { key, value }) {
|
||||
console.log(state.currency.keys())
|
||||
state.currency[key] = Decimal.add(state.currency[key], value)
|
||||
},
|
||||
|
||||
set(state, { key, value }) {
|
||||
state.currency[key] = value
|
||||
}
|
||||
set(state, { key, value }) {
|
||||
state.currency[key] = value
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue