the merge project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.3 KiB

4 years ago
import {createStore} from 'vuex'
import moment from "moment";
import getSeason from "@/tools/getSeason";
4 years ago
export default createStore({
state: {
player: null,
unlocked: {
fields: 48
},
time: {
stamp: null,
week: null,
season: null,
weekday: null,
weekdayNr: null
},
inventory: [],
cropField: [],
selections: {
field: null,
item: null
}
4 years ago
},
getters: {},
mutations: {
initialize(state) {
state.time.week = moment().week();
state.time.season = getSeason(state.time.week);
state.time.weekday = moment().weekday();
state.time.weekdayNr = moment().format('dddd');
this.commit('generateField');
},
updateTimestamp(state) {
state.time.stamp = moment().format('H:mm:ss')
},
generateField(state) {
let fieldIndex = 0;
while(state.cropField.length < state.unlocked.fields) {
fieldIndex++;
state.cropField.push({
id: fieldIndex
});
}
},
selectField(state, id) {
state.selections.field = id;
}
},
4 years ago
actions: {},
modules: {}
});