1.0.4 • Published 4 years ago

battleshipjs v1.0.4

Weekly downloads
4
License
GPL-3.0-or-later
Repository
github
Last release
4 years ago

Battleship.js

NPM

Sonarcloud Status Renovate contributions welcome semistandard ECMAScript license

A Battleship CLI game with customizations.

Features

  • Set the number of each 5 ship type.
  • Set the number of rows and columns in the board.
  • Play against computer or against another player in hotseat mode.
  • Choose which player plays first.
  • Choose whether to end attack turn even if player hits.
  • Set names of players.
  • Also randomly place your ships and attack opponent's ships.

Board

  • Empty: O
  • Boat (1 space): B
  • Frigate (2 spaces): F
  • Destroyer (3 spaces): D
  • Cruiser (4 spaces): C
  • Aircraft carrier (5 spaces): A
  • Miss: X
  • Hit: *

Installation

$ npm install battleshipjs

Usage

FlagShortDescriptionUsage
--rows-rSet number of rows in the board-r 15
--cols-cSet number of cols in the board-c 20
--multiplayer-mPlay against another player-m
--swap-sSwap player turns (Player2 plays first)-s
--end-eEnd attack turn even if player hits-e
--first-fSet name of first player-f berk
--second-nSet name of second player-n erol

Examples

ExampleDescription
$ battleshipStarts a new game with default settings
$ battleship -r 15Starts a new game with 15 rows
$ battleship -c 20Starts a new game with 20 cols
$ battleship -r 15 -c 20Starts a new game with 15 rows and 20 cols
$ battleship -mStarts a new game in mutliplayer hotseat mode
$ battleship -sStarts a new game in which Player2 plays first
$ battleship -eStarts a new game which ends attack turn even if player hits
$ battleship -f berkStarts a new game with name of first player
$ battleship -n erolStarts a new game with name of second player
$ battleship -f berk -n erolStarts a new game with names of first and second players
$ battleship -m -f berkStarts a new game in multiplayer with name of first player

Contribution

Feel free to contribute according to the semistandard rules and latest ECMAScript Specification.

Distribution

You can distribute this software freely under GNU GPL v3.0.

1.0.4

4 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago