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 { ...@@ -50,7 +50,6 @@ public class CreationB {
switch (taille) { switch (taille) {
case 1: case 1:
if (pays[0]!=0) { if (pays[0]!=0) {
pays[0]--;
try { try {
Submarine s = new Submarine("s", co[0]); Submarine s = new Submarine("s", co[0]);
return s; return s;
...@@ -61,7 +60,6 @@ public class CreationB { ...@@ -61,7 +60,6 @@ public class CreationB {
} }
case 2: case 2:
if (pays[1]!=0) { if (pays[1]!=0) {
pays[1]--;
try { try {
Destroyer d = new Destroyer("d", co[0], co[1]); Destroyer d = new Destroyer("d", co[0], co[1]);
return d; return d;
...@@ -72,7 +70,6 @@ public class CreationB { ...@@ -72,7 +70,6 @@ public class CreationB {
} }
case 3: case 3:
if (pays[2]!=0) { if (pays[2]!=0) {
pays[2]--;
try { try {
Cruiser c = new Cruiser("c", co[0], co[1]); Cruiser c = new Cruiser("c", co[0], co[1]);
return c; return c;
...@@ -83,7 +80,6 @@ public class CreationB { ...@@ -83,7 +80,6 @@ public class CreationB {
} }
case 4: case 4:
if (pays[3]!=0) { if (pays[3]!=0) {
pays[3]--;
try { try {
Battleship b = new Battleship("b", co[0], co[1]); Battleship b = new Battleship("b", co[0], co[1]);
return b; return b;
...@@ -94,7 +90,6 @@ public class CreationB { ...@@ -94,7 +90,6 @@ public class CreationB {
} }
case 5: case 5:
if (pays[4]!=0) { if (pays[4]!=0) {
pays[4]--;
try { try {
AircraftCarrier a = new AircraftCarrier("a", co[0], co[1]); AircraftCarrier a = new AircraftCarrier("a", co[0], co[1]);
return a; return a;
......
...@@ -105,6 +105,10 @@ public abstract class Ship implements IShip { ...@@ -105,6 +105,10 @@ public abstract class Ship implements IShip {
return -1; return -1;
} }
public ShipCategory gettheCategory(){
return getCategory();
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
......
...@@ -5,6 +5,7 @@ import info1.network.Player; ...@@ -5,6 +5,7 @@ import info1.network.Player;
import info1.ships.BadCoordException; import info1.ships.BadCoordException;
import info1.ships.CoordsBadShipException; import info1.ships.CoordsBadShipException;
import info1.ships.ICoord; import info1.ships.ICoord;
import info1.ships.ShipCategory;
import modele.info1.ships.Bouttons; import modele.info1.ships.Bouttons;
import modele.info1.ships.Coord; import modele.info1.ships.Coord;
import modele.info1.ships.CreationB; import modele.info1.ships.CreationB;
...@@ -14,6 +15,7 @@ import javax.swing.*; ...@@ -14,6 +15,7 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.function.BiPredicate; import java.util.function.BiPredicate;
...@@ -100,6 +102,20 @@ public class FenetreConnexion extends JFrame { ...@@ -100,6 +102,20 @@ public class FenetreConnexion extends JFrame {
final CreationB c = new CreationB(co[0],co[1],pays); final CreationB c = new CreationB(co[0],co[1],pays);
try {if(c.TestCreation()!=null){ try {if(c.TestCreation()!=null){
if(flotte.add(c.TestCreation())==0){ 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()); System.out.println(flotte.getShips());
List<ICoord> listec = c.TestCreation().getCoords(); List<ICoord> listec = c.TestCreation().getCoords();
for(int i=0;i<100;i++){ for(int i=0;i<100;i++){
...@@ -199,6 +215,7 @@ public class FenetreConnexion extends JFrame { ...@@ -199,6 +215,7 @@ public class FenetreConnexion extends JFrame {
bouttons[i].getButton().setEnabled(true); bouttons[i].getButton().setEnabled(true);
} }
flotte = new NavyFleet(); flotte = new NavyFleet();
System.out.println(Arrays.toString(pays));
} }
}); });
...@@ -214,6 +231,7 @@ public class FenetreConnexion extends JFrame { ...@@ -214,6 +231,7 @@ public class FenetreConnexion extends JFrame {
bouttons[i].getButton().setEnabled(true); bouttons[i].getButton().setEnabled(true);
} }
flotte = new NavyFleet(); 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