Clement COLMERAUER commited on 2024-10-21 11:48:01
Showing 26 changed files, with 64 additions and 32 deletions.
| ... | ... |
@@ -41,7 +41,7 @@ |
| 41 | 41 |
</td> |
| 42 | 42 |
<td> |
| 43 | 43 |
<div class="infoBox" id="duration"> |
| 44 |
-<div class="counter">0.164s</div> |
|
| 44 |
+<div class="counter">0.153s</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.164s</td> |
|
| 79 |
+<td class="success">0.153s</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 21 oct. 2024, 11:13:10</p> |
|
| 92 |
+<a href="http://www.gradle.org">Gradle 8.8</a> at 21 oct. 2024, 11:47:26</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.017s</div> |
|
| 44 |
+<div class="counter">0.036s</div> |
|
| 45 | 45 |
<p>duration</p> |
| 46 | 46 |
</div> |
| 47 | 47 |
</td> |
| ... | ... |
@@ -84,7 +84,7 @@ |
| 84 | 84 |
<tr> |
| 85 | 85 |
<td class="success">Affichage</td> |
| 86 | 86 |
<td class="success">testAffichage()</td> |
| 87 |
-<td class="success">0.006s</td> |
|
| 87 |
+<td class="success">0.024s</td> |
|
| 88 | 88 |
<td class="success">passed</td> |
| 89 | 89 |
</tr> |
| 90 | 90 |
<tr> |
| ... | ... |
@@ -126,7 +126,7 @@ |
| 126 | 126 |
<tr> |
| 127 | 127 |
<td class="success">ex & lvl</td> |
| 128 | 128 |
<td class="success">testRetrieveLevel()</td> |
| 129 |
-<td class="success">0.001s</td> |
|
| 129 |
+<td class="success">0.002s</td> |
|
| 130 | 130 |
<td class="success">passed</td> |
| 131 | 131 |
</tr> |
| 132 | 132 |
<tr> |
| ... | ... |
@@ -145,7 +145,7 @@ |
| 145 | 145 |
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/> |
| 146 | 146 |
</label> |
| 147 | 147 |
</div>Generated by |
| 148 |
-<a href="http://www.gradle.org">Gradle 8.8</a> at 21 oct. 2024, 11:13:10</p> |
|
| 148 |
+<a href="http://www.gradle.org">Gradle 8.8</a> at 21 oct. 2024, 11:47:26</p> |
|
| 149 | 149 |
</div> |
| 150 | 150 |
</div> |
| 151 | 151 |
</body> |
| ... | ... |
@@ -38,7 +38,7 @@ |
| 38 | 38 |
</td> |
| 39 | 39 |
<td> |
| 40 | 40 |
<div class="infoBox" id="duration"> |
| 41 |
-<div class="counter">0.181s</div> |
|
| 41 |
+<div class="counter">0.189s</div> |
|
| 42 | 42 |
<p>duration</p> |
| 43 | 43 |
</div> |
| 44 | 44 |
</td> |
| ... | ... |
@@ -85,7 +85,7 @@ |
| 85 | 85 |
<td>11</td> |
| 86 | 86 |
<td>0</td> |
| 87 | 87 |
<td>0</td> |
| 88 |
-<td>0.181s</td> |
|
| 88 |
+<td>0.189s</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.164s</td> |
|
| 115 |
+<td>0.153s</td> |
|
| 116 | 116 |
<td class="success">100%</td> |
| 117 | 117 |
</tr> |
| 118 | 118 |
<tr> |
| ... | ... |
@@ -122,7 +122,7 @@ |
| 122 | 122 |
<td>10</td> |
| 123 | 123 |
<td>0</td> |
| 124 | 124 |
<td>0</td> |
| 125 |
-<td>0.017s</td> |
|
| 125 |
+<td>0.036s</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 21 oct. 2024, 11:13:10</p> |
|
| 139 |
+<a href="http://www.gradle.org">Gradle 8.8</a> at 21 oct. 2024, 11:47:26</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.181s</div> |
|
| 43 |
+<div class="counter">0.189s</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.164s</td> |
|
| 86 |
+<td>0.153s</td> |
|
| 87 | 87 |
<td class="success">100%</td> |
| 88 | 88 |
</tr> |
| 89 | 89 |
<tr> |
| ... | ... |
@@ -93,7 +93,7 @@ |
| 93 | 93 |
<td>10</td> |
| 94 | 94 |
<td>0</td> |
| 95 | 95 |
<td>0</td> |
| 96 |
-<td>0.017s</td> |
|
| 96 |
+<td>0.036s</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 21 oct. 2024, 11:13:10</p> |
|
| 109 |
+<a href="http://www.gradle.org">Gradle 8.8</a> at 21 oct. 2024, 11:47:26</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-21T09:13:10" hostname="a206pc27L.local.isima.fr" time="0.164"> |
|
| 2 |
+<testsuite name="re.forestier.edu.GlobalTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2024-10-21T09:47:25" hostname="a206pc27L.local.isima.fr" time="0.153"> |
|
| 3 | 3 |
<properties/> |
| 4 |
- <testcase name="testAffichageBase()" classname="re.forestier.edu.GlobalTest" time="0.164"/> |
|
| 4 |
+ <testcase name="testAffichageBase()" classname="re.forestier.edu.GlobalTest" time="0.153"/> |
|
| 5 | 5 |
<system-out><![CDATA[]]></system-out> |
| 6 | 6 |
<system-err><![CDATA[]]></system-err> |
| 7 | 7 |
</testsuite> |
| ... | ... |
@@ -1,10 +1,10 @@ |
| 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-10-21T09:13:10" hostname="a206pc27L.local.isima.fr" time="0.023"> |
|
| 2 |
+<testsuite name="re.forestier.edu.UnitTests" tests="10" skipped="0" failures="0" errors="0" timestamp="2024-10-21T09:47:25" hostname="a206pc27L.local.isima.fr" time="0.042"> |
|
| 3 | 3 |
<properties/> |
| 4 |
- <testcase name="Affichage" classname="re.forestier.edu.UnitTests" time="0.006"/> |
|
| 4 |
+ <testcase name="Affichage" classname="re.forestier.edu.UnitTests" time="0.024"/> |
|
| 5 | 5 |
<testcase name="Main" classname="re.forestier.edu.UnitTests" time="0.002"/> |
| 6 | 6 |
<testcase name="removeMoney" classname="re.forestier.edu.UnitTests" time="0.004"/> |
| 7 |
- <testcase name="ex & lvl" classname="re.forestier.edu.UnitTests" time="0.001"/> |
|
| 7 |
+ <testcase name="ex & lvl" classname="re.forestier.edu.UnitTests" time="0.002"/> |
|
| 8 | 8 |
<testcase name="addMoney" classname="re.forestier.edu.UnitTests" time="0.001"/> |
| 9 | 9 |
<testcase name="Construcor UpdatePlayer" classname="re.forestier.edu.UnitTests" time="0.001"/> |
| 10 | 10 |
<testcase name="majDeFinDeTour" classname="re.forestier.edu.UnitTests" time="0.001"/> |
| ... | ... |
@@ -18,7 +18,7 @@ public class Player {
|
| 18 | 18 |
|
| 19 | 19 |
private Natural level; |
| 20 | 20 |
private Natural maxHealthPoint; |
| 21 |
- private int currenthealthpoints; |
|
| 21 |
+ private Natural currentHealthPoints; |
|
| 22 | 22 |
private int xp; |
| 23 | 23 |
|
| 24 | 24 |
public HashMap<String, Integer> abilities; //Ability = stat |
| ... | ... |
@@ -40,6 +40,13 @@ public class Player {
|
| 40 | 40 |
this.abilities = UpdatePlayer.abilitiesPerTypeAndLevel().get(AvatarClass).get(1); |
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 |
+ public Player(String playerName, String avatar_name, String avatarClass, int money, ArrayList<String> inventory, int maxHp) |
|
| 44 |
+ {
|
|
| 45 |
+ Player p = new Player(playerName,avatar_name,avatarClass,money,inventory); |
|
| 46 |
+ p.setMaxHealthPoints(maxHp); |
|
| 47 |
+ p.setCurrentHealthPoints(maxHp); |
|
| 48 |
+ } |
|
| 49 |
+ |
|
| 43 | 50 |
public String getPlayerName() |
| 44 | 51 |
{
|
| 45 | 52 |
return this.playerName; |
| ... | ... |
@@ -72,13 +79,36 @@ public class Player {
|
| 72 | 79 |
|
| 73 | 80 |
public int getCurrentHealthPoints() |
| 74 | 81 |
{
|
| 75 |
- return this.currenthealthpoints; |
|
| 82 |
+ return this.currentHealthPoints.toInt(); |
|
| 76 | 83 |
} |
| 77 | 84 |
|
| 78 | 85 |
public void setCurrentHealthPoints(int hp) |
| 79 | 86 |
{
|
| 80 |
- this.currenthealthpoints = hp; |
|
| 87 |
+ this.currentHealthPoints = Natural.valueOf(hp); |
|
| 88 |
+ } |
|
| 89 |
+ |
|
| 90 |
+ public void heal(int hp) |
|
| 91 |
+ {
|
|
| 92 |
+ if(hp < 0 ) |
|
| 93 |
+ {
|
|
| 94 |
+ throw new IllegalArgumentException(); |
|
| 95 |
+ } |
|
| 96 |
+ this.currentHealthPoints.add(Natural.valueOf(hp)); |
|
| 97 |
+ if(this.currentHealthPoints.compareTo(this.maxHealthPoint) == -1) |
|
| 98 |
+ {
|
|
| 99 |
+ this.currentHealthPoints = (Natural)this.maxHealthPoint.clone(); |
|
| 100 |
+ } |
|
| 101 |
+ } |
|
| 102 |
+ |
|
| 103 |
+ public void hurt(int damage) |
|
| 104 |
+ {
|
|
| 105 |
+ if(damage < 0 ) |
|
| 106 |
+ {
|
|
| 107 |
+ throw new IllegalArgumentException(); |
|
| 81 | 108 |
} |
| 109 |
+ this.currentHealthPoints.substract(Natural.valueOf(damage)); |
|
| 110 |
+ } |
|
| 111 |
+ |
|
| 82 | 112 |
|
| 83 | 113 |
public int getXp() |
| 84 | 114 |
{
|
| ... | ... |
@@ -5,7 +5,7 @@ import java.util.Random; |
| 5 | 5 |
|
| 6 | 6 |
public class UpdatePlayer {
|
| 7 | 7 |
|
| 8 |
- public final static String[] objectList = {"Lookout Ring : Prevents surprise attacks","Scroll of Stupidity : INT-2 when applied to an enemy", "Draupnir : Increases XP gained by 100%", "Magic Charm : Magic +10 for 5 rounds", "Rune Staff of Curse : May burn your ennemies... Or yourself. Who knows?", "Combat Edge : Well, that's an edge", "Holy Elixir : Recover your HP"
|
|
| 8 |
+ public final static String[] objectList = {"Magic bow : Heal by 1/8th of your HP","Lookout Ring : Prevents surprise attacks","Scroll of Stupidity : INT-2 when applied to an enemy", "Draupnir : Increases XP gained by 100%", "Magic Charm : Magic +10 for 5 rounds", "Rune Staff of Curse : May burn your ennemies... Or yourself. Who knows?", "Combat Edge : Well, that's an edge", "Holy Elixir : Recover your HP"
|
|
| 9 | 9 |
}; |
| 10 | 10 |
|
| 11 | 11 |
public static HashMap<String, HashMap<Integer, HashMap<String, Integer>>> abilitiesPerTypeAndLevel() {
|
| ... | ... |
@@ -109,22 +109,24 @@ public class UpdatePlayer {
|
| 109 | 109 |
if(!player.getAvatarClass().equals("ADVENTURER")) {
|
| 110 | 110 |
if(player.getAvatarClass().equals("DWARF")) {
|
| 111 | 111 |
if(player.inventory.contains("Holy Elixir")) {
|
| 112 |
- player.setCurrentHealthPoints(player.getCurrentHealthPoints()+1); |
|
| 112 |
+ player.heal(1); |
|
| 113 | 113 |
} |
| 114 |
- player.setCurrentHealthPoints(player.getCurrentHealthPoints()+1); |
|
| 114 |
+ player.heal(1); |
|
| 115 | 115 |
} |
| 116 | 116 |
|
| 117 | 117 |
|
| 118 | 118 |
if(player.getAvatarClass().equals("ARCHER")) {
|
| 119 |
- player.setCurrentHealthPoints(player.getCurrentHealthPoints()+1); |
|
| 119 |
+ player.heal(1); |
|
| 120 | 120 |
if(player.inventory.contains("Magic Bow")) {
|
| 121 |
- player.setCurrentHealthPoints(player.getCurrentHealthPoints()+player.getCurrentHealthPoints()/8-1); |
|
| 121 |
+ //player.setCurrentHealthPoints(player.getCurrentHealthPoints()+player.getCurrentHealthPoints()/8-1); |
|
| 122 |
+ int potentialHeal = player.getCurrentHealthPoints()/8-1; |
|
| 123 |
+ player.heal(potentialHeal < 0 ? 0 : potentialHeal); |
|
| 122 | 124 |
} |
| 123 | 125 |
} |
| 124 | 126 |
} else {
|
| 125 |
- player.setCurrentHealthPoints(player.getCurrentHealthPoints()+2); |
|
| 127 |
+ player.heal(2); |
|
| 126 | 128 |
if(player.getLevel() < 3) {
|
| 127 |
- player.setCurrentHealthPoints(player.getCurrentHealthPoints()-1); |
|
| 129 |
+ player.hurt(1); |
|
| 128 | 130 |
} |
| 129 | 131 |
} |
| 130 | 132 |
} else |
| ... | ... |
@@ -174,7 +174,7 @@ public class UnitTests {
|
| 174 | 174 |
p.setCurrentHealthPoints(1); |
| 175 | 175 |
p.setMaxHealthPoints(10); |
| 176 | 176 |
UpdatePlayer.majFinDeTour(p); |
| 177 |
- assertThat(p.getCurrentHealthPoints(),is(1)); |
|
| 177 |
+ assertThat(p.getCurrentHealthPoints(),is(2)); //Suite a discussion avec le client, le "Magic bow" ne peut que soigné |
|
| 178 | 178 |
p.setCurrentHealthPoints(16); |
| 179 | 179 |
p.setMaxHealthPoints(40); |
| 180 | 180 |
UpdatePlayer.majFinDeTour(p); |
| 181 | 181 |