# -*- coding: utf-8 -*-

"""
This is a very simple "dice rolling" module for python. It uses the
normal random number generator to generate random numbers in the
range from 1 to /sides/.

It also provides shortcuts to the d4, d6, d10, d20 and d100. You
also can call ndX to get a list of n rolls of an X sided dice.

 - Tobias Diekershoff <tobias.diekershoff--at--gmx.net>
   released under a Creative Commons License CC-BY-3.0

Versions
  0.1     TD    2009-FEB-25    initial set of dices
"""

import random

def dice(sides):
	"""Rolls the dice - IOW returns a random number up to sides"""
	return random.randint(1,sides)

def d4():
	"""Rolls a d4"""
	return dice(4)

def d6():
	"""Rolls a d6"""
	return dice(6)

def d10():
	"""Rolls a d10"""
	return dice(10)

def d20():
	"""Rolls a d20"""
	return dice(20)

def d100():
	"""Rolls a d100"""
	return dice(100)

def nd4(n):
	"""Rolls n times a d4 and returns the result as a list"""
	r = []
	for i in range(0,n):
		r.append(d4())
	return r

def nd6(n):
	"""Rolls n times a d6 and returns the result as a list"""
	r = []
	for i in range(0,n):
		r.append(d6())
	return r

def nd10(n):
	"""Rolls n times a d10 and returns the result as a list"""
	r = []
	for i in range(0,n):
		r.append(d10())
	return r

def nd20(n):
	"""Rolls n times a d20 and returns the result as a list"""
	r = []
	for i in range(0,n):
		r.append(d20())
	return r

def nd100(n):
	"""Rolls n times a d100 and returns the result as a list"""
	r = []
	for i in range(0,n):
		r.append(d6())
	return r

def ndices(n,s):
	"""Rolls n times a dice with s sides"""
	r = []
	for i in range(0,n):
		r.append(dice(s))
	return r