Mise a jour des test et contrainte de poids
Clement Colmerauer

Clement Colmerauer commited on 2024-12-13 11:51:03
Showing 29 changed files, with 142 additions and 79 deletions.

... ...
@@ -41,7 +41,7 @@
41 41
 </td>
42 42
 <td>
43 43
 <div class="infoBox" id="duration">
44
-<div class="counter">0.221s</div>
44
+<div class="counter">0.163s</div>
45 45
 <p>duration</p>
46 46
 </div>
47 47
 </td>
... ...
@@ -76,7 +76,7 @@
76 76
 </thead>
77 77
 <tr>
78 78
 <td class="success">testAffichageBase()</td>
79
-<td class="success">0.221s</td>
79
+<td class="success">0.163s</td>
80 80
 <td class="success">passed</td>
81 81
 </tr>
82 82
 </table>
... ...
@@ -89,7 +89,7 @@
89 89
 <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
90 90
 </label>
91 91
 </div>Generated by 
92
-<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 09:16:49</p>
92
+<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 11:48:15</p>
93 93
 </div>
94 94
 </div>
95 95
 </body>
... ...
@@ -23,7 +23,7 @@
23 23
 <tr>
24 24
 <td>
25 25
 <div class="infoBox" id="tests">
26
-<div class="counter">10</div>
26
+<div class="counter">12</div>
27 27
 <p>tests</p>
28 28
 </div>
29 29
 </td>
... ...
@@ -82,21 +82,39 @@
82 82
 <td class="success">passed</td>
83 83
 </tr>
84 84
 <tr>
85
+<td class="success">Item and player</td>
86
+<td class="success">testBuySell()</td>
87
+<td class="success">0.002s</td>
88
+<td class="success">passed</td>
89
+</tr>
90
+<tr>
85 91
 <td class="success">Heal and hurt</td>
86 92
 <td class="success">testHealAndHurt()</td>
87
-<td class="success">0.002s</td>
93
+<td class="success">0.001s</td>
94
+<td class="success">passed</td>
95
+</tr>
96
+<tr>
97
+<td class="success">Item tests</td>
98
+<td class="success">testItem()</td>
99
+<td class="success">0.010s</td>
88 100
 <td class="success">passed</td>
89 101
 </tr>
90 102
 <tr>
91 103
 <td class="success">Main</td>
92 104
 <td class="success">testMain()</td>
93
-<td class="success">0.008s</td>
105
+<td class="success">0.002s</td>
94 106
 <td class="success">passed</td>
95 107
 </tr>
96 108
 <tr>
97 109
 <td class="success">majDeFinDeTour</td>
98 110
 <td class="success">testMajFinTour()</td>
99
-<td class="success">0.004s</td>
111
+<td class="success">0.003s</td>
112
+<td class="success">passed</td>
113
+</tr>
114
+<tr>
115
+<td class="success">Construcor Manager</td>
116
+<td class="success">testManager()</td>
117
+<td class="success">0.001s</td>
100 118
 <td class="success">passed</td>
101 119
 </tr>
102 120
 <tr>
... ...
@@ -108,7 +126,7 @@
108 126
 <tr>
109 127
 <td class="success">Constructor Player</td>
110 128
 <td class="success">testPlayerConstructor()</td>
111
-<td class="success">0.002s</td>
129
+<td class="success">0.001s</td>
112 130
 <td class="success">passed</td>
113 131
 </tr>
114 132
 <tr>
... ...
@@ -120,19 +138,13 @@
120 138
 <tr>
121 139
 <td class="success">removeMoney</td>
122 140
 <td class="success">testRemoveMoney()</td>
123
-<td class="success">0.009s</td>
141
+<td class="success">0.008s</td>
124 142
 <td class="success">passed</td>
125 143
 </tr>
126 144
 <tr>
127 145
 <td class="success">ex &amp; lvl</td>
128 146
 <td class="success">testRetrieveLevel()</td>
