Player.xp en Natural
Clement COLMERAUER

Clement COLMERAUER commited on 2024-10-24 16:20:47
Showing 20 changed files, with 29 additions and 34 deletions.

... ...
@@ -41,7 +41,7 @@
41 41
 </td>
42 42
 <td>
43 43
 <div class="infoBox" id="duration">
44
-<div class="counter">0.145s</div>
44
+<div class="counter">0.158s</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.145s</td>
79
+<td class="success">0.158s</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 24 oct. 2024, 16:11:48</p>
92
+<a href="http://www.gradle.org">Gradle 8.8</a> at 24 oct. 2024, 16:19:13</p>
93 93
 </div>
94 94
 </div>
95 95
 </body>
... ...
@@ -41,7 +41,7 @@
41 41
 </td>
42 42
 <td>
43 43
 <div class="infoBox" id="duration">
44
-<div class="counter">0.026s</div>
44
+<div class="counter">0.029s</div>
45 45
 <p>duration</p>
46 46
 </div>
47 47
 </td>
... ...
@@ -90,7 +90,7 @@
90 90
 <tr>
91 91
 <td class="success">majDeFinDeTour</td>
92 92
 <td class="success">testMajFinTour()</td>
93
-<td class="success">0.001s</td>
93
+<td class="success">0.002s</td>
94 94
 <td class="success">passed</td>
95 95
 </tr>
96 96
 <tr>
... ...
@@ -102,7 +102,7 @@
102 102
 <tr>
103 103
 <td class="success">Constructor Player</td>
104 104
 <td class="success">testPlayerConstructor()</td>
105
-<td class="success">0s</td>
105
+<td class="success">0.001s</td>
106 106
 <td class="success">passed</td>
107 107
 </tr>
108 108
 <tr>
... ...
@@ -126,7 +126,7 @@
126 126
 <tr>
127 127
 <td class="success">Construcor UpdatePlayer</td>
128 128
 <td class="success">testUpdatePlayer()</td>
129
-<td class="success">0s</td>
129
+<td class="success">0.001s</td>
130 130
 <td class="success">passed</td>
131 131
 </tr>
132 132
 </table>
... ...
@@ -139,7 +139,7 @@
139 139
 <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
140 140
 </label>
141 141
 </div>Generated by 
142
-<a href="http://www.gradle.org">Gradle 8.8</a> at 24 oct. 2024, 16:11:48</p>
142
+<a href="http://www.gradle.org">Gradle 8.8</a> at 24 oct. 2024, 16:19:13</p>
143 143
 </div>
144 144
 </div>
145 145
 </body>
... ...
@@ -38,7 +38,7 @@
38 38
 </td>
39 39
 <td>
40 40
 <div class="infoBox" id="duration">
41
-<div class="counter">0.171s</div>
41
+<div class="counter">0.187s</div>
42 42
 <p>duration</p>
43 43
 </div>
44 44
 </td>
... ...
@@ -85,7 +85,7 @@
85 85
 <td>10</td>
86 86
 <td>0</td>
87 87
 <td>0</td>
88
-<td>0.171s</td>
88
+<td>0.187s</td>
89 89
 <td class="success">100%</td>
90 90
 </tr>
91 91
 </tbody>
... ...
@@ -112,7 +112,7 @@
112 112
 <td>1</td>
113 113
 <td>0</td>
114 114
 <td>0</td>
115
-<td>0.145s</td>
115
+<td>0.158s</td>
116 116
 <td class="success">100%</td>
117 117
 </tr>
118 118
 <tr>
... ...
@@ -122,7 +122,7 @@
122 122
 <td>9</td>
123 123
 <td>0</td>
124 124
 <td>0</td>
125
-<td>0.026s</td>
125
+<td>0.029s</td>
126 126
 <td class="success">100%</td>
127 127
 </tr>
128 128
 </tbody>
... ...
@@ -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 24 oct. 2024, 16:11:48</p>
139
+<a href="http://www.gradle.org">Gradle 8.8</a> at 24 oct. 2024, 16:19:13</p>
140 140
 </div>
141 141
 </div>
142 142
 </body>
... ...
@@ -40,7 +40,7 @@
40 40
 </td>
41 41
 <td>
42 42
 <div class="infoBox" id="duration">
43
-<div class="counter">0.171s</div>
43
+<div class="counter">0.187s</div>
44 44
 <p>duration</p>
45 45
 </div>
46 46
 </td>
... ...
@@ -83,7 +83,7 @@
83 83
 <td>1</td>
84 84
 <td>0</td>
85 85
 <td>0</td>
86
-<td>0.145s</td>
86
+<td>0.158s</td>
87 87
 <td class="success">100%</td>
88 88
 </tr>
89 89
 <tr>
... ...
@@ -93,7 +93,7 @@
93 93
 <td>9</td>
94 94
 <td>0</td>
95 95
 <td>0</td>
96
-<td>0.026s</td>
96
+<td>0.029s</td>
97 97
 <td class="success">100%</td>
98 98
 </tr>
99 99
 </table>
