silphius/app/ecs-components/time.js
2024-07-04 15:17:33 -05:00

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: 18 * realSecondsPerGameHour, type: 'uint16'},
};
}