Skip to content

drewcook/ts-battleship

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Battleship

Play the Demo App.

This is the classic game of battleship. It is a full-stack web application writtin in TypeScript. It follows object-oriented design patterns and principals. It was inspired by this design and SOLID Principles. The AI behavior is inspired by this article which contains some techniques for random placements and guessing.

This project includes the following tech:

Types

This project also serves as a host for the battleship-types package hosted on npmjs.org, which includes type definitions of a typical game of Battleship, and is used throughout this project. It serves the purpose of having a single, shared set of types that can be used across both server and client applications, reducing duplication of definitions in both frontend and backend, and easing the maintainability of changes to the schema over time.

Inherently, the battleship-types package code is located under the ./types directory.

How To Run

The project must be compiled before running, and the dist directory is not checked into git. To run the project locally, use the following command:

Install Dependencies

# server
cd ./server && npm i
# or
cd ./server && yarn install

# client
cd ./client && npm i
# or
cd ./client && yarn install

Build in Development Mode

# server
cd ./server
npm run dev

# client
cd ./client
yarn start

Build in Production Mode

# server
cd ./server
npm build

# client
cd ./client
yarn build

This will compile the TypeScript into JavaScript into a dist/ directory, and it will run the code with nodemon.

Ways To Play

  • Player vs Computer
  • Player vs Player
  • Computer vs Computer - AI game siumlation

visitor count