import const currencies as object properly

This commit is contained in:
John McCardle 2022-01-06 18:43:12 -05:00
parent 14c83b56b9
commit 57caa75b99
2 changed files with 60 additions and 59 deletions

View File

@ -1,5 +1,4 @@
export default { export const currencies = {
currencies: {
energy: 'energy', energy: 'energy',
seasons: 'seasons', seasons: 'seasons',
months: 'months', months: 'months',
@ -8,5 +7,4 @@ export default {
seconds: 'seconds', seconds: 'seconds',
nanoseconds: 'nanoseconds', nanoseconds: 'nanoseconds',
plancktime: 'plancktime', plancktime: 'plancktime',
},
} }

View File

@ -1,47 +1,51 @@
import Decimal from "break_infinity.js" import Decimal from 'break_infinity.js'
import currencies from "./const.js" import { currencies } from './const.js'
export const state = () => ({ export const state = () => ({
// use currencies from const as keys; initialize all values to zero // use currencies from const as keys; initialize all values to zero
currency: currencies.reduce(function(obj, x) { currency: Object.keys(currencies).reduce(function (obj, x) {
obj[x] = new Decimal(0); obj[x] = new Decimal(0)
return obj; return obj
}, {}), }, {}),
processes: [ processes: [
{ device: "Star Chart", {
worker: "Shaman", device: 'Star Chart',
worker: 'Shaman',
boughtWith: null, boughtWith: null,
produces: currencies.seasons, produces: currencies.seasons,
deviceCount: new Decimal(0), deviceCount: new Decimal(0),
workerCount: new Decimal(0), workerCount: new Decimal(0),
unlockThreshold: {[currencies.seasons]: 0, tech: null} unlockThreshold: { [currencies.seasons]: 0, tech: null },
}, },
{ device: "Stone Calendar", {
worker: "Stonecarver", device: 'Stone Calendar',
worker: 'Stonecarver',
boughtWith: currencies.seasons, boughtWith: currencies.seasons,
produces: currencies.months, produces: currencies.months,
deviceCount: new Decimal(0), deviceCount: new Decimal(0),
workerCount: new Decimal(0), workerCount: new Decimal(0),
unlockThreshold: {[currencies.seasons]: 1, tech: null} unlockThreshold: { [currencies.seasons]: 1, tech: null },
}, },
{ device: "Astrolabes", {
worker: "Mathematician", device: 'Astrolabes',
worker: 'Mathematician',
boughtWith: currencies.months, boughtWith: currencies.months,
produces: currencies.days, produces: currencies.days,
deviceCount: new Decimal(0), deviceCount: new Decimal(0),
workerCount: new Decimal(0), workerCount: new Decimal(0),
unlockThreshold: {[currencies.days]: 10, tech: 0} unlockThreshold: { [currencies.days]: 10, tech: 0 },
} },
], ],
upgrades: [ upgrades: [
{ name: "Mathematics", {
name: 'Mathematics',
boughtWith: currencies.seasons, boughtWith: currencies.seasons,
price: 100, price: 100,
purchased: false purchased: false,
}, },
] ],
}) })
export const mutations = { export const mutations = {
@ -52,6 +56,5 @@ export const mutations = {
set(state, { key, value }) { set(state, { key, value }) {
state.currency[key] = value state.currency[key] = value
},
} }
}