... ...
@@ -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 24 oct. 2024, 16:11:48</p>
109
+<a href="http://www.gradle.org">Gradle 8.8</a> at 24 oct. 2024, 16:19:13</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-10-24T14:11:48" hostname="a206pc27L.local.isima.fr" time="0.145">
2
+<testsuite name="re.forestier.edu.GlobalTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2024-10-24T14:19:13" hostname="a206pc27L.local.isima.fr" time="0.158">
3 3
   <properties/>
4
-  <testcase name="testAffichageBase()" classname="re.forestier.edu.GlobalTest" time="0.145"/>
4
+  <testcase name="testAffichageBase()" classname="re.forestier.edu.GlobalTest" time="0.158"/>
5 5
   <system-out><![CDATA[]]></system-out>
6 6
   <system-err><![CDATA[]]></system-err>
7 7
 </testsuite>
... ...
@@ -1,13 +1,13 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2
-<testsuite name="re.forestier.edu.UnitTests" tests="9" skipped="0" failures="0" errors="0" timestamp="2024-10-24T14:11:48" hostname="a206pc27L.local.isima.fr" time="0.033">
2
+<testsuite name="re.forestier.edu.UnitTests" tests="9" skipped="0" failures="0" errors="0" timestamp="2024-10-24T14:19:13" hostname="a206pc27L.local.isima.fr" time="0.032">
3 3
   <properties/>
4 4
   <testcase name="Main" classname="re.forestier.edu.UnitTests" time="0.013"/>
5 5
   <testcase name="removeMoney" classname="re.forestier.edu.UnitTests" time="0.006"/>
6 6
   <testcase name="ex &amp; lvl" classname="re.forestier.edu.UnitTests" time="0.002"/>
7 7
   <testcase name="addMoney" classname="re.forestier.edu.UnitTests" time="0.001"/>
8
-  <testcase name="Construcor UpdatePlayer" classname="re.forestier.edu.UnitTests" time="0.0"/>
9
-  <testcase name="majDeFinDeTour" classname="re.forestier.edu.UnitTests" time="0.001"/>
10
-  <testcase name="Constructor Player" classname="re.forestier.edu.UnitTests" time="0.0"/>
8
+  <testcase name="Construcor UpdatePlayer" classname="re.forestier.edu.UnitTests" time="0.001"/>
9
+  <testcase name="majDeFinDeTour" classname="re.forestier.edu.UnitTests" time="0.002"/>
10
+  <testcase name="Constructor Player" classname="re.forestier.edu.UnitTests" time="0.001"/>
11 11
   <testcase name="Natural Tests" classname="re.forestier.edu.UnitTests" time="0.002"/>
12 12
   <testcase name="Sample test" classname="re.forestier.edu.UnitTests" time="0.001"/>
13 13
   <system-out><![CDATA[]]></system-out>
... ...
@@ -19,7 +19,7 @@ public class Player {
19 19
     private Natural level;
20 20
     private Natural maxHealthPoint;
21 21
     private Natural currentHealthPoints;
22
-    private int xp;
22
+    private Natural xp;
23 23
 
24 24
     public HashMap<String, Integer> abilities; //Ability = stat
25 25
     public ArrayList<String> inventory;
... ...
@@ -36,7 +36,7 @@ public class Player {
36 36
         this.money = Integer.valueOf(money);
37 37
         this.inventory = inventory;
38 38
         this.level = Natural.valueOf(1);
39
-        this.xp = 0;
39
+        this.xp = Natural.valueOf(0);
40 40
         this.abilities = UpdatePlayer.abilitiesPerTypeAndLevel().get(this.avatarClass).get(1);
41 41
     }
42 42
 
... ...
@@ -53,7 +53,7 @@ public class Player {
53 53
         this.money = Integer.valueOf(money);
54 54
         this.inventory = inventory;
55 55
         this.level = Natural.valueOf(1);
56
-        this.xp = 0;
56
+        this.xp = Natural.valueOf(0);
57 57
         this.abilities = UpdatePlayer.abilitiesPerTypeAndLevel().get(this.avatarClass).get(1);
58 58
         this.maxHealthPoint = Natural.valueOf(maxHp);
59 59
         this.currentHealthPoints = Natural.valueOf(maxHp);
... ...
@@ -114,12 +114,7 @@ public class Player {
114 114
 
115 115
     public int getXp()
116 116
     {
117
-        return this.xp;
118
-    }
119
-
120
-    public void setXp(int xp)
121
-    {
122
-        this.xp = xp;
117
+        return this.xp.toInt();
123 118
     }
124 119
 
125 120
     public String getAvatarClass () {
... ...
@@ -128,9 +123,9 @@ public class Player {
128 123
 
129 124
     public void addXp(int xp) {
130 125
         Natural ancientLevel = (Natural)this.level.clone();
131
-        this.xp += xp;
126
+        this.xp.add(Natural.valueOf(xp));
132 127
         int i = 0;
133
-        while(i < xpForlevel.length && this.xp >= xpForlevel[i])
128
+        while(i < xpForlevel.length && this.xp.toInt() >= xpForlevel[i])
134 129
         {
135 130
             i++;
136 131
         }
137 132