Skip to content

dowenb/dice-cards

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dice-cards

A fairer way to provide 2d6 dice rolls!

This GitHub project focuses on enhancing the gaming experience of games that roll 2 6-sided dice (2d6). For example, Settlers of Catan is a board game where players build settlements and cities on a board with numbered tiles representing resources. Players roll 2d6 to determine which tiles produce resources each turn.

To mitigate the potential frustration of random dice rolls and the risk of detrimental streaks impacting game play, the project proposes using a deck of cards representing all possible dice roll combinations (2-12) to ensure a more balanced distribution of resources over time.

However, using just one deck can lead to predictability, so the concept is extended to incorporate multiple decks. By employing 'n' decks, each containing cards representing different dice roll combinations, the project aims to reintroduce an element of unpredictability while still maintaining overall distribution balance.

What works so far

import { deck } from 'dice-cards';

# Get a new deck of dice cards
# A deck is an array of card objects
# each card has 3 elements, die1, die2 and sum
const cardDeck = deck();

# Get a card from a random place in the deck
# This assigns 1 card to the variable randomCard and removes it from the deck
const randomCard = cardDeck.splice(Math.floor(Math.random() * cardDeck.length), 1)


console.log(randomCard)
# [ { die1: 5, die2: 3, sum: 8 } ]

TODO

  • Create a stack of multiple decks to reduce predictability
  • Persist a single instance of the deck, removing need for handling the deck in client application
  • Create a draw card function that returns a random card from the deck
  • Reset and shuffle the deck
  • Allow card to be returned to the deck
  • Introduce robust tests
  • Auto publish package on push to repository
  • Improve documentation

About

A fairer way to provide 2d6 dice rolls

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published