{"id":24617683,"url":"https://github.com/jacoblincool/bang-c","last_synced_at":"2025-05-07T05:24:49.610Z","repository":{"id":36952983,"uuid":"480312808","full_name":"JacobLinCool/Bang-C","owner":"JacobLinCool","description":"Bang! the board game C implementation, including game manager, computer player, backend websocket server, and frontend web client.","archived":false,"fork":false,"pushed_at":"2025-01-24T08:20:34.000Z","size":9165,"stargazers_count":20,"open_issues_count":26,"forks_count":22,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-31T06:51:07.788Z","etag":null,"topics":["computer-player","game","server"],"latest_commit_sha":null,"homepage":"https://bang.jacoblin.cool","language":"C","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/JacobLinCool.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":"2022-04-11T09:30:55.000Z","updated_at":"2025-03-29T17:22:44.000Z","dependencies_parsed_at":"2023-01-17T08:01:11.502Z","dependency_job_id":"8a990f79-8d2d-47c3-aba0-2a0ddd1e8ffe","html_url":"https://github.com/JacobLinCool/Bang-C","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/JacobLinCool%2FBang-C","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2FBang-C/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2FBang-C/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2FBang-C/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JacobLinCool","download_url":"https://codeload.github.com/JacobLinCool/Bang-C/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252819618,"owners_count":21809052,"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":["computer-player","game","server"],"created_at":"2025-01-24T23:39:55.314Z","updated_at":"2025-05-07T05:24:49.590Z","avatar_url":"https://github.com/JacobLinCool.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bang! C\n\nBang! the board game C implementation, including game manager, computer player, backend websocket server, and frontend web client.\n\n[Docker image is avaliable on Docker Hub](https://hub.docker.com/repository/docker/jacoblincool/bang-dev)\n\n## Architecture\n\nWe need to implement a 4-layer architecture.\n\n### Layer 1: Utils\n\nThe first layer is the utils layer.\n\nWe have implemented some generic utilities, such as connection waiting room.\n\n### Layer 2: Game Logic (Core)\n\nThe second layer is the game logic layer.\n\nIt contains all the game logic and expose a simplified API to the third layer (network layer).\n\n### Layer 3: Network Interface (Transportation)\n\nThe third layer is the network interface layer.\n\nWe use websocket portocol to transfer data over TCP.\n\nAll the data were using JSON to deliver from / to the client.\n\n### Layer 4: User Interface (View)\n\nThe forth layer is the user interface layer.\n\nWe designed a website as graphical interface (GUI).\n\n## Multiple Threads\n\nThe main thread will spawn a server thread, and in each round of game, the server thread will spawn a game manager thread, which will be ended when a game is done.\n\n- Main\n  - Server\n    - Game Manager 1\n    - Game Manager 2\n    - Game Manager 3\n    - ...\n\nAnd the main thread will stop the server when a round of game finished if user type `exit` in terminal during the cycle.\n\n## Development\n\nInstall cmake (to build `libwebsocket`) and valgrind (to debug).\n\n```sh\nsudo apt update \u0026\u0026 sudo apt install -y cmake valgrind\n```\n\nThen, you need two terminal window to run the game server and the client.\n\n### Backend Game Server\n\n1. Install third party libraries `sudo make setup`\n2. Build server `make server`\n3. Run server `./server`\n\n```sh\n# Install third party libraries\nsudo make setup\n\n# Build server\nmake server\n# or \"make server-debug\" to enable debug mode\n\n# Run server\n./server\n# or \"make valgrind\" to run with valgrind\n```\n\n### Frontend Game Client\n\nChange directory to `web`\n\n1. Install dev tools: Node.js 16+, pnpm\n2. Install dependencies: `pnpm install`\n3. Run dev server `pnpm dev`\n\n```sh\n# Install PNPM\ncurl -fsSL https://get.pnpm.io/install.sh | sh -\n\n# Install Node LTS\npnpm env use --global lts\n\n# Change directory to web\ncd web\n\n# Install dependencies\npnpm install\n\n# Run dev server\npnpm dev\n```\n\nAfter you run the both server and client, you should be able to play the game on `http://localhost:8080`.\n\n## References\n\n- [Bang! (card game) - Wikipedia](https://en.wikipedia.org/wiki/Bang!_(card_game))\n\n## Source\n\n### Cards\n\n- [Card List - Bang!](https://bang.dvgiochi.com/cardslist.php?id=1#q_result)\n\nWe Love GitHub!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Fbang-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacoblincool%2Fbang-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Fbang-c/lists"}