Esempio n. 1
0
  public Joueur(
      String pseudo, Carte carteMain1, Carte carteMain2, boolean dealer, boolean historique) {
    this.pseudo = pseudo;
    this.carteMain1 = carteMain1;
    this.carteMain2 = carteMain2;
    this.dealer = dealer;
    this.stack = stack;
    this.mise = mise;
    this.historique = historique;

    if (historique) {
      // Ajout du Joueur et récupèration en cas d'existance
      try {
        Statement stat = CmdSql.GererBD();
        String cmd =
            new String(
                "SELECT COUNT(ID_Joueur) as ID_Joueur FROM Joueur WHERE Pseudo = '"
                    + pseudo
                    + "';");
        id = CmdSql.RecupererJoueur(cmd);

        if (id == 0) {
          stat.executeUpdate("insert into Joueur(Pseudo) values('" + pseudo + "')");
          cmd = new String("SELECT ID_Joueur FROM Joueur WHERE Pseudo = '" + pseudo + "';");
          id = CmdSql.RecupererJoueur(cmd);
        } else {
          cmd = new String("SELECT ID_Joueur FROM Joueur WHERE Pseudo = '" + pseudo + "';");
          id = CmdSql.RecupererJoueur(cmd);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else {
      String cmd = new String("SELECT ID_Joueur FROM Joueur WHERE Pseudo = '" + pseudo + "';");
      try {
        id = CmdSql.RecupererJoueur(cmd);
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    this.id = id;
  }
Esempio n. 2
0
 public void check(String idPartie) {
   if (historique) {
     // Ajout a historique
     try {
       Statement stat = CmdSql.GererBD();
       stat.executeUpdate(
           "insert into Coups(ID_Action, ID_Joueur, ID_Partie) values('2','"
               + this.getId()
               + "','"
               + idPartie
               + "')");
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
Esempio n. 3
0
  public void setStack(int pot, String idPartie) {
    this.stack = pot;

    if (historique) {
      // Ajout a historique
      try {
        Statement stat = CmdSql.GererBD();
        stat.executeUpdate(
            "insert into Coups(ID_Action, ID_Joueur, ID_Partie, Montant) values('7','"
                + this.getId()
                + "','"
                + idPartie
                + "', '"
                + pot
                + "')");
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Esempio n. 4
0
  public void gagne(Partie p) {

    // Ajouter � Historique
    if (historique) {
      // Ajout a historique
      try {
        Statement stat = CmdSql.GererBD();
        stat.executeUpdate(
            "insert into Coups(ID_Action, ID_Partie, ID_Joueur) values('8','"
                + p.getIdPartie()
                + "','"
                + this.getId()
                + "')");
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    p.InitManche(this, true);
  }
Esempio n. 5
0
  public void aligner(Joueur adversaire, String idPartie) {
    int difference = adversaire.getMise() - this.getMise();
    this.stack = this.stack - difference;
    this.mise += difference;

    if (historique) {
      // Ajout a historique
      try {
        Statement stat = CmdSql.GererBD();
        stat.executeUpdate(
            "insert into Coups(ID_Action, ID_Joueur, ID_Partie) values('6','"
                + this.getId()
                + "','"
                + idPartie
                + "')");
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }