LambdaHack-0.6.2.0: A game engine library for roguelike dungeon crawlers

Safe HaskellNone
LanguageHaskell2010

Game.LambdaHack.Common.Dice

Contents

Description

Representation of dice for parameters scaled with current level depth.

Synopsis

Frequency distribution for casting dice scaled with level depth

data Dice Source #

Dice for parameters scaled with current level depth. To the result of rolling the first set of dice we add the second, scaled in proportion to current depth divided by maximal dungeon depth. The result if then multiplied by the scale --- to be used to ensure that dice results are multiples of, e.g., 10. The scale is set with |*|.

Dice like 100d100 lead to enormous lists, so we help a bit by keeping simple dice nonstrict below.

Instances

Eq Dice Source # 

Methods

(==) :: Dice -> Dice -> Bool #

(/=) :: Dice -> Dice -> Bool #

Num Dice Source # 

Methods

(+) :: Dice -> Dice -> Dice #

(-) :: Dice -> Dice -> Dice #

(*) :: Dice -> Dice -> Dice #

negate :: Dice -> Dice #

abs :: Dice -> Dice #

signum :: Dice -> Dice #

fromInteger :: Integer -> Dice #

Ord Dice Source # 

Methods

compare :: Dice -> Dice -> Ordering #

(<) :: Dice -> Dice -> Bool #

(<=) :: Dice -> Dice -> Bool #

(>) :: Dice -> Dice -> Bool #

(>=) :: Dice -> Dice -> Bool #

max :: Dice -> Dice -> Dice #

min :: Dice -> Dice -> Dice #

Show Dice Source # 

Methods

showsPrec :: Int -> Dice -> ShowS #

show :: Dice -> String #

showList :: [Dice] -> ShowS #

Generic Dice Source # 

Associated Types

type Rep Dice :: * -> * #

Methods

from :: Dice -> Rep Dice x #

to :: Rep Dice x -> Dice #

Binary Dice Source # 

Methods

put :: Dice -> Put #

get :: Get Dice #

putList :: [Dice] -> Put #

NFData Dice Source # 

Methods

rnf :: Dice -> () #

Hashable Dice Source # 

Methods

hashWithSalt :: Int -> Dice -> Int #

hash :: Dice -> Int #

type Rep Dice Source # 
type Rep Dice = D1 * (MetaData "Dice" "Game.LambdaHack.Common.Dice" "LambdaHack-0.6.2.0-6LvAjp6yuzE4Q9dWwe00a" False) (C1 * (MetaCons "Dice" PrefixI True) ((:*:) * (S1 * (MetaSel (Just Symbol "diceConst") NoSourceUnpackedness SourceLazy DecidedLazy) (Rec0 * SimpleDice)) ((:*:) * (S1 * (MetaSel (Just Symbol "diceLevel") NoSourceUnpackedness SourceLazy DecidedLazy) (Rec0 * SimpleDice)) (S1 * (MetaSel (Just Symbol "diceMult") NoSourceUnpackedness NoSourceStrictness DecidedStrict) (Rec0 * Int)))))

(|*|) :: Dice -> Int -> Dice infixl 5 Source #

Multiplying the dice, after all randomness is resolved, by a constant. Infix declaration ensures that 1 + 2 |*| 3 parses as (1 + 2) |*| 3.

d :: Int -> Dice Source #

A single simple dice.

dl :: Int -> Dice Source #

Dice scaled with level.

maxDice :: Dice -> Int Source #

Maximal value of dice. The scaled part taken assuming median level.

minDice :: Dice -> Int Source #

Minimal value of dice. The scaled part taken assuming median level.

meanDice :: Dice -> Int Source #

Mean value of dice. The scaled part taken assuming median level. Assumes the frequencies are not null.

Dice for rolling a pair of integer parameters representing coordinates.

data DiceXY Source #

Dice for rolling a pair of integer parameters pertaining to, respectively, the X and Y cartesian 2D coordinates.

Constructors

DiceXY Dice Dice 

Instances

Eq DiceXY Source # 

Methods

(==) :: DiceXY -> DiceXY -> Bool #

(/=) :: DiceXY -> DiceXY -> Bool #

Ord DiceXY Source # 
Show DiceXY Source # 
Generic DiceXY Source # 

Associated Types

type Rep DiceXY :: * -> * #

Methods

from :: DiceXY -> Rep DiceXY x #

to :: Rep DiceXY x -> DiceXY #

Binary DiceXY Source # 

Methods

put :: DiceXY -> Put #

get :: Get DiceXY #

putList :: [DiceXY] -> Put #

Hashable DiceXY Source # 

Methods

hashWithSalt :: Int -> DiceXY -> Int #

hash :: DiceXY -> Int #

type Rep DiceXY Source # 
type Rep DiceXY = D1 * (MetaData "DiceXY" "Game.LambdaHack.Common.Dice" "LambdaHack-0.6.2.0-6LvAjp6yuzE4Q9dWwe00a" False) (C1 * (MetaCons "DiceXY" PrefixI False) ((:*:) * (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedStrict) (Rec0 * Dice)) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedStrict) (Rec0 * Dice))))

maxDiceXY :: DiceXY -> (Int, Int) Source #

Maximal value of DiceXY.

minDiceXY :: DiceXY -> (Int, Int) Source #

Minimal value of DiceXY.

meanDiceXY :: DiceXY -> (Int, Int) Source #

Mean value of DiceXY.

Internal operations

Orphan instances