Skip to content

mmwo/shipbattle-generator

Repository files navigation

Webpack library starter

Asynchronous, Web Worker based battleship map generator in JS

Features

  • Webpack 4 based.
  • ES6 as a source.
  • Exports in a umd format so library works everywhere.
  • Linting with ESLint.

Scripts

npm run build - produces production version of this library under the lib folder

npm start - See in browser library usage

Usage

import {BoardGenerator} from '@yufuzu/shipbattle-board'

const generator = new BoardGenerator();
const mapWidth = 10;
const mapHeight = 10;

 generator.randomMap(mapWidth, mapHeight, [
      generator.ship('CRUISER-5', 5),
      generator.ship('CRUISER-4', 4),
      generator.ship('CRUISER-4', 4),
      generator.ship('CRUISER-3', 3),
      generator.ship('CRUISER-3', 3),
      generator.ship('CRUISER-2', 2),
      generator.ship('CRUISER-2', 2),
      generator.ship('CRUISER-2', 2),
      generator.ship('CRUISER-2', 2),
      generator.ship('CRUISER-1', 1),
      generator.ship('CRUISER-1', 1),
      generator.ship('CRUISER-1', 1),
      generator.ship('CRUISER-1', 1),
      generator.ship('CRUISER-1', 1)
    ]).then(fields => console.log(fields));

About

Creates random maps for battleship game

Resources

License

Stars

Watchers

Forks

Packages

No packages published