Package belotetime.application.game

Examples of belotetime.application.game.Game


public class TestGame
{
  @Test
  public void test()
  {
    Game game = new Game();
    assertTrue(game.getPacket().getCards().size() == 32);
   
    for(Card c : game.getPacket().getCards())
    {
      System.out.println(c.getImg());
    }
  }
View Full Code Here


{
  private Game g;
 
  public TestXmlFeeds()
  {
    g = new Game();
   
    g.getPlayers().add(new Player("Joueur 1"));
    g.getPlayers().add(new Player("Joueur 2"));
    g.getPlayers().add(new Player("Joueur 3"));
    g.getPlayers().add(new Player("Joueur 4"));
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())
View Full Code Here

        listCards.add(new Card("Valet", "Pique", 2));
        listCards.add(new Card("Dame", "Pique", 3));
        listCards.add(new Card("Roi", "Pique", 4));
        listCards.add(new Card("As", "Pique", 11));
       
        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)));
View Full Code Here

  public GameController()
  {
    super();
   
    //Mod�le
    game = new Game();
    cnt = 0;
  }
View Full Code Here

 
  public GameServer()
  {
    clients = new ArrayList<>();
    gameStarted = false;
    game = new Game();
    cnt = 0;
  }
View Full Code Here

      sendTchatMessage(user.getUser() + " : " + (String)args);
    }
    else
    {
   
      Game game = (Game)args;
     
      if(game.isStarted())
      {
      boolean online = (boolean)controller.execute("isOnline", null);
     
        if(game.getPlayers().size() < 4)
        {}
        else
        {
          start();
         
          southCards = new ArrayList<>();
          northCards = new ArrayList<>();
          eastCards = new ArrayList<>();
          westCards = new ArrayList<>();
         
          Position[] pos = new Position[3];
          pos[0] = Position.WEST;
          pos[1] = Position.NORTH;
          pos[2] = Position.EAST;
         
         
          for(Player p : game.getPlayers())
          {
            for(int i = 0; i < p.getHand().getCards().size(); i++)
            {
              if(game.getPlayers().indexOf(p) == numPlayer)
              {
                addCard(Position.SOUTH, p.getHand().getCards().get(i).getImg());
              }
              else
              {
                addCard(pos[(game.getPlayers().indexOf(p) - numPlayer + 3) % 4], "res\\cartes\\carte_inconnue.png");
              }
            }
          }
         
          southLabel.setText(game.getPlayers().get(numPlayer).getLogin());
          westLabel.setText(game.getPlayers().get((numPlayer + 1) % 4).getLogin());
          northLabel.setText(game.getPlayers().get((numPlayer + 2) % 4).getLogin());
          eastLabel.setText(game.getPlayers().get((numPlayer + 3) % 4).getLogin());
         
          Team us = (numPlayer % 2) == 0 ? game.getT1() : game.getT2();
          Team them = (numPlayer % 2) == 1 ? game.getT1() : game.getT2();
          setScore(us.getPoints());
          setGameScore(us.getGamePoints(), them.getGamePoints());
         
          //Si l'atout n'a pas encore �t� pris
          if(game.getCurrentSet().getTrump() == null || game.getCurrentSet().getTrump().equals("null"))
          {
            showTrump(game.getPacket().getCards().get(game.getPacket().getCards().size() - 1).getImg());
           
            //Si on n'est pas le joueur qui commence
            if(!game.getCurrentSet().getTaker().getLogin().equals(game.getPlayers().get(numPlayer).getLogin()))
            {
   
            }
            //C'est au tour du joueur de d�cider s'il veut prendre l'atout ou non
            else
            {
              takeButton.setDisable(false);
              passButton.setDisable(false);
           
            if (online)
            {
              sendRedTchatMessage("Vous avez 45 secondes pour d�cider de prendre l'atout ou de passer.");
            }
             
              //Si on est au deuxi�me tour
              if(game.getCurrentSet().getTurn() == 1)
              {
                Family fam = null;
                String trump = game.getPacket().getCards().get(game.getPacket().getCards().size() - 1).getColor();
               
                switch(trump)
                {
                  case "Carreau":
                    fam = Family.DIAMONDS;
                    break;
                  case "Pique":
                    fam = Family.SPADES;
                    break;
                  case "Tr�fle":
                    fam = Family.CLUBS;
                    break;
                  case "Coeur":
                    fam = Family.HEARTS;
                    break;
                  default:
                    break;
                }
               
                otherTrumps(fam);
              }
            }
          }
          //L'atout a �t� choisi
          else
          {
            if(game.getCarpet().getCards().size() == 0) resetCenter();
           
            if((game.getPlayers().get(numPlayer).hasBelote() && game.getCurrentSet().getBelotePlayed() == 0) || game.getCurrentSet().getBelotePlayed() == 1)
              beloteCheck.setDisable(false);
            else
              beloteCheck.setDisable(true);
           
            resetCenter();
           
            Position playPos[] = new Position[4];
            playPos[numPlayer] = Position.SOUTH;
            playPos[(numPlayer+1)%4] = Position.WEST;
            playPos[(numPlayer+2)%4] = Position.NORTH;
            playPos[(numPlayer+3)%4] = Position.EAST;
           
            String starterLogin = game.getCurrentSet().getStarter().getLogin();
            int starter = 0;
            for(Player p : game.getPlayers()){
              if(p.getLogin().equals(starterLogin))
                break;
              starter++;
            }
           
            for(Card c : game.getCarpet().getCards())
            {
              playCard(playPos[(starter - game.getCarpet().getCards().size() + 4)%4], new Image(c.getImg()));
              starter++;
            }
           
            if(game.getPacket().getCards().size() > 0)
            {
              Pack packet = game.getPacket();
              setFold(new ImageView(new Image(packet.getCards().get(packet.getCards().size() - 4).getImg())),
                  new ImageView(new Image(packet.getCards().get(packet.getCards().size() - 3).getImg())),
                  new ImageView(new Image(packet.getCards().get(packet.getCards().size() - 2).getImg())),
                  new ImageView(new Image(packet.getCards().get(packet.getCards().size() - 1).getImg())));
            }
           
            setTrump(game.getCurrentSet().getTrump());
          }
        }
      }
      else
      {
        sendRedTchatMessage("Partie termin�e");
        Team us = (numPlayer % 2) == 0 ? game.getT1() : game.getT2();
        Team them = (numPlayer % 2) == 1 ? game.getT1() : game.getT2();
        setScore(us.getPoints());
        setGameScore(us.getGamePoints(), them.getGamePoints());
        resetCenter();
      }
    }
