Basic game data structure for devices and workers.
This commit is contained in:
parent
98350955b0
commit
cd8cdd31e3
|
@ -0,0 +1,13 @@
|
||||||
|
export default {
|
||||||
|
currencies: [
|
||||||
|
"energy",
|
||||||
|
"seasons",
|
||||||
|
"months",
|
||||||
|
"days",
|
||||||
|
"hours",
|
||||||
|
"seconds",
|
||||||
|
"nanoseconds",
|
||||||
|
"plancktime"
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
|
@ -1,19 +1,52 @@
|
||||||
import Decimal from "break_infinity.js"
|
import Decimal from "break_infinity.js"
|
||||||
|
import currencies from "./const.js"
|
||||||
|
|
||||||
export const state = () => ({
|
export const state = () => ({
|
||||||
currency: {
|
// use currencies from const as keys; initialize all values to zero
|
||||||
energy: new Decimal(0),
|
currency: currencies.reduce(function(obj, x) {
|
||||||
// if it hasn't been your
|
obj[x] = new Decimal(0);
|
||||||
days: new Decimal(0),
|
return obj;
|
||||||
weeks: new Decimal(0),
|
}, {}),
|
||||||
months: new Decimal(0),
|
|
||||||
// or even your
|
processes: [
|
||||||
years: new Decimal(0)
|
{ 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
|
||||||
|
},
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
add(state, { key, value }) {
|
add(state, { key, value }) {
|
||||||
|
console.log(state.currency.keys())
|
||||||
state.currency[key] = Decimal.add(state.currency[key], value)
|
state.currency[key] = Decimal.add(state.currency[key], value)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Reference in New Issue