dice

package
v0.0.0-...-6b15219 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package dice is a simple package that defines die components with variable numbers of sides.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynamicValue

type DynamicValue struct {
	base.SubState
	base.ComponentValues
	Value        int
	SelectedFace int
}

DynamicValue encodes which face is currently selected.

func (*DynamicValue) ReadSetConfigurer

func (d *DynamicValue) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer

ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for DynamicValue

func (*DynamicValue) ReadSetter

func (d *DynamicValue) ReadSetter() boardgame.PropertyReadSetter

ReadSetter returns an autp-generated boardgame.PropertyReadSetter for DynamicValue

func (*DynamicValue) Reader

Reader returns an autp-generated boardgame.PropertyReader for DynamicValue

func (*DynamicValue) Roll

func (d *DynamicValue) Roll(r *rand.Rand)

Roll sets the Value of the Die randomly to a new value that is legal for the die Value it is associated with. Accepts a source of randomness it will use. You almost always should pass state.Rand() for this to have outcomes that are deterministic for this state (which can be useful for testing scenarios). If r is nil, a generic source of randomness will be used.

type Value

type Value struct {
	base.ComponentValues
	Faces []int
}

Value is the value component of a dice, encoding what the allowable values are.

func BasicDie

func BasicDie(min, max int) *Value

BasicDie returns a die with a face each for min through max, inclusive.

func DefaultDie

func DefaultDie() *Value

DefaultDie returns a die configured as as a typical six-sided die.

func (*Value) Max

func (v *Value) Max() int

Max returns the maximum value face for this die

func (*Value) Min

func (v *Value) Min() int

Min returns the lowest value face for this die

func (*Value) ReadSetConfigurer

func (v *Value) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer

ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for Value

func (*Value) ReadSetter

func (v *Value) ReadSetter() boardgame.PropertyReadSetter

ReadSetter returns an autp-generated boardgame.PropertyReadSetter for Value

func (*Value) Reader

func (v *Value) Reader() boardgame.PropertyReader

Reader returns an autp-generated boardgame.PropertyReader for Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL