{"id":13338522,"url":"https://github.com/kennethlng/tictactoe-multiplayer-cloud-functions","last_synced_at":"2025-03-11T10:31:18.881Z","repository":{"id":38769067,"uuid":"277379465","full_name":"kennethlng/tictactoe-multiplayer-cloud-functions","owner":"kennethlng","description":"Cloud Functions trigger functions that run the backend game logic for the \"tictactoe-multiplayer\" game. Determines which player's turn it is and when the game is over. ","archived":true,"fork":false,"pushed_at":"2022-06-02T21:58:32.000Z","size":246,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-23T22:16:53.011Z","etag":null,"topics":["cloud-functions","firebase-firestore","firebase-functions","game","server","serverless","turn-based"],"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/kennethlng.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}},"created_at":"2020-07-05T20:37:09.000Z","updated_at":"2023-01-27T19:54:54.000Z","dependencies_parsed_at":"2022-08-24T05:31:37.521Z","dependency_job_id":null,"html_url":"https://github.com/kennethlng/tictactoe-multiplayer-cloud-functions","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethlng%2Ftictactoe-multiplayer-cloud-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethlng%2Ftictactoe-multiplayer-cloud-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethlng%2Ftictactoe-multiplayer-cloud-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethlng%2Ftictactoe-multiplayer-cloud-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kennethlng","download_url":"https://codeload.github.com/kennethlng/tictactoe-multiplayer-cloud-functions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243015337,"owners_count":20222070,"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":["cloud-functions","firebase-firestore","firebase-functions","game","server","serverless","turn-based"],"created_at":"2024-07-29T19:16:28.810Z","updated_at":"2025-03-11T10:31:17.801Z","avatar_url":"https://github.com/kennethlng.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tictactoe-multiplayer-cloud-functions\n\nThis is a Cloud Functions backend that handles the backend game logic for the [multiplayer TicTacToe game](https://github.com/kennethlng/tictactoe-multiplayer). There are 2 Firestore trigger functions: `onQueueCreated` and `onMatchUpdated`.  \n \n### `onQueueCreated`\n\nWhile in the lobby, players can submit matchmaking requests. Each matchmaking request creates an active `queue` document in the `queues` Firestore collection. Each time a new `queue` is created, the `onQueueCreated` trigger function will:\n\n1. Clean out previous matchmaking requests from the same player by deactivating them (`isActive` = `false`). \n2. Search for active matchmaking requests from all players. For simplicity's sake, I only looked for the 2 most recent queues to create a match. In a real-life game example, you would probably create more complex logic to match players based on level, region, etc. \n3. If two queues have been found, create a new `match` document between the two players. \n\n### `onMatchUpdated`\n\nEach time a match is updated with new marks, the `onMatchUpdated` trigger function runs the backend game logic to determine whose turn it is next and whether a winner has been identified.\n\n## Contact\n\nIf you have any questions or concerns, message me on [Twitter](https://twitter.com/kennethlng) or email me at hello@kennethlng.com.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkennethlng%2Ftictactoe-multiplayer-cloud-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkennethlng%2Ftictactoe-multiplayer-cloud-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkennethlng%2Ftictactoe-multiplayer-cloud-functions/lists"}