Giter Site home page Giter Site logo

battleship-cli's Introduction

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

battleship-cli's People

Contributors

no-stack-dub-sack avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.