{"id":15686008,"url":"https://github.com/cestef/gamemaker","last_synced_at":"2025-05-07T18:21:57.745Z","repository":{"id":44453687,"uuid":"322862945","full_name":"cestef/gamemaker","owner":"cestef","description":"Easy Matchmaking nodejs module","archived":false,"fork":false,"pushed_at":"2024-02-17T17:06:54.000Z","size":1702,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-03T04:39:51.540Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/cestef.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":"2020-12-19T14:13:30.000Z","updated_at":"2024-08-02T13:21:09.000Z","dependencies_parsed_at":"2024-10-23T20:13:15.123Z","dependency_job_id":null,"html_url":"https://github.com/cestef/gamemaker","commit_stats":null,"previous_names":["cstefflexin/gamemaker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cestef%2Fgamemaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cestef%2Fgamemaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cestef%2Fgamemaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cestef%2Fgamemaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cestef","download_url":"https://codeload.github.com/cestef/gamemaker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931820,"owners_count":21827172,"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":[],"created_at":"2024-10-03T17:34:32.482Z","updated_at":"2025-05-07T18:21:57.724Z","avatar_url":"https://github.com/cestef.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003egamemaker\u003c/h3\u003e\r\n\r\n\u003cdiv\u003e\r\n\r\n[![Status](https://img.shields.io/badge/status-active-success.svg)]()\r\n[![GitHub Issues](https://img.shields.io/github/issues/cstefflexin/gamemaker.svg)](https://github.com/cstefflexin/gamemaker/issues)\r\n[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/cstefflexin/gamemaker.svg)](https://github.com/cstefflexin/gamemaker/pulls)\r\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE)\r\n\r\n\u003c/div\u003e\r\n\r\n---\r\n\r\n\r\n## 📝 Table of Contents\r\n\r\n- [About](#about)\r\n- [Getting Started](#getting_started)\r\n- [Usage](#usage)\r\n- [Built Using](#built_using)\r\n- [Authors](#authors)\r\n- [Acknowledgments](#acknowledgement)\r\n\r\n## 🧐 About \u003ca name = \"about\"\u003e\u003c/a\u003e\r\n\r\n`gamemaker` is an easy-to-use matchmaking nodejs module. You can easily modify the module by adding your own matching/sorting functions to the constructor parameters\r\n\r\n## 🏁 Getting Started \u003ca name = \"getting_started\"\u003e\u003c/a\u003e\r\n\r\nInstall the package with npm\r\n```shell\r\nnpm install --save gamemaker\r\n```\r\n\r\n## 🎈 Usage \u003ca name=\"usage\"\u003e\u003c/a\u003e\r\n\r\n```js\r\n//require the module\r\nconst Matchmaker = require(\"gamemaker\");\r\n\r\nfunction startMatch(players) {\r\n    //\"player\" parameter structure: {player: the player object, addedAt: timestamp when the player was added to the queue}\r\n    console.log(`Match started with players: ${players.map(e =\u003e e.player.name)}`); //fired when a match starts, passing all the players as arguments\r\n};\r\n\r\nfunction getPlayerID(player) {\r\n    return player.id; //Return the player property that includes its id\r\n};\r\n\r\nfunction matchPlayers(players) {\r\n    ///... do something to check if the players match together\r\n    return true;\r\n    //return true or false\r\n};\r\n\r\nfunction sortQueue(a, b) {\r\n    //sort with the a and b player object\r\n    return a - b\r\n};\r\nconst defaultQueue = []; // default matchmaker queue (array)\r\nconst matcher = new Matchmaker(startMatch, getPlayerID, {\r\n    checkInterval: 2000, // interval in ms to check the queue\r\n    minMatchSize: 2, //minimal party size to launch the match\r\n    maxMatchSize: 5, //max party size\r\n    matchPlayersFunction: matchPlayers, //the function used to tell if the player match together or not (default returns true)\r\n    sortQueueFunction: sortQueue, //the function used to sort the queue (default sort by add time)\r\n    queue: defaultQueue, //the default queue for the matchMaker (default [])\r\n});\r\nmatcher.init(); //init the matchmaker interval\r\nmatcher.addPlayer({name:\"Bob\", id:0}); //Add a player named \"Bob\"\r\nmatcher.addPlayer({name:\"John\", id:1, someRandomProperty:[123]}) //You can also add other properties to the player object\r\nmatcher.removePlayerByID(0); //will remove \"Bob\" from the queue\r\nmatcher.addPlayer({name:\"Alice\", id:2}) //Add a player named \"Alice\"\r\nmatcher.getPlayerByID(1) //will return the \"John\" player object\r\n\r\n//Output: Match started with players: John,Alice\r\n```\r\n\r\n## ⛏️ Built Using \u003ca name = \"built_using\"\u003e\u003c/a\u003e\r\n\r\n- [NodeJs](https://nodejs.org/en/)\r\n\r\n## ✍️ Authors \u003ca name = \"authors\"\u003e\u003c/a\u003e\r\n\r\n- [@cstefFlexin](https://github.com/cstefFlexin) - Idea \u0026 Initial work\r\n\r\nSee also the list of [contributors](https://github.com/cstefFlexin/gamemaker/contributors) who participated in this project.\r\n\r\n## 🎉 Acknowledgements \u003ca name = \"acknowledgement\"\u003e\u003c/a\u003e\r\n\r\nInspired by the package [matchmaking](https://github.com/Luifr/matchmaking)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcestef%2Fgamemaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcestef%2Fgamemaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcestef%2Fgamemaker/lists"}