Skip to content

Archmage.MinMax

An inclusive range of numbers or durations, the type of a minmax field, for drawing random values.

Inherits: RefCounted

var min: Variant

The lower bound, inclusive: an int, a float or an Archmage.Duration, as the element type of the field.

var max: Variant

The upper bound, inclusive, of the same type as min.

static func from_json(d: Variant, conv: Callable, e: Archmage.ParseError = null) -> Archmage.MinMax

Returns the range in d, a parsed JSON object, converting each bound with conv.call(value, e), which returns the zero value for null. For null, returns a range whose bounds are zero. For any other value that is not an object, returns the same range and records the type mismatch in e (see Archmage.ParseError.report_mismatch()). When conv records an error in e, returns null.

func to_json() -> Dictionary

Returns the range as a JSON object.

func sample(rng: RandomNumberGenerator = null) -> Variant

Returns a random value from min to max, both included, drawn uniformly with rng, or with the global random number generator, which seed() affects, when rng is null. An Archmage.Duration is drawn in whole milliseconds: the bounds are truncated to milliseconds, and every value returned is a whole number of milliseconds.