129
-<td class="success">0.005s</td>
130
-<td class="success">passed</td>
131
-</tr>
132
-<tr>
133
-<td class="success">Construcor UpdatePlayer</td>
134
-<td class="success">testUpdatePlayer()</td>
135
-<td class="success">0.001s</td>
147
+<td class="success">0.003s</td>
136 148
 <td class="success">passed</td>
137 149
 </tr>
138 150
 </table>
... ...
@@ -145,7 +157,7 @@
145 157
 <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
146 158
 </label>
147 159
 </div>Generated by 
148
-<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 09:16:49</p>
160
+<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 11:48:15</p>
149 161
 </div>
150 162
 </div>
151 163
 </body>
... ...
@@ -20,7 +20,7 @@
20 20
 <tr>
21 21
 <td>
22 22
 <div class="infoBox" id="tests">
23
-<div class="counter">11</div>
23
+<div class="counter">13</div>
24 24
 <p>tests</p>
25 25
 </div>
26 26
 </td>
... ...
@@ -38,7 +38,7 @@
38 38
 </td>
39 39
 <td>
40 40
 <div class="infoBox" id="duration">
41
-<div class="counter">0.258s</div>
41
+<div class="counter">0.200s</div>
42 42
 <p>duration</p>
43 43
 </div>
44 44
 </td>
... ...
@@ -82,10 +82,10 @@
82 82
 <td class="success">
83 83
 <a href="packages/re.forestier.edu.html">re.forestier.edu</a>
84 84
 </td>
85
-<td>11</td>
85
+<td>13</td>
86 86
 <td>0</td>
87 87
 <td>0</td>
88
-<td>0.258s</td>
88
+<td>0.200s</td>
89 89
 <td class="success">100%</td>
90 90
 </tr>
91 91
 </tbody>
... ...
@@ -112,14 +112,14 @@
112 112
 <td>1</td>
113 113
 <td>0</td>
114 114
 <td>0</td>
115
-<td>0.221s</td>
115
+<td>0.163s</td>
116 116
 <td class="success">100%</td>
117 117
 </tr>
118 118
 <tr>
119 119
 <td class="success">
120 120
 <a href="classes/re.forestier.edu.UnitTests.html">re.forestier.edu.UnitTests</a>
121 121
 </td>
122
-<td>10</td>
122
+<td>12</td>
123 123
 <td>0</td>
124 124
 <td>0</td>
125 125
 <td>0.037s</td>
... ...
@@ -136,7 +136,7 @@
136 136
 <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
137 137
 </label>
138 138
 </div>Generated by 
139
-<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 09:16:49</p>
139
+<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 11:48:15</p>
140 140
 </div>
141 141
 </div>
142 142
 </body>
... ...
@@ -22,7 +22,7 @@
22 22
 <tr>
23 23
 <td>
24 24
 <div class="infoBox" id="tests">
25
-<div class="counter">11</div>
25
+<div class="counter">13</div>
26 26
 <p>tests</p>
27 27
 </div>
28 28
 </td>
... ...
@@ -40,7 +40,7 @@
40 40
 </td>
41 41
 <td>
42 42
 <div class="infoBox" id="duration">
43
-<div class="counter">0.258s</div>
43
+<div class="counter">0.200s</div>
44 44
 <p>duration</p>
45 45
 </div>
46 46
 </td>
... ...
@@ -83,14 +83,14 @@
83 83
 <td>1</td>
84 84
 <td>0</td>
85 85
 <td>0</td>
86
-<td>0.221s</td>
86
+<td>0.163s</td>
87 87
 <td class="success">100%</td>
88 88
 </tr>
89 89
 <tr>
90 90
 <td class="success">
91 91
 <a href="../classes/re.forestier.edu.UnitTests.html">UnitTests</a>
92 92
 </td>
93
-<td>10</td>
93
+<td>12</td>
94 94
 <td>0</td>
95 95
 <td>0</td>
96 96
 <td>0.037s</td>
... ...
@@ -106,7 +106,7 @@
106 106
 <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
