Przeglądaj źródła

Debug affichage explosion en chaine + documentation

Loquicom 6 lat temu
rodzic
commit
751c09226f

+ 1 - 2
README.md

@@ -64,5 +64,4 @@ Le client utilise 3 Threads, le thread principal qui lance le jeu, le thread d'a
 
 - Rarement lors du ramassage d'un objet le client crash
 - Lors d'un game over suite à la pression d'une touche pour revenir dans le menu l'ecran de jeu se reaffiche, il est necessaire de bouger dans le menu (Z/S) pour actualiser l'affichage et voir le menu.
-- Lorsque l'on selectionne rejoindre alors qu'il n'exsite aucune partie l'ecran devient blanc, il est necessaire de bouger dans le menu (Z/S) pour actualiser l'affichage et revoir le menu.
-- Lors d'une explosion en chaine de bombe il reste parfois quelques cases qui garde le sprite de l'explosion, il suffir de marcher dessus pour les faires redevenir normal
+- Lorsque l'on selectionne rejoindre alors qu'il n'exsite aucune partie l'ecran devient blanc, il est necessaire de bouger dans le menu (Z/S) pour actualiser l'affichage et revoir le menu.

BIN
client/Client.jar


+ 1 - 7
client/src/bs/Create.java

@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bs;
 
 import bswfx.BomberStudent;
