src/z-dice.c
void dice_random_value(dice_t *dice, random_value *v)
{
	if (v == NULL)
		return;

	if (dice->ex_b) {
		if (dice->expressions != NULL && dice->expressions[dice->b].expression != NULL)
			v->base = expression_evaluate(dice->expressions[dice->b].expression);
		else
			v->base = 0;
	}
	else
		v->base = dice->b;

	if (dice->ex_x) {
		if (dice->expressions != NULL && dice->expressions[dice->x].expression != NULL)
			v->dice = expression_evaluate(dice->expressions[dice->x].expression);
		else
			v->dice = 0;
	}
	else
		v->dice = dice->x;

	if (dice->ex_y) {
		if (dice->expressions != NULL && dice->expressions[dice->y].expression != NULL)
			v->sides = expression_evaluate(dice->expressions[dice->y].expression);
		else
			v->sides = 0;
	}
	else
		v->sides = dice->y;

	if (dice->ex_m) {
		if (dice->expressions != NULL && dice->expressions[dice->m].expression != NULL)
			v->m_bonus = expression_evaluate(dice->expressions[dice->m].expression);
		else
			v->m_bonus = 0;
	}
	else
		v->m_bonus = dice->m;
}
/**
 * Extract a random_value by evaluating any bound expressions.
 *
 * \param dice is the object to get the random_value from.
 * \param v is the random_value to place the values into.
 */
Extract a random_value by evaluating any bound expressions.
\param dice is the object to get the random_value from.
\param v is the random_value to place the values into.
Extract a random_value by evaluating any bound expressions . \ param dice is the object to get the random_value from . \ param v is the random_value to place the values into .
void dice_random_value(dice_t *dice, random_value *v)
{
	if (v == NULL)
		return;
	if (dice->ex_b) {
		if (dice->expressions != NULL && dice->expressions[dice->b].expression != NULL)
			v->base = expression_evaluate(dice->expressions[dice->b].expression);
		else
			v->base = 0;
	}
	else
		v->base = dice->b;
	if (dice->ex_x) {
		if (dice->expressions != NULL && dice->expressions[dice->x].expression != NULL)
			v->dice = expression_evaluate(dice->expressions[dice->x].expression);
		else
			v->dice = 0;
	}
	else
		v->dice = dice->x;
	if (dice->ex_y) {
		if (dice->expressions != NULL && dice->expressions[dice->y].expression != NULL)
			v->sides = expression_evaluate(dice->expressions[dice->y].expression);
		else
			v->sides = 0;
	}
	else
		v->sides = dice->y;
	if (dice->ex_m) {
		if (dice->expressions != NULL && dice->expressions[dice->m].expression != NULL)
			v->m_bonus = expression_evaluate(dice->expressions[dice->m].expression);
		else
			v->m_bonus = 0;
	}
	else
		v->m_bonus = dice->m;
}
void dice_random_value ( dice_t * dice , random_value * v ) { if ( v == NULL ) return ; if ( dice -> ex_b ) { if ( dice -> expressions != NULL && dice -> expressions [ dice -> b ] . expression != NULL ) v -> base = expression_evaluate ( dice -> expressions [ dice -> b ] . expression ) ; else v -> base = 0 ; } else v -> base = dice -> b ; if ( dice -> ex_x ) { if ( dice -> expressions != NULL && dice -> expressions [ dice -> x ] . expression != NULL ) v -> dice = expression_evaluate ( dice -> expressions [ dice -> x ] . expression ) ; else v -> dice = 0 ; } else v -> dice = dice -> x ; if ( dice -> ex_y ) { if ( dice -> expressions != NULL && dice -> expressions [ dice -> y ] . expression != NULL ) v -> sides = expression_evaluate ( dice -> expressions [ dice -> y ] . expression ) ; else v -> sides = 0 ; } else v -> sides = dice -> y ; if ( dice -> ex_m ) { if ( dice -> expressions != NULL && dice -> expressions [ dice -> m ] . expression != NULL ) v -> m_bonus = expression_evaluate ( dice -> expressions [ dice -> m ] . expression ) ; else v -> m_bonus = 0 ; } else v -> m_bonus = dice -> m ; }
Extract a random_value by evaluating any bound expressions.
Extract a random_value by evaluating any bound expressions .