Esempio n. 1
0
 protected void reset_board() {
   db.resetBoard();
   configure_die(db);
   for (int die = 0; die < DiceBoard.NUMDIE; die++) {
     chbs[die].setSelected(false);
     chbs[die].setEnabled(false);
   }
 }
Esempio n. 2
0
  protected void doARoll(DiceBoard db, Match m, final JButton rollBut) {
    db.rollBoard();

    configure_die(db);
    for (int die = 0; die < DiceBoard.NUMDIE; die++) {
      chbs[die].setEnabled(true);
    }
    switch (db.getNextRollNum()) {
      case 1:
        // Roll number has cycled round to 1.
        rollBut.setEnabled(false); // Will be reset on score allocation
        break;
      case 2:
        rollBut.setText("Second Roll");
        break;
      case 3:
        rollBut.setText("Last Roll");
        break;
    }
  }
Esempio n. 3
0
  private void make_dice_and_JCheckBoxes(final DiceBoard db, boolean cheat) {
    diceSet.setBackground(Color.white);
    GridBagLayout gb = new GridBagLayout();
    GridBagConstraints gc;
    diceSet.setLayout(gb);
    for (int die = 0; die < DiceBoard.NUMDIE; die++) {
      dice[die] = new GuiDice(db.getDie(die), cheat);
      gc = new GridBagConstraints();
      gc.gridy = 0;
      gc.gridx = die;
      gb.setConstraints(dice[die], gc);
      diceSet.add(dice[die]);
    }
    // Add the roll JButton
    gc = new GridBagConstraints();
    gc.gridy = 0;
    gc.gridx = DiceBoard.NUMDIE;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1.0;
    gb.setConstraints(rollButton, gc);
    diceSet.add(rollButton);

    for (int die = 0; die < DiceBoard.NUMDIE; die++) {
      final int which = die;
      chbs[which] = new JCheckBox();
      chbs[which].setEnabled(false);
      chbs[which].addItemListener(
          new ItemListener() {
            // This method is called when the user clicks the JCheckBox
            public void itemStateChanged(ItemEvent e) {
              if (e.getStateChange() == ItemEvent.DESELECTED) db.getDie(which).setLock(false);
              else db.getDie(which).setLock(true);
            }
          });
      gc = new GridBagConstraints();
      gc.gridy = 1;
      gc.gridx = die;
      gb.setConstraints(chbs[die], gc);
      diceSet.add(chbs[which]);
    }

    gc = new GridBagConstraints();
    gc.gridy = 1;
    gc.gridx = DiceBoard.NUMDIE;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    gb.setConstraints(nextPlayerJButton, gc);
    diceSet.add(nextPlayerJButton);
  }
Esempio n. 4
0
 /* The following methods are concerned with controlling the game state */
 public void configure_die(DiceBoard db) {
   for (int die = 0; die < DiceBoard.NUMDIE; die++) {
     dice[die].showval(db.getDie(die).getValue());
   }
 }