Package belotetime.application.game

Examples of belotetime.application.game.Set


    g.addPlayer(g.getT1(), g.getPlayers().get(2));
    g.addPlayer(g.getT2(), g.getPlayers().get(3));
   
    g.getPacket().shuffle();
   
    g.setCurrentSet(new Set(g, g.getPlayers().get((int)(Math.random() * 4))));
    g.getCurrentSet().firstDeal(Set.THREE_CARDS);
  }
 
View Full Code Here


 
  @Test
  public void testXmlToGame()
  {
    Game game = XmlFeeds.xmlToGame(XmlFeeds.gameToXml(g));
    Set s = game.getCurrentSet();
    if(s.getTaker().getLogin().isEmpty())
      s.setTaker(null);
    if(s.getDealer().getLogin().isEmpty())
      s.setDealer(null);
    if(s.getStarter().getLogin().isEmpty())
      s.setStarter(null);
    if(s.getTrump().equals("false"))
      s.setTrump(null);
   
    assertEquals(g.getCurrentSet().getTrump(), s.getTrump());
    assertEquals(g.getCurrentSet().getStarter(), s.getStarter());
    assertEquals(g.getCurrentSet().getTaker(), s.getTaker());
    assertEquals(g.getT2().getP1().getLogin(), "Joueur 2");
  }
View Full Code Here

  {
    g.getCurrentSet().setTurn(Set.SECOND_TURN);
    String xml = XmlFeeds.setToXml(g.getCurrentSet());
    String turn = XmlFeeds.xmlGetTag(xml, "turn");
    int t = Integer.parseInt(turn);
    Set s = XmlFeeds.xmlToSet(xml);
  }
View Full Code Here

        game = new Game(new Pack(listCards));
        game.getPlayers().add(new Player("Joueur 1"));
        game.getPlayers().add(new Player("Joueur 2"));
        game.getPlayers().add(new Player("Joueur 3"));
        game.getPlayers().add(new Player("Joueur 4"));
        game.setCurrentSet(new Set(game, game.getPlayers().get(3)));
       
        set = game.getCurrentSet();
  }
View Full Code Here

      if(game.getT1().getPoints() + game.getT2().getPoints() == 152)
      {
        game.getCurrentSet().result();
        game.getPacket().cut();
        int dealer = game.getPlayers().indexOf(game.getCurrentSet().getDealer());
        game.setCurrentSet(new Set(game, game.getPlayers().get((dealer + 1) % 4)));
        game.getCurrentSet().defineStarter();
        game.getCurrentSet().firstDeal(Set.THREE_CARDS);
      }
     
      //Fin de la partie
View Full Code Here

          p.getHand().getCards().removeAll(p.getHand().getCards());
        }
       
        game.getPacket().cut();
        int numDealer = game.getPlayers().indexOf(game.getCurrentSet().getDealer());
        game.setCurrentSet(new Set(game, game.getPlayers().get((numDealer + 1) % 4)));
        game.getCurrentSet().defineStarter();
        game.getCurrentSet().firstDeal(Set.THREE_CARDS);
      }
     
      notifyView(game);
View Full Code Here

  {
    server.getGame().getPacket().shuffle();
    server.getGame().getPacket().cut();
   
    //Cr�ation de la premi�re manche avec un premier donneur choisi au pif
    server.getGame().setCurrentSet(new Set(server.getGame(), server.getGame().getPlayers().get((int)(Math.random() * 4))));
    server.getGame().getCurrentSet().defineStarter();
    server.getGame().getCurrentSet().firstDeal(Set.THREE_CARDS);
  }
 
View Full Code Here

                    p.getHand().getCards().removeAll(p.getHand().getCards());
                  }
                 
                  server.getGame().getPacket().cut();
                  int numDealer = server.getGame().getPlayers().indexOf(server.getGame().getCurrentSet().getDealer());
                  server.getGame().setCurrentSet(new Set(server.getGame(), server.getGame().getPlayers().get((numDealer + 1) % 4)));
                  server.getGame().getCurrentSet().defineStarter();
                  server.getGame().getCurrentSet().firstDeal(Set.THREE_CARDS);
                }
                connect();
              }
              catch(NumberFormatException e)
              {
                e.printStackTrace();
              }
              break;
            case "passSet" :
              //On ajoute le score global aux deux �quipes et on r�initialiste les plis
              server.getGame().getT1().updatePoints();
              server.getGame().getT2().updatePoints();           
              server.getGame().getPacket().cut();
              int numDealer = server.getGame().getPlayers().indexOf(server.getGame().getCurrentSet().getDealer());
              server.getGame().setCurrentSet(new Set(server.getGame(), server.getGame().getPlayers().get((numDealer + 1) % 4)));
              server.getGame().getCurrentSet().defineStarter();
              server.getGame().getCurrentSet().firstDeal(Set.THREE_CARDS);
              break;
            case "takeTrump" :
              String color = XmlFeeds.xmlGetTag(data, "color");
              player = Integer.parseInt(XmlFeeds.xmlGetTag(data, "numplayer"));
              Card trump = server.getGame().getPacket().getCards().get(server.getGame().getPacket().getCards().size() - 1);
              color = color.length() == 0 ? trump.getColor() : color;
              server.getGame().getCurrentSet().setTrump(color);
              server.getGame().getCurrentSet().takeTrump(server.getGame().getPlayers().get(player));
              server.getGame().getCurrentSet().secondDeal();
              server.getGame().getCurrentSet().alterTrumpValue();
              connect();
              break;
            case "playCard" :
              player = Integer.parseInt(XmlFeeds.xmlGetTag(data, "player"));
              Player p = server.getGame().getPlayers().get(player);
             
              boolean b = Boolean.parseBoolean(XmlFeeds.xmlGetTag(data, "belote"));
              if(b) server.getGame().getCurrentSet().playBelote();
             
              if(server.getGame().getCurrentSet().getBelotePlayed() == 2)
              {
                Team t = player % 2 == 0 ? server.getGame().getT1() : server.getGame().getT2();
                t.setBelote(true);
              }
             
              int numCard = Integer.parseInt(XmlFeeds.xmlGetTag(data, "card"));
              server.getGame().getCarpet().getCards().add(p.playCard(numCard));
              server.getGame().getCurrentSet().nextStarter();
              connect();
              break;
            case "initTrick" :
              //Fin du pli
              server.getGame().getCurrentSet().trickWin();
              server.getGame().setCarpet(new Pack());
             
              //Fin de la manche
              if(server.getGame().getT1().getPoints() + server.getGame().getT2().getPoints() == 152)
              {
                server.getGame().getCurrentSet().result();
                server.getGame().getPacket().cut();
                int dealer = server.getGame().getPlayers().indexOf(server.getGame().getCurrentSet().getDealer());
                server.getGame().setCurrentSet(new Set(server.getGame(), server.getGame().getPlayers().get((dealer + 1) % 4)));
                server.getGame().getCurrentSet().defineStarter();
                server.getGame().getCurrentSet().firstDeal(Set.THREE_CARDS);
              }
             
              //Fin de la partie
View Full Code Here

TOP

Related Classes of belotetime.application.game.Set

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.