Skip to content

OP2-CheckMate/OnlineChessFront

Repository files navigation

OnlineChessFront - TypeScript - React Native

Published to expo.io

https://expo.dev/@samz9n/OnlineChessFront?serviceType=classic&distribution=expo-go (This only works for android with Expo Go app!) Install Expo Go app on Google Play store to get started! Then scan the QR-code from our published link, or follow the provided link to open our application.

About

This is a schoolproject made by five students. The application is built with React Native, using TypeScript. As a "backend" we used socket.io and node (express), to get realtime game and chat updates. The goal was to create a multiplayer online chess game, where players can play against friends and random opponents. We also wanted to include a chat for an enchanced player experience.

Components (main screens):

Homepage.tsx

First page in the app. The player can choose to start a new game, go to settings or go to the board. 
The navigation will work with stack-navigation.

Settings.tsx

In the settings screen, the player can edit:  
1. Gameplay options (show possible moves toggle), 
2. Theme options for the board
3. Profile settings (changing and setting name) 

QueuingScreen.tsx

Player can either create a new lobby, join an existing lobby with the lobby code or find game against opponents that are ready to play. 

LobbyCodeScreen.tsx

When creating a new lobby player will be redirected 
to a screen with lobby code visible so they can share it with the opponent 

Board.tsx

Component for the UI of the board 

Game.tsx

Game logic using Chess.js third party library. 
Also, chess pieces are defined in this component, 
and the movement of them are done with different animation logic. 

Chess.js

Third party library (https://github.com/jhlywa/chess.js/blob/master/README.md)

  • Validation of moves in frontend
  • Only validated moves can be sent to backend
  • Chess piece logic and other gameplay logic (e.g. winner, check and checkmate)

Install:

npm install chess.js

Example:

import { Chess } from 'chess.js' 
const chess = new Chess() //starts new game 
console.log(chess.ascii()) //shows all piece placements 
chess.move({from:'a2', to:'a4'}) //Move PAWN 
console.log(chess.ascii()) 

Run app locally:

To play the game you also need the backend running locally!

Get it here -> OnlineChessBack

Clone the repo:

git clone https://github.com/OP2-CheckMate/OnlineChessFront.git

Install npm packages:

npm install

Set environment variables

Create env file:
touch .env

Inside .env add HOST_NAME=http://<your_ip_adddress>:8080

Run program:

npm start

Stop program:

ctrl + c

Authors

Acknowledgements

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5