View Full Code Here

      sendTchatMessage((String)args);
    }
    else
    {
   
      Game game = (Game)args;
     
      if(game.isStarted())
      {
      boolean online = (boolean)controller.execute("isOnline", null);
     
        if(game.getPlayers().size() < 4)
        {}
        else
        {
          start();
         
          southCards = new ArrayList<>();
          northCards = new ArrayList<>();
          eastCards = new ArrayList<>();
          westCards = new ArrayList<>();
         
          Position[] pos = new Position[3];
          pos[0] = Position.WEST;
          pos[1] = Position.NORTH;
          pos[2] = Position.EAST;
         
         
          for(Player p : game.getPlayers())
          {
            for(int i = 0; i < p.getHand().getCards().size(); i++)
            {
              if(game.getPlayers().indexOf(p) == numPlayer)
              {
                addCard(Position.SOUTH, p.getHand().getCards().get(i).getImg());
              }
              else
              {
                addCard(pos[(game.getPlayers().indexOf(p) - numPlayer + 3) % 4], "res\\cartes\\carte_inconnue.png");
              }
            }
          }
         
          Team us = (numPlayer % 2) == 0 ? game.getT1() : game.getT2();
          Team them = (numPlayer % 2) == 1 ? game.getT1() : game.getT2();
          setScore(us.getPoints());
          setGameScore(us.getGamePoints(), them.getGamePoints());
         
          //Si l'atout n'a pas encore �t� pris
          if(game.getCurrentSet().getTrump() == null || game.getCurrentSet().getTrump().equals("null"))
          {
            showTrump(game.getPacket().getCards().get(game.getPacket().getCards().size() - 1).getImg());
           
            //Si on n'est pas le joueur qui commence
            if(!game.getCurrentSet().getTaker().getLogin().equals(game.getPlayers().get(numPlayer).getLogin()))
            {
   
            }
            //C'est au tour du joueur de d�cider s'il veut prendre l'atout ou non
            else
            {
              takeButton.setDisable(false);
              passButton.setDisable(false);
           
            if (online)
            {
              sendRedTchatMessage("Vous avez 45 secondes pour d�cider de prendre l'atout ou de passer.");
            }
             
              //Si on est au deuxi�me tour
              if(game.getCurrentSet().getTurn() == 1)
              {
                Family fam = null;
                String trump = game.getPacket().getCards().get(game.getPacket().getCards().size() - 1).getColor();
               
                switch(trump)
                {
                  case "Carreau":
                    fam = Family.DIAMONDS;
                    break;
                  case "Pique":
                    fam = Family.SPADES;
                    break;
                  case "Tr�fle":
                    fam = Family.CLUBS;
                    break;
                  case "Coeur":
                    fam = Family.HEARTS;
                    break;
                  default:
                    break;
                }
               
                otherTrumps(fam);
              }
            }
          }
          //L'atout a �t� choisi
          else
          {
            if(game.getCarpet().getCards().size() == 0) resetCenter();
           
            if((game.getPlayers().get(numPlayer).hasBelote() && game.getCurrentSet().getBelotePlayed() == 0) || game.getCurrentSet().getBelotePlayed() == 1)
              beloteCheck.setDisable(false);
            else
              beloteCheck.setDisable(true);
           
            resetCenter();
           
            Position playPos[] = new Position[4];
            playPos[numPlayer] = Position.SOUTH;
            playPos[(numPlayer+1)%4] = Position.WEST;
            playPos[(numPlayer+2)%4] = Position.NORTH;
            playPos[(numPlayer+3)%4] = Position.EAST;
           
            String starterLogin = game.getCurrentSet().getStarter().getLogin();
            int starter = 0;
            for(Player p : game.getPlayers()){
              if(p.getLogin().equals(starterLogin))
                break;
              starter++;
            }
           
            for(Card c : game.getCarpet().getCards())
            {
              playCard(playPos[(starter - game.getCarpet().getCards().size() + 4)%4], new Image(c.getImg()));
              starter++;
            }
           
            if(game.getPacket().getCards().size() > 0)
            {
              Pack packet = game.getPacket();
              setFold(new ImageView(new Image(packet.getCards().get(packet.getCards().size() - 4).getImg())),
                  new ImageView(new Image(packet.getCards().get(packet.getCards().size() - 3).getImg())),
                  new ImageView(new Image(packet.getCards().get(packet.getCards().size() - 2).getImg())),
                  new ImageView(new Image(packet.getCards().get(packet.getCards().size() - 1).getImg())));
            }
           
            setTrump(game.getCurrentSet().getTrump());
          }
        }
      }
      else
      {
        sendRedTchatMessage("Partie termin�e");
        Team us = (numPlayer % 2) == 0 ? game.getT1() : game.getT2();
        Team them = (numPlayer % 2) == 1 ? game.getT1() : game.getT2();
        //Team winner = us.getGamePoints() > them.getGamePoints() ? us : them;
        //winner.getGamePoints(); //Les points du vainqueur
        //controller.execute("addNbPoints", new Object[] {winner.getP1().getLogin(), winner.getGamePoints()});
        //controller.execute("addNbPoints", new Object[] {winner.getP2().getLogin(), winner.getGamePoints()});
        setScore(us.getPoints());
View Full Code Here

  }
 
  @Override
  public void update(Object args)
  {
    Game game = (Game)args;
   
    if(game.getT2().getP1().getLogin().equals(""))
    {
      posWest.setDisable(false);
      posWest.setText("Rejoindre");
    }
    else
    {
      posWest.setText(game.getT2().getP1().getLogin());
    }
   
    if(game.getT1().getP2().getLogin().equals(""))
    {
      posNorth.setDisable(false);
      posNorth.setText("Rejoindre");
    }
    else
    {
      posNorth.setText(game.getT1().getP2().getLogin());
    }
   
    if(game.getT2().getP2().getLogin().equals(""))
    {
      posEast.setDisable(false);
      posEast.setText("Rejoindre");
    }
    else
    {
      posEast.setText(game.getT2().getP2().getLogin());
    }
  }
View Full Code Here

TOP

Related Classes of belotetime.application.game.Game

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.