Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 1.18 KB

README.md

File metadata and controls

43 lines (33 loc) · 1.18 KB

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));