{"id":13797649,"url":"https://github.com/seanohue/fantasy-time-crunch","last_synced_at":"2025-05-13T04:32:10.701Z","repository":{"id":34362604,"uuid":"176622018","full_name":"seanohue/fantasy-time-crunch","owner":"seanohue","description":"A way of handling time and time-related state changes in a highly customizable way, for use with games and virtual worlds","archived":false,"fork":false,"pushed_at":"2023-02-26T23:58:43.000Z","size":289,"stargazers_count":8,"open_issues_count":9,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-13T08:46:08.408Z","etag":null,"topics":["fantasy","games","hacktoberfest","mmo-engine","mud-engine","ranvier","time","utility-library"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seanohue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-20T00:43:10.000Z","updated_at":"2023-04-17T11:30:04.000Z","dependencies_parsed_at":"2024-08-04T00:01:52.162Z","dependency_job_id":"94275798-64b1-4afe-bbcc-13dfe42a0336","html_url":"https://github.com/seanohue/fantasy-time-crunch","commit_stats":{"total_commits":30,"total_committers":8,"mean_commits":3.75,"dds":0.5333333333333333,"last_synced_commit":"3f3dbef34c68d27a3250e6afef64a203db52e203"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seanohue%2Ffantasy-time-crunch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seanohue%2Ffantasy-time-crunch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seanohue%2Ffantasy-time-crunch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seanohue%2Ffantasy-time-crunch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seanohue","download_url":"https://codeload.github.com/seanohue/fantasy-time-crunch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225176598,"owners_count":17433010,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fantasy","games","hacktoberfest","mmo-engine","mud-engine","ranvier","time","utility-library"],"created_at":"2024-08-04T00:00:25.842Z","updated_at":"2024-11-18T12:31:29.125Z","avatar_url":"https://github.com/seanohue.png","language":"JavaScript","funding_links":[],"categories":["Categories"],"sub_categories":["Libraries"],"readme":"# fantasy-time-crunch\n\nI needed a way of handling a made-up time system in a game, so I made this.\n\n## Sample Configuration\n\n```javascript\nconst time = {\n  // One and only one unit is the smallest measured subdivision of time, defined as a 'tick'\n  second: {\n    tick: true,\n    makes: {minute: 60},\n  },\n\n  // Larger units are defined by how many of a smaller unit they are subdivided into\n  minute: {\n    makes: {hour: 60},\n  },\n\n  // Optionally one can define a function to be called when\n  // a unit increments (having a bell toll, etc.)\n  hour: {\n    makes: {day: 24},\n    onIncrement() {\n      console.log('BING!');\n      console.log('Hour: ', this.time.hour);\n    },\n    // Units can be divided into multiple state changes. For example, a day has two or more states defined\n    // by how many hours have passed.\n    // 'states' can be an object or a function.\n    // In this case, dawn and dusk are different depending\n    // on the season\n    states() {\n      if (this.states.is('winter')) {\n        return {\n          day: 9, // 0900 -- by default this number represents hours. however, each property returned can also be a function that has access to any time unit.\n          night: 20, // 2000\n        };\n      }\n      return {\n        day: 6, // 0900\n        night: 23, // 2200\n      };\n    }\n  },\n\n\n  day: {\n    makes() {\n      const days = this.time.month % 2 ? 31 : 30;\n      return {month: days};\n    },\n    onIncrement() {\n      const names = 'MTWHFSU';\n      console.log('Day:', names[this.time.day - 1]);\n    },\n  },\n  month: {\n    // The 'of' property can also be a function called\n    // In this case, even months have 30 days and odd have 31.\n    makes: { year: 12},\n\n    // For simpler state changes, an object marking the\n    // transitional thresholds is fine.\n    states: {\n      winter: 11,\n      spring: 3,\n      summer: 5,\n      fall: 9\n    }\n  }\n};\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseanohue%2Ffantasy-time-crunch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseanohue%2Ffantasy-time-crunch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseanohue%2Ffantasy-time-crunch/lists"}