From 35f87bd62ed3d2984b2cd115ba44c0b4208ad943 Mon Sep 17 00:00:00 2001 From: Paul Gross Date: Wed, 6 May 2020 16:46:33 +0200 Subject: [PATCH] RessourceLoader --- src/database/RessourceLoader.java | 19 +++++++++++++++++-- src/database/Table.java | 10 +--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/database/RessourceLoader.java b/src/database/RessourceLoader.java index f33ad8f..7734f8c 100644 --- a/src/database/RessourceLoader.java +++ b/src/database/RessourceLoader.java @@ -8,6 +8,7 @@ import java.util.Map; import carte.Carte; import carte.CartePiochable; +import personnage.CartePersonnage; public class RessourceLoader { @@ -50,8 +51,22 @@ public class RessourceLoader { return cartesType; } - - + private static Map getMapPersonnage(Map cartes){ + + Map cartesPersonnage = new HashMap(); + + for(Integer i: cartes.keySet()) { + + Carte c = cartes.get(i); + if(cartes.get(i) instanceof CartePersonnage) { + + CartePersonnage carte = (CartePersonnage) c; + cartesPersonnage.put(i,carte); + } + } + return cartesPersonnage; + } + public static Object deserialize(byte[] data) throws IOException, ClassNotFoundException { ByteArrayInputStream in = new ByteArrayInputStream(data); ObjectInputStream is = new ObjectInputStream(in); diff --git a/src/database/Table.java b/src/database/Table.java index ce53f44..4daea77 100644 --- a/src/database/Table.java +++ b/src/database/Table.java @@ -27,10 +27,8 @@ public class Table { public void remplirTableQuery(String query) { try (Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/ShadowHunterDatabase", "shManager", "shadowhunter1234")) { //notre utilisateur que l'on utilisera (: - - System.out.println("Connected to PostgreSQL database!"); + Statement statement = connection.createStatement(); - System.out.println("Reading records..."); ResultSet retour = statement.executeQuery(query); while (retour.next()) { list.add(new Record(retour.getString("id"), retour.getString("nom"), null, retour.getBytes("objet"))); @@ -65,10 +63,4 @@ public class Table { return false; } } - - - - - - }