{"id":26493954,"url":"https://github.com/dwarvesf/ts-tokyoclient","last_synced_at":"2025-10-14T17:16:29.837Z","repository":{"id":200700743,"uuid":"706055245","full_name":"dwarvesf/ts-tokyoclient","owner":"dwarvesf","description":"A Typescript client library for connecting to a Tokyo game server and controlling a ship in the game.","archived":false,"fork":false,"pushed_at":"2024-02-25T05:24:32.000Z","size":337,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-04T14:48:31.253Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/dwarvesf.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}},"created_at":"2023-10-17T08:11:17.000Z","updated_at":"2023-10-17T09:18:23.000Z","dependencies_parsed_at":"2023-10-19T18:52:47.534Z","dependency_job_id":"d9a18b32-0b10-4010-9458-ca93ffaf0a0c","html_url":"https://github.com/dwarvesf/ts-tokyoclient","commit_stats":null,"previous_names":["dwarvesf/ts-tokyoclient"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarvesf%2Fts-tokyoclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarvesf%2Fts-tokyoclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarvesf%2Fts-tokyoclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarvesf%2Fts-tokyoclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dwarvesf","download_url":"https://codeload.github.com/dwarvesf/ts-tokyoclient/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244591450,"owners_count":20477709,"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":"2025-03-20T09:58:23.799Z","updated_at":"2025-10-14T17:16:24.796Z","avatar_url":"https://github.com/dwarvesf.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tokyoclient-ts\n\n`tokyoclient-ts` is a Typescript client library for connecting to a Tokyo game server and controlling a ship in the game. It provides functionality to interact with the game server, receive events, and control the ship using a simple bot implementation.\n\n## Methods\n`Controller()`: Returns a controller for controlling the game with actions (rotate, throttle, fire).\n\n`setGamePlan(callback, perMs)`: Sets up a game plan by executing the provided function at regular intervals.\n\n`setOnOpenfn()`: Sets the function to handle 'OnOpen' events for the WebSocket communication.\n\n`close()`: Closes the WebSocket connection.\n\n## Utilities\n`estimateDistance()`: Calculates the Euclidean distance between two players based on their coordinates.\n\n`calculateRotationAngle()`: Calculates the angle (in radians) a player needs to rotate to face the target player.\n\n## Usage\n\nTo use `tokyoclient-ts`, follow these steps:\n\n1. Install the package using:\n```sh\nnpm i tokyoclient-ts`\n```\n\n2. Initialize the Game client with your credentials\n```js\n  const client = new TokyoGameClient({\n    serverHost: \"combat.sege.dev\",\n    apiKey: \"std0101\",\n    userName: \"std0101\",\n    useSecureConnection: true, // scheme wss: or ws:\n  });\n\n  // Initialize the Game client instance\n  const client = new TokyoGameClient(config);\n  \n  // Get your own controller\n  const controller = client.Controller();\n```\n\n3. Implement your own algorithm to respond to how things happen in the map (provided in `state` object below)\n```js\n  client.setGamePlan((state) =\u003e {\n    // can use provided utility functions here\n    console.log(\"Current map state: \", state);\n    controller.throttle(0.2);\n    const angle = getRandomFloat(0.1, 1.0, 1) * 2 * Math.PI;\n    controller.rotate(angle);\n    controller.fire();\n  }, 1000);\n```\n\n5. Run your program and observe the client interacting with the Tokyo game server.\n\n## Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests for any improvements or bug fixes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwarvesf%2Fts-tokyoclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwarvesf%2Fts-tokyoclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwarvesf%2Fts-tokyoclient/lists"}