CthulhuRoller: An abstract R6 class representing rolls with a die of a...

Description Public fields Active bindings Methods Examples

Description

A roller has a number of die sides and may support modify rolls.

Public fields

ModifyType

Enumeration that defines the type of a modifier. The 'Bonus' is an enhancement; the 'Malus' is a risk.

Label

A string that characterices the roller and may be used as button label.

Active bindings

DieSides

Sides of the die

ModsAllowed

Does this roller support modify rolls (TRUE/FALSE)?

ModDieSides

The number of sides of a modifier die (readonly)

IsSkillRoller

Does the roller satisfy the characterstics of a skill roll (i.e. 1d100 with modify rolls allowed). (readonly)

Methods

Public methods


Method new()

dieSides Private property

modsAllowed Private property

modDieSides Private property

Constructor

Usage
CthulhuRoller$new(dieSides = NA, label = NA, modDieSides = NA)
Arguments
dieSides

Dies sides

label

A label that could qualify as button label to initiate this roller.

modDieSides

Sides of a modifier die (1 < 'modDieSides' < 'dieSides'/2).

Returns

'invisible(self)'


Method Roll()

Roll the roller to get a die roll result.

Usage
CthulhuRoller$Roll()
Returns

The roll (value between 1 and the number of sides of this roller die).

Examples
\dontrun{
roller = CthulhuRoller(100, "W100", 10)
print(roller$Roll())
}

Method AddModifier()

AddModifier

Usage
CthulhuRoller$AddModifier(Roll, Modifier)
Arguments
Roll

The current roll that shall be modified.

Modifier

A value of enumeration 'CthulhuRoller$ModifyType'.

Returns

The modified roll (value between 1 and the number of sides of this roller die).

Examples
\dontrun{
roller <- CthulhuRoller$new(100, "W100", 10)
print(roller$AddModifier(12, roller$ModifyType["Bonus"])) 
}

Method MaxHardSuccess()

MaxHardSuccess Determine the smallest target value required so that a roll would be a hard success.

Usage
CthulhuRoller$MaxHardSuccess(value)
Arguments
value

A roll result

Returns

Smallest target value required for a hard success


Method MaxExtremeSuccess()

MaxExtremeSuccess Determine the smallest target value required so that a roll would be an extreme success.

Usage
CthulhuRoller$MaxExtremeSuccess(value)
Arguments
value

A roll result

Returns

Smallest target value required for an extreme success


Method MaxBotch()

What is the value for a critical failure?

Usage
CthulhuRoller$MaxBotch(value)
Arguments
value

A roll result

Returns

The value characterizing a critical failure.


Method clone()

The objects of this class are cloneable with this method.

Usage
CthulhuRoller$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## ------------------------------------------------
## Method `CthulhuRoller$Roll`
## ------------------------------------------------

## Not run: 
roller = CthulhuRoller(100, "W100", 10)
print(roller$Roll())

## End(Not run)

## ------------------------------------------------
## Method `CthulhuRoller$AddModifier`
## ------------------------------------------------

## Not run: 
roller <- CthulhuRoller$new(100, "W100", 10)
print(roller$AddModifier(12, roller$ModifyType["Bonus"])) 

## End(Not run)

SigurdJanson/cthulhu documentation built on Dec. 18, 2021, 2 p.m.