Clement COLMERAUER commited on 2024-10-24 16:29:31
Showing 19 changed files, with 34 additions and 40 deletions.
| ... | ... |
@@ -41,7 +41,7 @@ |
| 41 | 41 |
</td> |
| 42 | 42 |
<td> |
| 43 | 43 |
<div class="infoBox" id="duration"> |
| 44 |
-<div class="counter">0.158s</div> |
|
| 44 |
+<div class="counter">0.167s</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.158s</td> |
|
| 79 |
+<td class="success">0.167s</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:19:13</p> |
|
| 92 |
+<a href="http://www.gradle.org">Gradle 8.8</a> at 24 oct. 2024, 16:29:02</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.029s</div> |
|
| 44 |
+<div class="counter">0.021s</div> |
|
| 45 | 45 |
<p>duration</p> |
| 46 | 46 |
</div> |
| 47 | 47 |
</td> |
| ... | ... |
@@ -84,7 +84,7 @@ |
| 84 | 84 |
<tr> |
| 85 | 85 |
<td class="success">Main</td> |
| 86 | 86 |
<td class="success">testMain()</td> |
| 87 |
-<td class="success">0.013s</td> |
|
| 87 |
+<td class="success">0.006s</td> |
|
| 88 | 88 |
<td class="success">passed</td> |
| 89 | 89 |
</tr> |
| 90 | 90 |
<tr> |
| ... | ... |
@@ -96,19 +96,19 @@ |
| 96 | 96 |
<tr> |
| 97 | 97 |
<td class="success">Natural Tests</td> |
| 98 | 98 |
<td class="success">testNatural()</td> |
| 99 |
-<td class="success">0.002s</td> |
|
| 99 |
+<td class="success">0.003s</td> |
|
| 100 | 100 |
<td class="success">passed</td> |
| 101 | 101 |
</tr> |
| 102 | 102 |
<tr> |
| 103 | 103 |
<td class="success">Constructor Player</td> |
| 104 | 104 |
<td class="success">testPlayerConstructor()</td> |
| 105 |
-<td class="success">0.001s</td> |
|
| 105 |
+<td class="success">0s</td> |
|
| 106 | 106 |
<td class="success">passed</td> |
| 107 | 107 |
</tr> |
| 108 | 108 |
<tr> |
| 109 | 109 |
<td class="success">Sample test</td> |
| 110 | 110 |
<td class="success">testPlayerName()</td> |
| 111 |
-<td class="success">0.001s</td> |
|
| 111 |
+<td class="success">0s</td> |
|
| 112 | 112 |
<td class="success">passed</td> |
| 113 | 113 |
</tr> |
| 114 | 114 |
<tr> |
| ... | ... |
@@ -120,13 +120,13 @@ |
| 120 | 120 |
<tr> |
| 121 | 121 |
<td class="success">ex & lvl</td> |
| 122 | 122 |
<td class="success">testRetrieveLevel()</td> |
| 123 |
-<td class="success">0.002s</td> |
|
| 123 |
+<td class="success">0.003s</td> |
|
| 124 | 124 |
<td class="success">passed</td> |
| 125 | 125 |
</tr> |
| 126 | 126 |
<tr> |
| 127 | 127 |
<td class="success">Construcor UpdatePlayer</td> |
| 128 | 128 |
<td class="success">testUpdatePlayer()</td> |
| 129 |
-<td class="success">0.001s</td> |
|
| 129 |
+<td class="success">0s</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:19:13</p> |
|
| 142 |
+<a href="http://www.gradle.org">Gradle 8.8</a> at 24 oct. 2024, 16:29:02</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.187s</div> |
|
| 41 |
+<div class="counter">0.188s</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.187s</td> |
|
| 88 |
+<td>0.188s</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.158s</td> |
|
| 115 |
+<td>0.167s</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.029s</td> |
|
| 125 |
+<td>0.021s</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:19:13</p> |
|
| 139 |
+<a href="http://www.gradle.org">Gradle 8.8</a> at 24 oct. 2024, 16:29:02</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.187s</div> |
|
| 43 |
+<div class="counter">0.188s</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.158s</td> |
|
| 86 |
+<td>0.167s</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.029s</td> |
|
| 96 |
+<td>0.021s</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:19:13</p> |
|
| 109 |
+<a href="http://www.gradle.org">Gradle 8.8</a> at 24 oct. 2024, 16:29:02</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:19:13" hostname="a206pc27L.local.isima.fr" time="0.158"> |
|
| 2 |
+<testsuite name="re.forestier.edu.GlobalTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2024-10-24T14:29:02" hostname="a206pc27L.local.isima.fr" time="0.167"> |
|
| 3 | 3 |
<properties/> |
| 4 |
- <testcase name="testAffichageBase()" classname="re.forestier.edu.GlobalTest" time="0.158"/> |
|
| 4 |
+ <testcase name="testAffichageBase()" classname="re.forestier.edu.GlobalTest" time="0.167"/> |
|
| 5 | 5 |
<system-out><![CDATA[]]></system-out> |
| 6 | 6 |
<system-err><![CDATA[]]></system-err> |
| 7 | 7 |
</testsuite> |
| ... | ... |
@@ -1,15 +1,15 @@ |
| 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:19:13" hostname="a206pc27L.local.isima.fr" time="0.032"> |
|
| 2 |
+<testsuite name="re.forestier.edu.UnitTests" tests="9" skipped="0" failures="0" errors="0" timestamp="2024-10-24T14:29:02" hostname="a206pc27L.local.isima.fr" time="0.028"> |
|
| 3 | 3 |
<properties/> |
| 4 |
- <testcase name="Main" classname="re.forestier.edu.UnitTests" time="0.013"/> |
|
| 4 |
+ <testcase name="Main" classname="re.forestier.edu.UnitTests" time="0.006"/> |
|
| 5 | 5 |
<testcase name="removeMoney" classname="re.forestier.edu.UnitTests" time="0.006"/> |
| 6 |
- <testcase name="ex & lvl" classname="re.forestier.edu.UnitTests" time="0.002"/> |
|
| 6 |
+ <testcase name="ex & lvl" classname="re.forestier.edu.UnitTests" time="0.003"/> |
|
| 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.001"/> |
|
| 8 |
+ <testcase name="Construcor UpdatePlayer" classname="re.forestier.edu.UnitTests" time="0.0"/> |
|
| 9 | 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 |
- <testcase name="Natural Tests" classname="re.forestier.edu.UnitTests" time="0.002"/> |
|
| 12 |
- <testcase name="Sample test" classname="re.forestier.edu.UnitTests" time="0.001"/> |
|
| 10 |
+ <testcase name="Constructor Player" classname="re.forestier.edu.UnitTests" time="0.0"/> |
|
| 11 |
+ <testcase name="Natural Tests" classname="re.forestier.edu.UnitTests" time="0.003"/> |
|
| 12 |
+ <testcase name="Sample test" classname="re.forestier.edu.UnitTests" time="0.0"/> |
|
| 13 | 13 |
<system-out><![CDATA[]]></system-out> |
| 14 | 14 |
<system-err><![CDATA[]]></system-err> |
| 15 | 15 |
</testsuite> |
| ... | ... |
@@ -6,6 +6,7 @@ import java.util.HashMap; |
| 6 | 6 |
import re.forestier.edu.lib.Natural; |
| 7 | 7 |
|
| 8 | 8 |
public class Player {
|
| 9 |
+ private static final Natural defaultMaxHp = Natural.valueOf(20); |
|
| 9 | 10 |
private static final Integer[] xpForlevel = {0,10,27,57,111}; //Level = i+1
|
| 10 | 11 |
//TODO : add level |
| 11 | 12 |
|
| ... | ... |
@@ -25,19 +26,12 @@ public class Player {
|
| 25 | 26 |
public ArrayList<String> inventory; |
| 26 | 27 |
|
| 27 | 28 |
public Player(String playerName, String avatar_name, String avatarClass, int money, ArrayList<String> inventory) {
|
| 28 |
- if (!avatarClass.equals("ARCHER") && !avatarClass.equals("ADVENTURER") && !avatarClass.equals("DWARF"))
|
|
| 29 |
- {
|
|
| 30 |
- return; |
|
| 29 |
+ this(playerName,avatar_name,avatarClass,money,inventory,Player.defaultMaxHp.toInt()); |
|
| 31 | 30 |
} |
| 32 | 31 |
|
| 33 |
- this.playerName = playerName; |
|
| 34 |
- this.avatarName = avatar_name; |
|
| 35 |
- this.avatarClass = avatarClass; |
|
| 36 |
- this.money = Integer.valueOf(money); |
|
| 37 |
- this.inventory = inventory; |
|
| 38 |
- this.level = Natural.valueOf(1); |
|
| 39 |
- this.xp = Natural.valueOf(0); |
|
| 40 |
- this.abilities = UpdatePlayer.abilitiesPerTypeAndLevel().get(this.avatarClass).get(1); |
|
| 32 |
+ private Player() |
|
| 33 |
+ {
|
|
| 34 |
+ //Here to prevent the compilator to create default constructor |
|
| 41 | 35 |
} |
| 42 | 36 |
|
| 43 | 37 |
public Player(String playerName, String avatar_name, String avatarClass, int money, ArrayList<String> inventory, int maxHp) |
| 44 | 38 |