예제 #1
0
 // TODO add test methods here.
 // The methods must be annotated with annotation @Test. For example:
 //
 @Test
 public void poseidonFire() throws Exception {
   bn.addShip(TypeShip.BARQUE, new Coordinate(0, 0), new Coordinate(0, 4));
   bn.switchTurn();
   TypeShip[] bateaux = {BARQUE, BARQUE, BARQUE};
   ((Bot) bn.getJ2()).placerBateaux(bateaux);
   bn.fire(OrdreTir.NO_ORDER);
   bn.fire(OrdreTir.NO_ORDER);
   bn.fire(OrdreTir.NO_ORDER);
   bn.fire(OrdreTir.NO_ORDER);
   //        bn.fire(OrdreTir.NO_ORDER);
   assertEquals(bn.getJ1().getFlotte().getVaisseaux().get(0).getLife(), 1);
 }
예제 #2
0
 @Test
 public void poseidonFire2() throws Exception {
   bn.addShip(TypeShip.BARQUE, new Coordinate(0, 0), new Coordinate(0, 4));
   bn.switchTurn();
   TypeShip[] bateaux = {BARQUE, BARQUE, BARQUE};
   ((Bot) bn.getJ2()).placerBateaux(bateaux);
   bn.fire(OrdreTir.NO_ORDER);
   bn.fire(OrdreTir.NO_ORDER);
   bn.fire(OrdreTir.NO_ORDER);
   bn.fire(OrdreTir.NO_ORDER);
   StateCase state = bn.fire(OrdreTir.NO_ORDER);
   assertEquals(FLOTTE_DETRUITE, state);
 }
예제 #3
0
  public JPanelAcceuil(final BatailleNavale model, final JPanelWizard wizard) {
    super(new BorderLayout());
    //        SpringLayout sl = new SpringLayout();
    JPanel buttons = new JPanel(new GridLayout(3, 1) /*sl*/);
    //        buttons.setLayout(new BoxLayout(buttons, BoxLayout.Y_AXIS));
    model.addObserver(this);
    // buttons.setBorder(BorderFactory.createEmptyBorder(100,100,100,100));
    JButton creerPartie = new JButton("Créer Partie");
    //        creerPartie.setOpaque(false);
    creerPartie.addActionListener(new MoveToPanelListener(model, wizard, JPanelCreer.id));
    buttons.add(creerPartie);
    //        sl.putConstraint(SpringLayout.NORTH, creerPartie, 50, SpringLayout.NORTH, buttons);

    JButton chargerPartie = new JButton("Charger Partie");
    chargerPartie.addActionListener(new MoveToPanelListener(model, wizard, JPanelParties.id));
    buttons.add(chargerPartie);

    JButton voirScore = new JButton("Voir scores");
    voirScore.addActionListener(new MoveToPanelListener(model, wizard, JPanelScore.id));
    buttons.add(voirScore);

    buttons.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.GRAY),
            "Bienvenue",
            TitledBorder.LEFT,
            TitledBorder.TOP,
            new Font(Font.SERIF, Font.ITALIC, 16),
            Color.GRAY));

    //        setSize(new Dimension(100,100));
    //        buttons.setMaximumSize(new Dimension(20,20));
    add(buttons, BorderLayout.CENTER);
    //        SpringUtilities.makeCompactGrid(buttons, 1,
    //                                buttons.getComponentCount(),
    //                                6, 6, 6, 6);

    //        SpringUtilities.makeCompactGrid(buttons,
    //                                1,3, //rows, cols
    //                                50, 50,        //initX, initY
    //                                6, 6);       //xPad, yPad

  }
예제 #4
0
  @Before
  public void setUp() {

    try {
      bn = new BatailleNavale();
      bn.setDifficulty(Difficulty.POSEIDON);
      bn.setPseudoHumun("testingPoseidon");
      bn.setLongeurGrille(5);
      bn.setLargeurGrille(5);
      bn.constructPlayers();
      bn.newGame();

    } catch (DaoFactoryException ex) {
      Logger.getLogger(TestPoseidon.class.getName()).log(Level.SEVERE, null, ex);
    } catch (Exception ex) {
      Logger.getLogger(TestPoseidon.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
예제 #5
0
 @Test
 public void poseidonFire3() throws Exception {
   bn.addShip(TypeShip.BARQUE, new Coordinate(0, 0), new Coordinate(0, 4));
   bn.addShip(TypeShip.TRANSPORT, new Coordinate(1, 0), new Coordinate(1, 1));
   bn.switchTurn();
   TypeShip[] bateaux = {BARQUE, TRANSPORT};
   ((Bot) bn.getJ2()).placerBateaux(bateaux);
   int i = 0;
   //        int j = 0;
   StateCase s;
   while (i < 5) {
     s = bn.fire(OrdreTir.NO_ORDER);
     if (s == HIT) {
       i++;
     }
   }
   //        bn.fire(OrdreTir.NO_ORDER);
   //        bn.fire(OrdreTir.NO_ORDER);
   //        bn.fire(OrdreTir.NO_ORDER);
   //        bn.fire(OrdreTir.NO_ORDER);
   assertEquals(bn.getJ1().getFlotte().getVaisseaux().size(), 1);
 }