Giter VIP home page Giter VIP logo

dynotum / mandala-game Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 535 KB

This Mancala game project was made with Spring-boot and ReactJS. It focused specifically on the backend using DTO pattern. The mancala games are a family of two-player turn-based strategy board games played with small stones, beans, or seeds and rows of holes or pits in the earth, a board or other playing surface. The objective is usually to capture all or some set of the opponent's pieces

Java 87.32% HTML 1.57% CSS 0.94% JavaScript 9.98% Dockerfile 0.20%
java spring-boot gradle reactjs docker junit5 mancala-game

mandala-game's Introduction

Carlos Sedano

Mancala Game

Mancala Game
  1. Synopsis
  2. Gameplay
  3. Getting Started
  4. Generate a JAR
  5. Docker Deploy
  6. Backend
  7. Frontend
  8. Usage
  9. Tests
  10. Technical Information
  11. Swagger UI
  12. Contact

Synopsis

The mancala games are a family of two-player turn-based strategy board games played with small stones, beans, or seeds and rows of holes or pits in the earth, a board or other playing surface. The objective is usually to capture all or some set of the opponent's pieces.- Wikipedia

Built With

Gameplay

  • The board is designed for two players. There are six pits on each player's side and a Mancala (large pit) on either > end.
  • To start place 6 stones in each pit, leaving the Mancalas empty.
  • Decide who goes first. (Randomly)
  • One player picks up all the stones in one of their own pits.
  • Starting with the next pit (counterclockwise), drop one stone in each pit including your own Mancala and skipping your opponent’s Mancala.
  • If the last stone is dropped in your own Mancala, you get to play again.
  • If the last stone is dropped in an empty pit on your own side and there are stones in the pit opposite the pit adhere you just dropped the last stone, then you get to capture your own stone and all the stones in the opposite pit and place this all in your own Mancala. Otherwise, it is the other players turn.
  • Then all the pits on one side are empty, the other player gets to take all the stones on their own side and place those stones into their own Mancala.
  • At the end, whoever has the most stones in their Mancala wins.

Getting Started

Prerequisites

  • Install IntelliJ IDEA, configure & install plugins

    • Plugins - Press Ctrl+Alt+S / Cmd+, to open IDE settings and select Plugins. Find the plugin in the Marketplace and click Install. For more information see IntelliJ oficial wiki
    • Optional plugins
    • Enable annotation processing - Press Ctrl+Alt+S / Cmd+, to open IDE settings and select Build, Execution, Deployment | Compiler | Annotation Processors and make sure Enable annotation processing is checked. For more information see IntelliJ oficial wiki
  • Install Postman (Optional)

  • Install Gradle

    -----------------------------------------------------
    Gradle 7.2
    ------------------------------------------------------------
    
    Build time:   2021-08-17 09:59:03 UTC
    Revision:     a773786b58bb28710e3dc96c4d1a7063628952ad
    
    Kotlin:       1.5.21
    Groovy:       3.0.8
    Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
    JVM:          11.0.8 (AdoptOpenJDK 11.0.8+10)
  • Install OpenJDK 11

  • Install nvm or nvm-windows

  • Node v16.13.0

  • npm v8.1.0

  • Install yarn 1.22.17

IMPORTANT : If you do not want to install nvm, NodeJS nor yarn, you can use Gradle to generate a JAR file with all the dependencies. Follow the steps below

If you have installed Docker on your machine, go to the Docker Deploy section. And follow the steps.

If you do not have Docker and you want to generate and run a JAR file go under Generate a JAR section.

Docker Deploy

  1. Build the dockerfile with the command below

     $ docker build . --progress=plain --no-cache -t mancala-image
  2. Create a base image for the Mancala game

     $ docker run --name mancala -h mancala -p 8080:8080 -d mancala-image
  3. Finally, open http://localhost:8080 to view it in the browser.

Generate a JAR

  • If you do not want to install Node.js, nvm, neither Yarn nor you do have a different versions. You can follow these steps in order to generate a JAR and execute it.

If you don't want to generate and run a JAR file and prefer to run it manually, go to the Backend section followed by the Frontend.

  1. Clean with Gradle
    $ ./gradlew clean
  2. Execute a task with Gradle in order to download all the dependencies under the project.
    $ ./gradlew executeYarn
  3. Let's generate a JAR file.
    $ ./gradlew bootJar
  4. We're ready to go, run the JAR file that has been created in order to start the app.
    $  java -jar build/libs/malanca-0.0.1-SNAPSHOT.jar
  5. Open http://localhost:8080 to view it in the browser.

Backend

Run Backend

  1. Clean and build with Gradle

    $ ./gradlew clean build
  2. Run the backend project app on local with Gradle

    $ ./gradlew bootRun

    It will be running at http://localhost:8080

  3. (Optional) Generate and run jar file only for backend purposes

    $ ./gradlew bootJar

    The jar is created under the $project/build/libs/ folder

    $ java -jar malanca-0.0.1-SNAPSHOT.jar

Test

  1. Execute bundle of unit and integration tests
    $ ./gradlew test

Frontend

Run Frontend

  1. First, check our version of Node after installing it with nvm If the installation was successful, you should be able to run the following command.

     $ node --version
     v16.13.0
    
     $ npm --version
     8.1.0   
  2. Yarn installation

    • After installing node, this project will need yarn too, so just run the following command.
     $ npm install -g yarn   
  3. In the fronted project directory (called frontend folder), you need to install all the dependencies listed within package.json in the local node_modules folder.

     $ yarn install   
  4. In the fronted project directory (called frontend folder), you can start the application:

     $ yarn start   

Runs the app in the development mode.

  1. Open http://localhost:3000 to view it in the browser.

Known issues on Windows: Error PS1 Can Not Be Loaded

Usage

Board

Technical Information

Code architecture Backend

src/main/java/com/game/mancala

  • config/apidocumentation - Contains Swagger configuration class for API documentation
  • controller - Contains all controllers (Our API endpoints). This controllers uses @Service classes located at business package
    • error - Contains response exception handler and all exception classes for Mancala game api
  • domain/dto - Contains all objects related to Mancala game project
    • requests - Contains request objects for the game API (DTOs)
    • responses - Contains response objects for game API (DTOs)
  • mapper - Contains mappers to build from a DTO request to a DTO response
  • service - Contains all business logic
  • util - Contains common resources for this project

java/resources

  • application.properties - Contains all properties for Mancala game app

src/test/java/com/game/mancala

  • integration Contains all the integration tests for the project
  • unit Contains all the unit tests for the project
  • utils Contains a helper class for mocking a object

Code architecture Frontend

src/main/frontend

  • public - Public folder that can be referenced from the index.html where is the page template.
  • src - Contains all the files related to run the app.
    • components - Contains all components necessary in order to render the app.
  • package.json - Store the metadata associated with the project as well as to store the list of dependency packages.

Swagger UI

Open Swagger UI

http://localhost:8080/swagger-ui.html

Swagger UI

Contact

Carlos Sedano

mandala-game's People

Contributors

dynotum avatar

Stargazers

 avatar  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.