Giter Site home page Giter Site logo

game-of-three's Introduction

Requirements to Run

  • Node.js: Ensure that you have Node.js installed. You can download it from nodejs.org. Latest LTS version should be fine.
  • Docker: You can download it from docker.com.

Getting Started

  1. Clone the Repository: git clone https://github.com/premithk/game-of-three.git
  2. Backend Setup:
    • Navigate to the game-of-three folder.
    • Run npm install to install dependencies. You can also use yarn
    • Run docker-compose up to start the NestJS instances in Docker containers.
  3. To see the game running:
    • There is a script called play.js in the script folder.
    • Run it using node to see the game in action. node script/play.js

Architecture

Components

  1. GameService: Manages the game logic, including starting the game, playing turns, and checking for game over.
  2. GameController: Exposes RESTful APIs for starting the game, playing turns, and checking if the game is over.

Tests

  1. Unit tests are found along with the controller and the service files. ./src/game/game.controller.spec.ts and ./src/game/game.controller.spec.ts
  2. E2E tests are found in ./test/app.e2e-spec.ts. The E2E test also contains a test for the full gameplay.
  3. You can run the unit tests using npm run test and npm run test:e2e

Game Flow

  1. A random number is generated when a player starts, and the game begins.
  2. Players take turns to adjust the number to be divisible by 3, and the game continues until one player reaches 1.

Docker Compose

  • Two independent instances of the same NestJS application are deployed using Docker Compose to simulate two players. game_of_three

Limitations

  1. Simplified Logic: The game logic is kept simple for demonstration purposes. You may enhance it for a more complex and engaging gaming experience.
  2. Single Instance Interaction: The game assumes interaction between two players within the same instance. For a real-world scenario, consider integrating WebSocket or other communication methods for cross-instance communication.
  3. Error Handling: Basic error handling is implemented. Further enhancements can be made to handle edge cases and improve error messages.
  4. Security: The application does not implement advanced security measures. Ensure proper security practices for production deployment.

Screenshot

game_of_3

game-of-three's People

Contributors

premithk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.