Example #1
0
  // Chamado quando o botão rolar dado é pressionado
  @Action
  public void bt_rolar_dado() {
    String s = "";
    try {
      int dado, tot = 0, i, i_f = Integer.parseInt(txt_num_dados.getText());

      if (!(i_f > 0)) {
        JOptionPane.showMessageDialog(
            null, "Você só pode rolar um número maior que zero de dados!");
        txt_modificador.setText("0");
        txt_num_dados.setText("1");
        return;
      }

      for (i = 0; i < i_f; i++) {
        dado = (int) (1 + (6 * random()));
        dado += Integer.parseInt(txt_modificador.getText());
        tot += dado;
        if (mestrando) {
          s += "\nO dado rolado por <Mestre> " + "foi: " + dado;
        } else {
          s += "\nO dado rolado por <" + cliente.getNick() + "> " + "foi: " + dado;
        }
      }

      if (mestrando) {
        s +=
            "\nForam rolados "
                + i_f
                + " dados por "
                + "<Mestre>, com o modificador: "
                + Integer.parseInt(txt_modificador.getText())
                + ". O total é: "
                + tot;
      } else {
        s +=
            "\nForam rolados "
                + i_f
                + " dados por "
                + "<"
                + cliente.getNick()
                + ">, com o modificador: "
                + Integer.parseInt(txt_modificador.getText())
                + ". O total é: "
                + tot;
      }

      enviar(s);
    } catch (NumberFormatException e) {
      JOptionPane.showMessageDialog(
          null, "Digite números em \"Modificador\" e \"Número de dados\"");
      txt_modificador.setText("0");
      txt_num_dados.setText("1");
    }
  }
Example #2
0
 public void enviar(String s) {
   if (mestrando) {
     mestre.Enviar_mensagem(s);
   } else {
     cliente.Escrever_mensagem(s);
   }
 }
Example #3
0
  @Action
  public void bt_editar_ficha() {
    JFrame jan;
    if (mestrando) {
      jan = new Frame_Ficha(RPG_globais.getMinha_ficha(), mestre_ficha);
    } else {
      jan = new Frame_Ficha(RPG_globais.getMinha_ficha(), cliente.getConecxao_ficha());
    }

    jan.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    jan.setVisible(true);
  }