Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kenziebottoms/nss-back-01-diceroll
Node modularity and testing practice exercise.
https://github.com/kenziebottoms/nss-back-01-diceroll
chai javascript js mocha mochajs modularity node nodejs testing
Last synced: about 2 months ago
JSON representation
Node modularity and testing practice exercise.
- Host: GitHub
- URL: https://github.com/kenziebottoms/nss-back-01-diceroll
- Owner: kenziebottoms
- Archived: true
- Created: 2018-03-06T17:24:11.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-03-13T18:19:55.000Z (over 6 years ago)
- Last Synced: 2024-09-18T23:39:11.655Z (about 2 months ago)
- Topics: chai, javascript, js, mocha, mochajs, modularity, node, nodejs, testing
- Language: JavaScript
- Homepage: https://github.com/kenziebottoms/nss-back-end-01-foundations/tree/master/exercises
- Size: 39.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Modularity
![](https://img.shields.io/badge/modularity-node-green.svg)
![](https://img.shields.io/badge/mvp-working-green.svg)
![](https://img.shields.io/badge/testing-chai+mocha-a40802.svg)### Run Locally
Note: Written on and dependent on Linux infrastructure; may work on Mac OS.
```bash
git clone [email protected]:kenziebottoms/nss-back-01-diceroll.git
cd nss-back-01-diceroll/bin
./diceroll
```
If permission is denied, try
```bash
sudo chmod +x diceroll
```### Usage
Roll any number of dice with any number of sides.
```bash
./diceroll # rolls one six-sided die
``````bash
./diceroll 20 # rolls one twenty-sided die
``````bash
./diceroll 2 20 # rolls two twenty-sided dice
```## Requirements
Create a program that performs a dice roll. You will need a folder `dice-roll` with at least 5 files to accomplish this task.
### File structure
```
|-- bin/
|-- diceroll
|-- lib/
| |-- cli.js
| |-- dice.js
| |-- math.js
| `-- parse-args.js
|-- README.md
`-- package.json
```### Goals
- [x] This library should be globally installed or linked such that you can execute it anywhere on your system. (Use a shebang.)
- [x] `diceroll` should be the only file that has permissions to execute.
- [x] It should also include only single line of code that requires the `cli.js` lib file and a shebang.
- [x] `math.js` should export an `Object` with a method called `randomInt(min, max)`.
- [x] This function should return a random integer inclusive of the lower bound and the upper bound.
- [x] `parse-args.js` should export a single function to parse your command line arguments.
- [x] The function should accept an array containing the arguments passed on the command line.
- [x] Convert these arguments to `Object { count, sides }`.
- [x] `dice.js` should export an `Object` with at least two methods called `roll()` and `toDiceNotation()`.
- [x] `toDiceNotation()` should accept an object with a sides and count property and convert it to a `String` with the dice notation
- i.e. "1d6" or "2d40".
- [x] `roll()` should accept a dice notation `String` and produce a random `Number` which is the result of the dice roll.
- [x] `cli.js` should work like a controller. It should have no logic on its own.Use [this sample code](sample.js) to get you started:
### Expected:
```bash
$ diceroll
3 # Result of a single roll of a standard 6 sided dice: i.e. random integer 1 - 6
``````bash
$ diceroll 20
10 # Result of a single roll of a 20 sided dice: i.e. random integer 1 - 20
``````bash
$ diceroll 2 100
100 # Result of 2 rolls of a 100 sided dice: i.e. random integer 2 - 200
```