107 107
 </label>
108 108
 </div>Generated by 
109
-<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 09:16:49</p>
109
+<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 11:48:15</p>
110 110
 </div>
111 111
 </div>
112 112
 </body>
... ...
@@ -1,7 +1,7 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2
-<testsuite name="re.forestier.edu.GlobalTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2024-12-13T08:16:49" hostname="clement-G551JM" time="0.221">
2
+<testsuite name="re.forestier.edu.GlobalTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2024-12-13T10:48:15" hostname="clement-G551JM" time="0.163">
3 3
   <properties/>
4
-  <testcase name="testAffichageBase()" classname="re.forestier.edu.GlobalTest" time="0.221"/>
4
+  <testcase name="testAffichageBase()" classname="re.forestier.edu.GlobalTest" time="0.163"/>
5 5
   <system-out><![CDATA[]]></system-out>
6 6
   <system-err><![CDATA[]]></system-err>
7 7
 </testsuite>
... ...
@@ -1,14 +1,16 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2
-<testsuite name="re.forestier.edu.UnitTests" tests="10" skipped="0" failures="0" errors="0" timestamp="2024-12-13T08:16:49" hostname="clement-G551JM" time="0.047">
2
+<testsuite name="re.forestier.edu.UnitTests" tests="12" skipped="0" failures="0" errors="0" timestamp="2024-12-13T10:48:15" hostname="clement-G551JM" time="0.05">
3 3
   <properties/>
4
-  <testcase name="Main" classname="re.forestier.edu.UnitTests" time="0.008"/>
5
-  <testcase name="removeMoney" classname="re.forestier.edu.UnitTests" time="0.009"/>
6
-  <testcase name="ex &amp; lvl" classname="re.forestier.edu.UnitTests" time="0.005"/>
4
+  <testcase name="Item tests" classname="re.forestier.edu.UnitTests" time="0.01"/>
5
+  <testcase name="Main" classname="re.forestier.edu.UnitTests" time="0.002"/>
6
+  <testcase name="removeMoney" classname="re.forestier.edu.UnitTests" time="0.008"/>
7
+  <testcase name="ex &amp; lvl" classname="re.forestier.edu.UnitTests" time="0.003"/>
7 8
   <testcase name="addMoney" classname="re.forestier.edu.UnitTests" time="0.001"/>
8
-  <testcase name="Heal and hurt" classname="re.forestier.edu.UnitTests" time="0.002"/>
9
-  <testcase name="Construcor UpdatePlayer" classname="re.forestier.edu.UnitTests" time="0.001"/>
10
-  <testcase name="majDeFinDeTour" classname="re.forestier.edu.UnitTests" time="0.004"/>
11
-  <testcase name="Constructor Player" classname="re.forestier.edu.UnitTests" time="0.002"/>
9
+  <testcase name="Heal and hurt" classname="re.forestier.edu.UnitTests" time="0.001"/>
10
+  <testcase name="Item and player" classname="re.forestier.edu.UnitTests" time="0.002"/>
11
+  <testcase name="Construcor Manager" classname="re.forestier.edu.UnitTests" time="0.001"/>
12
+  <testcase name="majDeFinDeTour" classname="re.forestier.edu.UnitTests" time="0.003"/>
13
+  <testcase name="Constructor Player" classname="re.forestier.edu.UnitTests" time="0.001"/>
12 14
   <testcase name="Natural Tests" classname="re.forestier.edu.UnitTests" time="0.004"/>
13 15
   <testcase name="Sample test" classname="re.forestier.edu.UnitTests" time="0.001"/>
14 16
   <system-out><![CDATA[]]></system-out>
... ...
@@ -8,7 +8,7 @@ import java.util.ArrayList;
8 8
 
