summaryrefslogtreecommitdiff
path: root/src/main/java/modele/Unit.java
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2026-07-02 00:14:17 +0200
committerpolo <ordipolo@gmx.fr>2026-07-02 00:14:17 +0200
commit0c2c3ee5a55f36d270171f2f67938542e251fdc5 (patch)
tree8ea4d6a7ad09a5b1389b829980a7a5476982e754 /src/main/java/modele/Unit.java
downloadppe_javafx-0c2c3ee5a55f36d270171f2f67938542e251fdc5.tar.gz
ppe_javafx-0c2c3ee5a55f36d270171f2f67938542e251fdc5.tar.bz2
ppe_javafx-0c2c3ee5a55f36d270171f2f67938542e251fdc5.zip
fork utilisant maven
Diffstat (limited to 'src/main/java/modele/Unit.java')
-rw-r--r--src/main/java/modele/Unit.java96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/main/java/modele/Unit.java b/src/main/java/modele/Unit.java
new file mode 100644
index 0000000..11b51d9
--- /dev/null
+++ b/src/main/java/modele/Unit.java
@@ -0,0 +1,96 @@
1package modele;
2
3import java.util.ArrayList;
4import java.util.HashMap;
5
6
7
8public class Unit {
9
10 private ArrayList<Figurine> figurines;
11 private HashMap<String, ArrayList<Figurine>> identical_figs = new HashMap<String, ArrayList<Figurine>>();
12 private int id;
13 private String nom;
14 private int points;
15 private String logo;
16 private Armee armee;
17
18 public Unit(ArrayList<Figurine> figurines, String nom, int points, String logo, Armee armee) {
19 this.figurines = figurines;
20 this.makeIdenticalFigsGroups();
21 this.nom = nom;
22 this.points = points;
23 this.logo = logo;
24 this.armee = armee;
25 }
26 public Unit(ArrayList<Figurine> figurines,int id, String nom, int points,String logo, Armee armee) {
27 this.id = id;
28 this.figurines = figurines;
29 this.nom = nom;
30 this.logo = logo;
31 this.points = points;
32 this.armee = armee;
33 }
34
35 // bientôt inutile
36 public Unit(String nom_unit,ArrayList<Figurine> list_unit) {
37 this.nom = nom_unit;
38 this.figurines = list_unit;
39 }
40
41 // getters
42 public ArrayList<Figurine> getFigurines() {
43 return figurines;
44 }
45 public HashMap<String, ArrayList<Figurine>> getIdenticalFigsGroups(){
46 return identical_figs;
47 }
48
49 // est exécuté dès qu'on touche au slider
50 public int getAliveFigsOfAGroup(String group_name) {
51 int nb = 0;
52 for(Figurine fig : identical_figs.get(group_name))
53 {
54 if(fig.getHP() > 0) {
55 nb++;
56 }
57 }
58 return nb;
59 }
60
61 public int getId() {
62 return id;
63 }
64 public String getName() {
65 return nom;
66 }
67 public int getPoints() {
68 return points;
69 }
70 public String getLogo() {
71 return nom;
72 }
73 public Armee getArmee() {
74 return armee;
75 }
76
77 public void setFigurine(ArrayList<Figurine> liste) {
78 figurines = liste;
79 }
80
81 private void makeIdenticalFigsGroups() {
82 for(Figurine fig : figurines)
83 {
84 if(!identical_figs.containsKey(fig.getNom())) // si nouveau type de figurines
85 {
86 identical_figs.put(fig.getNom(), new ArrayList<Figurine>()); // création d'uné paire clé/liste dans la hashmap
87 }
88 identical_figs.get(fig.getNom()).add(fig); // récupérer la liste correspondante à la clé et ajouter la figurine
89 }
90 }
91
92 @Override
93 public String toString() {
94 return "" + nom + "";
95 }
96}