コード例 #1
0
ファイル: PartieDaoImpl.java プロジェクト: Saluki/WazabiGame
  public Partie commencerPartie(int nbCartesParJoueur, int nbDesParJoueurs) {
    Partie p = getPartieCourante();
    if (p == null || p.getStatut() != Status.EN_ATTENTE || p.getStatut() == Status.ANNULEE)
      return null;
    p.setStatut(Status.COMMENCE);

    int nbJoueurs = getPartieCourante().getJoueursParties().size();
    for (int i = 0; i < nbJoueurs; i++) {
      for (int j = 0; j < nbCartesParJoueur; j++)
        gestionPartie.piocherUneCarte(getPartieCourante().getJoueursParties().get(i).getJoueur());
    }
    // Attribution des des aux joueurs
    int cpt = 1;
    for (Joueur j : listerJoueurPartieCourante()) {
      List<De> des = new ArrayList<De>();
      for (int nbDes = 0; nbDes < nbDesParJoueurs; nbDes++) {
        des.add(deDaoImpl.rechercher(cpt));
        cpt++;
      }
      joueurPartieDao.setDes(j, des);
    }

    p.setCourant(joueurPartieDao.getJoueurCourant());
    super.mettreAJour(p);
    return p;
  }
コード例 #2
0
ファイル: PartieDaoImpl.java プロジェクト: Saluki/WazabiGame
 public Partie enregistrerPioche(List<Carte> pioche) {
   pioche = melangerPioche(pioche);
   Partie p = getPartieCourante();
   for (int i = 0; i < pioche.size(); i++) {
     Carte c = pioche.get(i);
     c = carteDaoImpl.recharger(c.getId_carte());
     p.ajouterCarteALaPioche(c);
   }
   return super.enregistrer(p);
 }
コード例 #3
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();
  }
コード例 #4
0
ファイル: PartieDaoImpl.java プロジェクト: Saluki/WazabiGame
 public Partie setCourant(JoueurPartie suivant, Partie partie) {
   partie.setCourant(suivant);
   return super.mettreAJour(partie);
 }