fantasy-time-crunch
I needed a way of handling a made-up time system in a game, so I made this.
Sample Configuration
const time = {
second: {
tick: true,
makes: {minute: 60},
},
minute: {
makes: {hour: 60},
},
hour: {
makes: {day: 24},
onIncrement() {
console.log('BING!');
console.log('Hour: ', this.time.hour);
},
states() {
if (this.states.is('winter')) {
return {
day: 9,
night: 20,
};
}
return {
day: 6,
night: 23,
};
}
},
day: {
makes() {
const days = this.time.month % 2 ? 31 : 30;
return {month: days};
},
onIncrement() {
const names = 'MTWHFSU';
console.log('Day:', names[this.time.day - 1]);
},
},
month: {
makes: { year: 12},
states: {
winter: 11,
spring: 3,
summer: 5,
fall: 9
}
}
};