24 lines
813 B
JavaScript
24 lines
813 B
JavaScript
import {IRL_MINUTES_PER_GAME_DAY} from '@/constants';
|
|
import Component from '@/ecs/component.js';
|
|
|
|
const realSecondsPerGameDay = 60 * IRL_MINUTES_PER_GAME_DAY;
|
|
const realSecondsPerGameHour = realSecondsPerGameDay / 24;
|
|
const realSecondsPerGameMinute = realSecondsPerGameHour / 60;
|
|
|
|
export default class Time extends Component {
|
|
instanceFromSchema() {
|
|
return class TimeInstance extends super.instanceFromSchema() {
|
|
static gameDayLengthInRealSeconds = 24 * realSecondsPerGameHour;
|
|
get hour() {
|
|
return this.$$irlSeconds / realSecondsPerGameHour;
|
|
}
|
|
get minute() {
|
|
return (this.$$irlSeconds % realSecondsPerGameHour) / realSecondsPerGameMinute;
|
|
}
|
|
};
|
|
}
|
|
static properties = {
|
|
irlSeconds: {defaultValue: 10 * realSecondsPerGameHour, type: 'uint16'},
|
|
};
|
|
}
|