9 9
 public class Main {
10 10
     public static void main(String[] args) {
11
-        Player firstPlayer = new Player("Florian", "Ruzberg de Rivehaute", Jobs.DWARF, 200, new ArrayList<>());
11
+        Player firstPlayer = new Player("Florian", "Ruzberg de Rivehaute", Jobs.DWARF, 200, new ArrayList<>(),10);
12 12
         firstPlayer.addMoney(400);
13 13
 
14 14
         firstPlayer.addXp(15);
... ...
@@ -2,7 +2,9 @@ package re.forestier.edu.rpg;
2 2
 
3 3
 public class Affichage {
4 4
 
5
-    public static void afficherJoueur(Player player) {
5
+    public static void afficherJoueur(Player player) 
6
+    {
6 7
         System.out.println(player.toString());
7 8
     }
9
+
8 10
 }
... ...
@@ -27,16 +27,18 @@ public class Player {
27 27
     private Natural maxHealthPoint;
28 28
     private Natural currentHealthPoints;
29 29
     private Natural xp;
30
+    private Natural maxWeight;
31
+    private Natural weight;
30 32
 
31 33
     private final HashMap<Ability, Integer> abilities; //Ability = stat
32 34
                                                        //SHOULDDO : have another hashmap to have contextual modifier (items,...)
33 35
     private ArrayList<Item> inventory;
34 36
 
35
-    public Player(String playerName, String avatar_name, Jobs avatarClass, int money, ArrayList<Item> inventory) {
36
-        this(playerName,avatar_name,avatarClass,money,inventory,Player.defaultMaxHp.toInt());
37
+    public Player(String playerName, String avatar_name, Jobs avatarClass, int money, ArrayList<Item> inventory, int maxWeight) {
38
+        this(playerName,avatar_name,avatarClass,money,inventory,Player.defaultMaxHp.toInt(),maxWeight);
37 39
     }
38 40
 
39
-    public Player(String playerName, String avatar_name, Jobs avatarClass, int money, ArrayList<Item> inventory, int maxHp)
41
+    public Player(String playerName, String avatar_name, Jobs avatarClass, int money, ArrayList<Item> inventory, int maxHp, int maxWeight)
40 42
     {
41 43
         this.playerName = playerName;
42 44
         this.avatarName = avatar_name;
... ...
@@ -49,7 +51,16 @@ public class Player {
49 51
         avatarClass.getAbilityPerLevel().forEach((ability,value)->
50 52
             {this.abilities.put(ability,value[0]);}
51 53
         );
52
-
54
+        this.maxWeight = Natural.valueOf(maxWeight);
55
+        this.weight = Natural.valueOf(0);
56
+        for(Item i : inventory)
57
+        {
58
+            this.weight.add(i.getWeight());
59
+        }
60
+        if(this.weight.compareTo(this.maxWeight) == -1)
61
+        {
62
+            throw  new UnsupportedOperationException("The player have too much to carry in theyr inventory");
63
+        }
53 64
         this.maxHealthPoint = Natural.valueOf(maxHp);
54 65
         this.currentHealthPoints = Natural.valueOf(maxHp);
55 66
     }
... ...
@@ -111,6 +122,30 @@ public class Player {
111 122
         }
112 123
     }
113 124
 
125
+    public void addItem(Item i)
126
+    {
127
+        Natural w = (Natural)this.weight.clone();
128
+        w.add(i.getWeight());
129
+        if(w.compareTo(this.maxWeight) == -1)
130
+        {
131
+            throw new UnsupportedOperationException("Player can't carry more.");
132
+
133
+        }
134
+
135
+        this.weight.add(i.getWeight());
136
+        this.inventory.add(i);
137
+    }
138
+
139
+    public void removeItem(Item i)
140
+    {
141
+        if(!this.inventory.contains(i))
142
+        {
143
+            throw new UnsupportedOperationException("Can't remove what player don't have");
144
+        }
145
+        this.weight.substract(i.getWeight());
146
+        this.inventory.remove(i);
147
+    }
148
+
114 149
     public void buy(Item i)
115 150
     {
116 151
         if(this.money.compareTo(i.getValue()) == 1)
... ...
@@ -118,7 +153,16 @@ public class Player {
118 153
             throw new UnsupportedOperationException("Player doesn't have enough money.");
119 154
         }
120 155
 
156
+        Natural w = (Natural)this.weight.clone();
157
+        w.add(i.getWeight());
158
+        if(w.compareTo(this.maxWeight) == -1)
159
+        {
160
+            throw new UnsupportedOperationException("Player can't carry more.");
161
+
162
+        }
163
+
121 164
         this.removeMoney(i.getValue().toInt());
165
+        this.weight.add(i.getWeight());
122 166
         this.inventory.add(i);
123 167
     }
124 168
 
... ...
@@ -130,6 +174,7 @@ public class Player {
130 174
         }
131 175
 
132 176
         this.inventory.remove(i);
177
+        this.weight.substract(i.getWeight());
133 178
         this.addMoney(i.getValue().toInt());
134 179
     }
135 180
 
... ...
@@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test;
5 5
 import re.forestier.edu.rpg.Affichage;
6 6
 import re.forestier.edu.rpg.Manager;
7 7
 import re.forestier.edu.rpg.Player;
8
+import re.forestier.edu.rpg.Item;
8 9
 import re.forestier.edu.rpg.Jobs;
9 10
 
10 11
 import java.util.ArrayList;
... ...
@@ -43,11 +44,12 @@ public class GlobalTest {
43 44
         System.setErr(originalErr);
44 45
     }
45 46
 
47
+
46 48
     @Test
47 49
     void testAffichageBase() {
48
-        Player player = new Player("Florian", "Gnognak le Barbare", Jobs.ADVENTURER, 200, new ArrayList<>());
50
+        Player player = new Player("Florian", "Gnognak le Barbare", Jobs.ADVENTURER, 200, new ArrayList<Item>(),10);
49 51
         player.addXp(20);
50
-        player.inventory = new ArrayList<>();
52
+        player.removeItem(player.getInventory().get(0));
51 53
         Affichage.afficherJoueur(player);
52 54
         verify(outContent );
53 55
     }
... ...
@@ -38,7 +38,7 @@ public class UnitTests {
38 38
     @Test
39 39
     @DisplayName("Sample test")
40 40
     void testPlayerName() {
41
-        Player Player = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>());
41
+        Player Player = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10);
42 42
         assertThat(Player.getPlayerName(), is("Florian"));
43 43
         
44 44
     }
... ...
@@ -47,11 +47,11 @@ public class UnitTests {
47 47
     @DisplayName("Constructor Player")
48 48
     void testPlayerConstructor()
49 49
     {
50
-        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>());
50
+        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10);
51 51
         assertThat(p.getPlayerName(), is("Florian"));
52
-        p = new Player("Florian", "Grognak le barbare", Jobs.DWARF, 100, new ArrayList<>());
52
+        p = new Player("Florian", "Grognak le barbare", Jobs.DWARF, 100, new ArrayList<>(),10);
53 53
         assertThat(p.getPlayerName(), is("Florian"));
54
-        p = new Player("Florian", "Grognak le barbare", Jobs.ARCHER, 100, new ArrayList<>());
54
+        p = new Player("Florian", "Grognak le barbare", Jobs.ARCHER, 100, new ArrayList<>(),10);
55 55
         assertThat(p.getPlayerName(), is("Florian"));
56 56
         assertThat(p.getAvatarName(), is("Grognak le barbare"));
57 57
     }
... ...
@@ -59,7 +59,7 @@ public class UnitTests {
59 59
     @Test
60 60
     @DisplayName("removeMoney")
61 61
     void testRemoveMoney() {
62
-        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>());
62
+        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10);
63 63
 
64 64
         assertThrows(IllegalArgumentException.class, () -> p.removeMoney(200));
65 65
         p.removeMoney(50);
... ...
@@ -73,7 +73,7 @@ public class UnitTests {
73 73
     @DisplayName("Heal and hurt")
74 74
     void testHealAndHurt()
75 75
     {
76
-        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>());
76
+        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10);
77 77
         assertThrows(IllegalArgumentException.class, () -> p.heal(-1));
78 78
         assertThrows(IllegalArgumentException.class, () -> p.hurt(-1));
79 79
 
... ...
@@ -83,7 +83,7 @@ public class UnitTests {
83 83
     @Test
84 84
     @DisplayName("addMoney")
85 85
     void testAddMoney() {
86
-        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>());
86
+        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10);
87 87
         p.addMoney(50);
88 88
         assertThat(p.getMoney(), is(150));
89 89
     }
... ...
@@ -98,7 +98,7 @@ public class UnitTests {
98 98
     @Test
99 99
     @DisplayName("ex & lvl")
100 100
     void testRetrieveLevel() {
101
-        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>());
101
+        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10);
102 102
         boolean b;
103 103
         p.addXp(5);
104 104
         assertThat(p.getXp(),is(5));
... ...
@@ -112,13 +112,13 @@ public class UnitTests {
112 112
         p.addXp(100);
113 113
         assertThat(p.getLevel(),is(5));
114 114
 
115
-        p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>());
116
-        int tailleinv = p.inventory.size();
115
+        p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10);
116
+        int tailleinv = p.getInventory().size();
117 117
         p.addXp(10);
