Commit 0fbf3239 authored by Tristan MAISONNEUVE's avatar Tristan MAISONNEUVE
Browse files

Fennetre modif compo equip

parent 09604764
......@@ -50,7 +50,6 @@ public class CreationB {
switch (taille) {
case 1:
if (pays[0]!=0) {
pays[0]--;
try {
Submarine s = new Submarine("s", co[0]);
return s;
......@@ -61,7 +60,6 @@ public class CreationB {
}
case 2:
if (pays[1]!=0) {
pays[1]--;
try {
Destroyer d = new Destroyer("d", co[0], co[1]);
return d;
......@@ -72,7 +70,6 @@ public class CreationB {
}
case 3:
if (pays[2]!=0) {
pays[2]--;
try {
Cruiser c = new Cruiser("c", co[0], co[1]);
return c;
......@@ -83,7 +80,6 @@ public class CreationB {
}
case 4:
if (pays[3]!=0) {
pays[3]--;
try {
Battleship b = new Battleship("b", co[0], co[1]);
return b;
......@@ -94,7 +90,6 @@ public class CreationB {
}
case 5:
if (pays[4]!=0) {
pays[4]--;
try {
AircraftCarrier a = new AircraftCarrier("a", co[0], co[1]);
return a;
......
......@@ -105,6 +105,10 @@ public abstract class Ship implements IShip {
return -1;
}
public ShipCategory gettheCategory(){
return getCategory();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
......
......@@ -5,6 +5,7 @@ import info1.network.Player;
import info1.ships.BadCoordException;
import info1.ships.CoordsBadShipException;
import info1.ships.ICoord;
import info1.ships.ShipCategory;
import modele.info1.ships.Bouttons;
import modele.info1.ships.Coord;
import modele.info1.ships.CreationB;
......@@ -14,6 +15,7 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiPredicate;
......@@ -100,6 +102,20 @@ public class FenetreConnexion extends JFrame {
final CreationB c = new CreationB(co[0],co[1],pays);
try {if(c.TestCreation()!=null){
if(flotte.add(c.TestCreation())==0){
c.TestCreation().gettheCategory();
ShipCategory s = c.TestCreation().gettheCategory();
if(s==ShipCategory.SUBMARINE){
pays[0]--;
} if (s==ShipCategory.DESTROYER) {
pays[1]--;
} if (s==ShipCategory.CRUISER) {
pays[2]--;
} if (s==ShipCategory.BATTLESHIP) {
pays[3]--;
} if (s==ShipCategory.AIRCRAFT_CARRIER) {
pays[4]--;
}
System.out.println(Arrays.toString(pays));
System.out.println(flotte.getShips());
List<ICoord> listec = c.TestCreation().getCoords();
for(int i=0;i<100;i++){
......@@ -199,6 +215,7 @@ public class FenetreConnexion extends JFrame {
bouttons[i].getButton().setEnabled(true);
}
flotte = new NavyFleet();
System.out.println(Arrays.toString(pays));
}
});
......@@ -214,6 +231,7 @@ public class FenetreConnexion extends JFrame {
bouttons[i].getButton().setEnabled(true);
}
flotte = new NavyFleet();
System.out.println(Arrays.toString(pays));
}
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment