npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

battleship-cli

v1.1.0

Published

A Battleship CLI game, built with JavaScript

Downloads

11

Readme

Battleship-Cli

A super cool, fun, and easy to play command line implementation of Battleship, the classic 2-player guessing game. Built in JavaScript, battleship-cli is a simple NodeJS program, with CLI interface enabled by InquirerJS, and colorized by chalk.

image

Requirements:

  • Node

Installation & Usage:

  • With NPM*:
    • npm install -g battleship-cli
  • With Yarn*:
    • yarn global add battleship-cli
  • Manually (for hacking):
    • clone repo
    • run npm install or yarn install to install dependencies
    • run npm i -g to make the module available globally
  • To play:
    • In your favorite terminal, simply run the battleship command from any directory
    • For the best experience use a terminal that has full color and emoji support

*Note: If anything except version 1.1.0 gets pulled down, please explicitly install the correct version instead by appending @1.1.0 to either command.

Battleship-CLI Instructions

Type help and hit return at any time during gameplay to show these instructions.

Other helpful commands:

  • Type show score at any time to check the status of the game.
  • Type quit or q at any time to quit the game.

Settings:

  • NOTE: If your terminal does not support Emojis, please disable Emojis in the settings menu.
  • For a more challenging game, you can choose a larger board size.
  • You can also adjust the computer's skill level.

How to win:

  • Each player has a battlefield represented by a 10x10 grid on which they place 5 ships, hidden to their opponent.
  • The goal of the game is sink all of your opponents ships! A ship is sunk when it is hit once for each space it occupies.
  • In other words, a submarine, which occupies 3 spaces, is sunk after being hit 3 times.
  • The 5 ships occupy 17 total spaces, so the first player to register 17 hits wins!

Gameplay:

  • To play, follow the prompts to configure your five ships in any pattern you'd like (diagonal placements are not allowed).
  • Valid configuration instructions include a ship name, a starting coordinate (A1-J10 for default 10x10 board), and a direction (right, left, up or down).
  • For example: submarine e3 up or carrier j7 left. Ships cannot overlap, and you must stay within the bounds of the board.
  • Once both players have configured their ships, the race is on to sink your opponent's ships before they sink yours!
  • Fire torpedoes at your opponent's ships by guessing coordinates on the 10x10 board.
  • Rows are represented by the letters A-J, and columns with the numbers 1-10 (10x10 board).
  • Valid guesses include a row followed by a column, e.g. A1, B7, J10, etc.
  • You will be informed if you've hit, missed, or sunk a ship.
  • Sink all 5 of the computer's ships to win!

Hint:

  • When placing ships, you can also use abbreviations to make your life easier!
  • Use the ship's abbreviations (see legend), and single letters for directions.
  • e.g. btl a9 r or cru i6 u

Legend:

  • Battleship (BTL), 4 spaces
  • Carrier (CAR), 5 spaces
  • Cruiser (CRU), 3 spaces
  • Destroyer (DST), 2 spaces
  • Submarine (SUB), 3 spaces
  • A hit looks like 💥 or X (depending on Emoji support)
  • A miss looks like ❌ or 0 (depending on Emoji support)

Screenshots:

Placing Ships

image

Gameplay (10x10 Emoji Board)

image

Gameplay (12x12 Plain Board)

image

20x20 Board

image

Helpful Validations

image image image

In-Game Instructions

image