/* Callback on dice press */ gint modify_dice (GtkWidget * widget, gpointer data) { DiceInfo *tmp = (DiceInfo *) data; GtkToggleToolButton *button = GTK_TOGGLE_TOOL_BUTTON (widget); /* Don't modify dice if player is marked finished or computer is playing */ if (players[CurrentPlayer].finished || players[CurrentPlayer].comp) { if (gtk_toggle_tool_button_get_active (button)) gtk_toggle_tool_button_set_active (button, FALSE); return TRUE; } if (NumberOfRolls >= NUM_ROLLS) { say (_("You are only allowed three rolls. Choose a score slot.")); gtk_toggle_tool_button_set_active (button, FALSE); return TRUE; } tmp->sel = gtk_toggle_tool_button_get_active (button); UpdateAllDicePixmaps (); update_roll_button_sensitivity (); return TRUE; }
/* Display current player and refresh dice/display */ void DisplayCurrentPlayerRefreshDice(void) { DisplayCurrentPlayer(); UpdateAllDicePixmaps (); DeselectAllDice (); UpdateRollLabel(); }
void RollSelectedDice (void) { int i, cnt = 0; if (NumberOfRolls >= NUM_ROLLS) { return; } for (i = 0; i < NUMBER_OF_DICE; i++) { if (DiceValues[i].sel) { DiceValues[i].val = RollDie (); DiceValues[i].sel = 0; cnt++; lastRoll.DiceValues[i] = DiceValues[i].val; } } /* If no dice is selcted roll them all */ if (cnt == 0) { for (i = 0; i < NUMBER_OF_DICE; i++) { DiceValues[i].val = RollDie (); lastRoll.DiceValues[i] = DiceValues[i].val; } } UpdateAllDicePixmaps (); DeselectAllDice (); NumberOfRolls++; if (NumberOfRolls >= NUM_ROLLS) { say (_("Choose a score slot.")); } lastRoll.roll = NumberOfRolls; lastRoll.player = CurrentPlayer; }