118 118
         /*fail(p.avatarClass.getAbilityPerLevel().toString());
119 119
         fail(p.getAbilities().toString());*/
120 120
         int atk = p.getAbilities().get(Ability.ATK);
121
-        assertNotEquals(p.inventory.size(),tailleinv);
121
+        assertNotEquals(p.getInventory().size(),tailleinv);
122 122
         assertThat(p.getLevel(),is(2));
123 123
         p.addXp(17);
124 124
         assertThat(p.getLevel(),is(3));
... ...
@@ -134,7 +134,7 @@ public class UnitTests {
134 134
     @DisplayName("majDeFinDeTour")
135 135
     void testMajFinTour() {
136 136
         assertEquals(Ability.ATK.toString(),"ATK");
137
-        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10);
137
+        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10,10);
138 138
         p.hurt(10);
139 139
         Manager.majFinDeTour(p);
140 140
         assertEquals("Le joueur est KO !", outContent.toString().trim());
... ...
@@ -150,45 +150,45 @@ public class UnitTests {
150 150
         Manager.majFinDeTour(p);
151 151
         assertThat(p.getCurrentHealthPoints(),is(p.getMaxHealthPoints()));
152 152
         
153
-        p = new Player("Florian", "Grognak le barbare", Jobs.DWARF, 100, new ArrayList<>(),10);
153
+        p = new Player("Florian", "Grognak le barbare", Jobs.DWARF, 100, new ArrayList<>(),10,10);
154 154
         p.hurt(9);
155 155
         Manager.majFinDeTour(p);
156 156
         assertThat(p.getCurrentHealthPoints(),is(2));
157 157
 
158
-        p = new Player("Florian", "Grognak le barbare", Jobs.DWARF, 100, new ArrayList<>(),10);
158
+        p = new Player("Florian", "Grognak le barbare", Jobs.DWARF, 100, new ArrayList<>(),10,10);
159 159
         p.hurt(5);
160 160
         Manager.majFinDeTour(p);
161 161
         assertThat(p.getCurrentHealthPoints(),is(5));
162 162
 
163
-        ArrayList<String> inv = new ArrayList<String>();
164
-        inv.add("Holy Elixir");
165
-        p = new Player("Florian", "Grognak le barbare", Jobs.DWARF, 100, inv,10);
163
+        ArrayList<Item> inv = new ArrayList<Item>();
164
+        inv.add(new Item("Holy Elixir","",Natural.valueOf(0),Natural.valueOf(0)))   ;
165
+        p = new Player("Florian", "Grognak le barbare", Jobs.DWARF, 100, inv,10,10);
166 166
         p.hurt(9);
167 167
         Manager.majFinDeTour(p);
168 168
         assertThat(p.getCurrentHealthPoints(),is(3));
169 169
 
170
-        p = new Player("Florian", "Grognak le barbare", Jobs.ARCHER, 100, new ArrayList<>(),10);
170
+        p = new Player("Florian", "Grognak le barbare", Jobs.ARCHER, 100, new ArrayList<>(),10,10);
171 171
         p.hurt(9);
172 172
         Manager.majFinDeTour(p);
173 173
         assertThat(p.getCurrentHealthPoints(),is(2));
174 174
 
175
-        p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10);
175
+        p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10,10);
176 176
         p.hurt(9);
