コード例 #1
0
ファイル: PartieDaoImpl.java プロジェクト: Saluki/WazabiGame
  public Partie rejoindrePartie(Joueur j) throws NoCurrentGameException {
    // On verifie que le joueur ne serait pas deja dans la partie...
    if (joueurPartieDao.getJoueurDeLaPartieCourante(j) == null) {
      JoueurPartie jp = new JoueurPartie(ordre++, 0, null, null);
      Partie p = getPartieCourante();
      if (p == null
          || p.getStatut() == Partie.Status.PAS_COMMENCE
          || p.getStatut() == Status.ANNULEE) throw new NoCurrentGameException();

      jp.setPartie(p);
      p.ajouterJoueurPartie(jp);
      jp.setJoueur(j);
      if (p.getCourant() == null) {
        p.setCourant(jp);
      }
      joueurPartieDao.enregistrer(jp);
      return super.enregistrer(p);
    }
    return getPartieCourante();
  }