@@ -13,8 +8,7 @@ import org.json.JSONArray;
 import org.json.JSONObject;
 
 /**
- *
- * @author loquicom
+ * Gestion du menu de création de partie
  */
 public class Create {
 

+ 94 - 9
client/src/bs/Game.java

@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bs;
 
 import bswfx.BomberStudent;
@@ -13,17 +8,35 @@ import org.json.JSONObject;
 import wfx.WebFx;
 
 /**
- *
- * @author loquicom
+ * Gestion des parties
  */
 public class Game {
 
+    /**
+     * Liste des joueurs avec comme clef leur id
+     */
     protected HashMap<Integer, Player> player = new HashMap<>();
+    /**
+     * L'id du joueur principale
+     */
     protected int mainPlayer;
+    /**
+     * Largeur de la map
+     */
     protected int width;
+    /**
+     * Hauteur de la map
+     */
     protected int height;
+    /**
+     * La map
+     */
     protected String map[][];
 
+    /**
+     * Création d'une partie à partir du JSON du serveur
+     * @param jo Le JSON du serveur
+     */
     public Game(JSONObject jo) {
         //Recup la map
         JSONObject joMap = jo.getJSONObject("map");
@@ -52,12 +65,23 @@ public class Game {
     }
 
     /* --- Méthodes jeu --- */
+    /**
+     * Ajoute un joueur dans la partie
+     * @param id Id du joueur
+     * @param pos Position du joueur
+     */
     public void join(int id, String pos) {
         Player p = new Player(id, pos);
         this.player.put(id, p);
         this.map[p.getX()][p.getY()] = "" + id;
     }
 
+    /**
+     * Déplace un joueur
+     * @param player Id du joueur
+     * @param dir La direction du déplacement
+     * @return Reussite
+     */
     public boolean move(int player, int dir) {
         //Recup le joueur
         Player p = this.player.get(player);
@@ -136,7 +160,13 @@ public class Game {
         p.setY(y);
         return true;
     }
-
+    
+    /**
+     * Ajoute uene bombe sur le terrain
+     * @param type Le type de la bombe
+     * @param coord Coordonnées de la bombe
+     * @return Reussite
+     */
     public boolean newBomb(int type, String coord) {
         //Recup la position
         int pos[] = this.parseCoord(coord);
@@ -157,6 +187,10 @@ public class Game {
         return true;
     }
 
+    /**
+     * Retire une bombe du terrain
+     * @param coord Position de la bombe
+     */
     public void removeBomb(String coord) {
         int pos[] = this.parseCoord(coord);
         if (this.map[pos[0]][pos[1]].equals("b") || this.map[pos[0]][pos[1]].equals("m") || this.map[pos[0]][pos[1]].equals("r")) {
@@ -164,6 +198,12 @@ public class Game {
         }
     }
 
+    /**
+     * Ajoute un objet sur le terrain
+     * @param type Le type de l'objet
+     * @param coord La position de l'objet
+     * @return Reussite
+     */
     public boolean newObject(int type, String coord) {
         //Recup la position
         int pos[] = this.parseCoord(coord);
@@ -208,6 +248,11 @@ public class Game {
         return true;
     }
 
+    /**
+     * Récupération d'un objet sur le terrain
+     * @param type Le type de l'objet
+     * @return Reussite
+     */
     public boolean getObject(int type) {
         JSONObject param = new JSONObject();
         //Creation json en fonction type
@@ -286,6 +331,10 @@ public class Game {
         return true;
     }
 
+    /**
+     * Met à jour la carte
+     * @param mapContent La carte en une ligne
+     */
     public void updateMap(String mapContent) {
         String map[][] = this.parseMap(mapContent);
         //Compare les 2 cartes
@@ -298,6 +347,10 @@ public class Game {
         }
     }
 
+    /**
+     * Met à jour la vie
+     * @param newLife La nouvelle valeur
+     */
     public void updateLife(int newLife) {
         Player p = this.player.get(this.mainPlayer);
         //Si non invincible
@@ -310,6 +363,11 @@ public class Game {
         }
     }
 
+    /**
+     * Quitte une partie
+     * @param id Id du joueur qui quitte
+     * @return Reussite
+     */
     public boolean quit(int id) {
         //Recup joueur
         Player p = this.player.get(id);
@@ -322,6 +380,9 @@ public class Game {
         return true;
     }
     
+    /**
+     * Ecran de game over
+     */
     public void gameOver(){
         //Quitte la partie
         BomberStudent.bsc.send("POST", "game/quit");
@@ -334,6 +395,10 @@ public class Game {
         BomberStudent.menu.show();
     }
     
+    /**
+     * Affiche les explosions des bombes
+     * @param explo JSON avec les coordonnées des explosions
+     */
     public void explosion(JSONArray explo){
         int x, y;
         JSONObject pos;
@@ -360,10 +425,13 @@ public class Game {
         t.start();
     }
     
+    /**
+     * Supprime les explosions du terrain
+     */
     public void removeExplosion(){
         for (int i = 0; i < height; i++) {
             for (int j = 0; j < width; j++) {
-                if(this.map[j][i].charAt(0) == 'e'){
+                while(this.map[j][i].charAt(0) == 'e'){
                     this.map[j][i] = this.map[j][i].substring(1);
                 }
             }
@@ -371,6 +439,10 @@ public class Game {
     }
 
     /* --- Méthodes affichage --- */
+    /**
+     * Genere l'HTML pour l'affichage
+     * @return 
+     */
     public String toHtml() {
         Player pl = this.player.get(this.mainPlayer);
         String html = "<!DOCTYPE html><html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"file:" + System.getProperty("user.dir") + "/file/css/map.css\"></head><body><div id=\"game\">";
@@ -508,6 +580,9 @@ public class Game {
         return html;
     }
 
+    /**
+     * Affiche la map dans le terminal
+     */
     public void showMap() {
         for (int i = 0; i < height; i++) {
             for (int j = 0; j < width; j++) {
@@ -535,6 +610,11 @@ public class Game {
     }
 
     /* --- Methodes privée --- */
+    /**
+     * Parse la map 1D en 2D
+     * @param mapContent
+     * @return 
+     */
     private String[][] parseMap(String mapContent) {
         String[][] map = new String[this.width][this.height];
         for (int i = 0; i < this.height; i++) {
@@ -545,6 +625,11 @@ public class Game {
         return map;
     }
 
+    /**
+     * Parse les coordonnées
+     * @param coord Coordonnées
+     * @return 0 => X, 1 => Y
+     */
     private int[] parseCoord(String coord) {
         int res[] = new int[2];
         //Cherche le separateur

+ 1 - 7
client/src/bs/Join.java

@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bs;
 
 import bswfx.ScreenManager;
@@ -11,8 +6,7 @@ import bswfx.BomberStudent;
 import org.json.JSONObject;
 
 /**
- *
- * @author loquicom
+ * Gestion du menu pour rejoindre une partie
  */
 public class Join {
 

+ 1 - 7
client/src/bs/Menu.java

@@ -1,16 +1,10 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bs;
 
 import bswfx.BomberStudent;
 import bswfx.ScreenManager;
 
 /**
- *
- * @author loquicom
+ * Gestion du menu principale
  */
 public class Menu {
     

+ 26 - 9
client/src/bs/Player.java

@@ -1,16 +1,10 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bs;
 
 import bswfx.BomberStudent;
 import org.json.JSONObject;
 
 /**
- *
- * @author loquicom
+ * Gestion joueur
  */
 public class Player {
     
@@ -48,6 +42,11 @@ public class Player {
     protected int firepower;
     protected boolean major;
     
+    /**
+     * Création d'un joueur non principal (sur un autre client)
+     * @param id L'id du joueur
+     * @param pos La position de départ
+     */
     public Player(int id, String pos){
         int coord[] = parseCoord(pos);
         //SetUp les valeurs
@@ -58,6 +57,11 @@ public class Player {
         this.y = coord[1];
     }
     
+    /**
+     * Création d'un joueur principal (sur ce client)
+     * @param jo JSON décrivant le joueur
+     * @param pos La position de départ
+     */
     public Player(JSONObject jo, String pos){
         int coord[] = parseCoord(pos);
         //SetUp les valeurs
@@ -78,7 +82,11 @@ public class Player {
     }
     
     /* --- Méthodes --- */
-    
+    /**
+     * Déplace le joueur sur le serveur
+     * @param dir La direction
+     * @return Reussite
+     */
     public boolean move(int dir){
         JSONObject jo = new JSONObject();
         switch(dir){
@@ -99,6 +107,11 @@ public class Player {
         }
     }
     
+    /**
+     * Pose une bombe
+     * @param type Le type de la bombe
+     * @return Reussite
+     */
     public boolean attack(int type){
         JSONObject jo = new JSONObject();
         //Calcul position
@@ -279,7 +292,11 @@ public class Player {
     }
     
     /* --- Methodes privées --- */
-    
+    /**
+     * Parse les coordonnées
+     * @param coord Coordonnées
+     * @return 0 => X, 1 => Y
+     */
     private int[] parseCoord(String coord){
         int res[] = new int[2];
         //Cherche le separateur

+ 20 - 11
client/src/bswfx/BomberStudent.java

@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bswfx;
 
 import bs.Create;
@@ -15,21 +10,35 @@ import rsx.BomberStudentClient;
 import wfx.WebFx;
 
 /**
- *
- * @author Loquicom <contact@loquicom.fr>
+ * Class principal
  */
 public class BomberStudent {
     
+    /**
+     * Affichage
+     */
     public static WebFx wfx = new WebFx();
+    /**
+     * Connexion avec le serveur
+     */
     public static BomberStudentClient bsc = new BomberStudentClient();
-    public static Game game;  
+    /**
+     * La partie actuelle
+     */
+    public static Game game;
+    /**
+     * Le menu principale
+     */
     public static Menu menu;
+    /**
+     * Le menu de création de partie
+     */
     public static Create create;
-    public static Join join;
-
     /**
-     * @param args the command line arguments
+     * Le menu pour rejoindre une partie
      */
+    public static Join join;
+
     public static void main(String[] args) {
         //Change passage de ligne du systeme
         System.setProperty("line.separator", "\n");

+ 21 - 7
client/src/bswfx/KeyHandler.java

@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bswfx;
 
 import bs.Create;
@@ -13,11 +8,14 @@ import javafx.scene.input.KeyEvent;
 import wfx.WebFx;
 
 /**
- *
- * @author Loquicom <contact@loquicom.fr>
+ * Gestion des entrées claviers
  */
 public class KeyHandler {
 
+    /**
+     * Repartition en fonction de l'ecran afficher
+     * @param ke L'event KeyPressed
+     */
     public static void manage(KeyEvent ke) {
         switch (ScreenManager.getScreen()) {
             case ScreenManager.GAME_SCREEN:
@@ -37,6 +35,10 @@ public class KeyHandler {
         }
     }
 
+    /**
+     * Gestion des touches pour la partie
+     * @param ke L'event KeyPressed
+     */
     protected static void gameEvent(KeyEvent ke) {
         //Recup le joueur principale
         Player p = BomberStudent.game.getPlayer(BomberStudent.game.getMainPlayerId());
@@ -89,6 +91,10 @@ public class KeyHandler {
         }
     }
 
+    /**
+     * Gestion des touches pour le menu principale
+     * @param ke L'event KeyPressed
+     */
     protected static void menuEvent(KeyEvent ke) {
         switch (ke.getCode()) {
             case Z:
@@ -117,6 +123,10 @@ public class KeyHandler {
         }
     }
 
+    /**
+     * Gestion des touches pour la création de partie
+     * @param ke L'event KeyPressed
+     */
     public static void createEvent(KeyEvent ke) {
         if (BomberStudent.create.getMode() == Create.NAME_MODE) {
             switch (ke.getCode()) {
@@ -146,6 +156,10 @@ public class KeyHandler {
         }
     }
 
+    /**
+     * Gestion de touche pour rejoindre une partie
+     * @param ke L'event KeyPressed
+     */
     public static void joinEvent(KeyEvent ke) {
         switch (ke.getCode()) {
             case Z:

+ 1 - 7
client/src/bswfx/ScreenManager.java

@@ -1,13 +1,7 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bswfx;
 
 /**
- *
- * @author loquicom
+ * Gestion de l'ecran actuellement affiché
  */
 public class ScreenManager {
     

+ 2 - 7
client/src/bswfx/handler/HandlerAttackAffect.java

@@ -1,8 +1,4 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
+
 package bswfx.handler;
 
 import org.json.JSONObject;
@@ -10,8 +6,7 @@ import rsx.BomberStudentHandler;
 import bswfx.BomberStudent;
 
 /**
- *
- * @author loquicom
+ * Handler attack/affect
  */
 public class HandlerAttackAffect implements BomberStudentHandler{
 

+ 1 - 7
client/src/bswfx/handler/HandlerAttackBomb.java

@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bswfx.handler;
 
 import bs.Player;
@@ -11,8 +6,7 @@ import rsx.BomberStudentHandler;
 import bswfx.BomberStudent;
 
 /**
- *
- * @author loquicom
+ * Handler attack/newbomb
  */
 public class HandlerAttackBomb implements BomberStudentHandler{
 

+ 1 - 7
client/src/bswfx/handler/HandlerAttackExplose.java

@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bswfx.handler;
 
 import bs.Player;
@@ -12,8 +7,7 @@ import bswfx.BomberStudent;
 import org.json.JSONArray;
 
 /**
- *
- * @author loquicom
+ * Handler attack/explose
  */
 public class HandlerAttackExplose implements BomberStudentHandler {
 

+ 1 - 7
client/src/bswfx/handler/HandlerMajorEnd.java

@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bswfx.handler;
 
 import bs.Player;
@@ -11,8 +6,7 @@ import rsx.BomberStudentHandler;
 import bswfx.BomberStudent;
 
 /**
- *
- * @author loquicom
+ * Handler player/major/end
  */
 public class HandlerMajorEnd implements BomberStudentHandler{
 

+ 1 - 7
client/src/bswfx/handler/HandlerPlayerJoin.java

@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bswfx.handler;
 
 import org.json.JSONObject;
@@ -10,8 +5,7 @@ import rsx.BomberStudentHandler;
 import bswfx.BomberStudent;
 
 /**
- *
- * @author loquicom
+ * Handler game/newplayer
  */
 public class HandlerPlayerJoin implements BomberStudentHandler{
 

+ 1 - 7
client/src/bswfx/handler/HandlerPlayerMove.java

@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bswfx.handler;
 
 import bs.Player;
@@ -11,8 +6,7 @@ import rsx.BomberStudentHandler;
 import bswfx.BomberStudent;
 
 /**
- *
- * @author loquicom
+ * Handler player/position/update
  */
 public class HandlerPlayerMove implements BomberStudentHandler{
 

+ 1 - 7
client/src/bswfx/handler/HandlerPlayerQuit.java

@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bswfx.handler;
 
 import org.json.JSONObject;
@@ -10,8 +5,7 @@ import rsx.BomberStudentHandler;
 import bswfx.BomberStudent;
 
 /**
- *
- * @author loquicom
+ * Handler game/quit
  */
 public class HandlerPlayerQuit implements BomberStudentHandler{
 

+ 1 - 7
client/src/bswfx/handler/HandlerServerEnd.java

@@ -1,8 +1,3 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package bswfx.handler;
 
 import org.json.JSONObject;
@@ -10,8 +5,7 @@ import rsx.BomberStudentHandler;
 import bswfx.BomberStudent;
 
 /**
- *
- * @author loquicom
+ * Handler server/end
  */
 public class HandlerServerEnd implements BomberStudentHandler{