177 177
         p.addXp(28);
178 178
         Manager.majFinDeTour(p);
179 179
         assertThat(p.getCurrentHealthPoints(),is(3));
180 180
 
181
-        inv.add("Magic Bow");
182
-        p = new Player("Florian", "Grognak le barbare", Jobs.ARCHER, 100, inv,10);
181
+        inv.add(new Item("Magic Bow","",Natural.valueOf(0),Natural.valueOf(0)));
182
+        p = new Player("Florian", "Grognak le barbare", Jobs.ARCHER, 100, inv,10,10);
183 183
         p.hurt(9);;
184 184
         Manager.majFinDeTour(p);
185 185
         assertThat(p.getCurrentHealthPoints(),is(2)); //Suite a discussion avec le client, le "Magic bow" ne peut que soigner
186
-        p = new Player("Florian", "Grognak le barbare", Jobs.ARCHER, 100, inv,40);
186
+        p = new Player("Florian", "Grognak le barbare", Jobs.ARCHER, 100, inv,40,10);
187 187
         p.hurt(24);
188 188
         Manager.majFinDeTour(p);
189 189
         assertThat(p.getCurrentHealthPoints(),is(17 + 17/8-1));
190 190
 
191
-        p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),40);
191
+        p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),40,10);
192 192
         p.hurt(20);
193 193
         Manager.majFinDeTour(p);
194 194
         assertEquals(p.getCurrentHealthPoints(),20);
... ...
@@ -217,18 +217,18 @@ public class UnitTests {
217 217
     @DisplayName("Item and player")
218 218
     void testBuySell()
219 219
     {   
220
-        Item i = new Item("1kg de plume","Pese plus lourd que le plomb de part le poids du destin de ces pauvres oiseaux", Natural.valueOf(1),Natural.valueOf(2));
221
-        Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10);
220
+        final Item i = new Item("1kg de plume","Pese plus lourd que le plomb de part le poids du destin de ces pauvres oiseaux", Natural.valueOf(1),Natural.valueOf(2));
221
+        final Player p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 100, new ArrayList<>(),10,10);
222 222
         p.buy(i);
223
-        assertEquals(p.getInventory().size(),1);
224
-        assertEquals(p.getMoney(),Natural.valueOf(98));
223
+        assertTrue(p.getInventory().contains(i));
224
+        assertEquals(p.getMoney(),98);
225 225
         p.sell(i);
226 226
         assertEquals(p.getInventory().size(),0);
227
-        assertEquals(p.getMoney(),Natural.valueOf(100));
228
-        assertThrows(UnsupportedOperationExceptionn.class, () -> p.sell(i));
229
-        p = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 0, new ArrayList<>(),10);
230
-        assertThrows(UnsupportedOperationExceptionn.class, () -> p.buy(i));
231
-        assertThrows(UnsupportedOperationExceptionn.class, () -> p.sell(i));
227
+        assertEquals(p.getMoney(),100);
228
+        assertThrows(UnsupportedOperationException.class, () -> p.sell(i));
229
+        Player p2 = new Player("Florian", "Grognak le barbare", Jobs.ADVENTURER, 0, new ArrayList<>(),10,10);
230
+        assertThrows(UnsupportedOperationException.class, () -> p2.buy(i));
231
+        assertThrows(UnsupportedOperationException.class, () -> p2.sell(i));
232 232
 
233 233
     }
234 234
 
235 235