Ajout markdown
Clement Colmerauer

Clement Colmerauer commited on 2024-12-13 12:14:03
Showing 24 changed files, with 90 additions and 27 deletions.

... ...
@@ -41,7 +41,7 @@
41 41
 </td>
42 42
 <td>
43 43
 <div class="infoBox" id="duration">
44
-<div class="counter">0.163s</div>
44
+<div class="counter">0.169s</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.163s</td>
79
+<td class="success">0.169s</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 à 11:48:15</p>
92
+<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 12:05:19</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.037s</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">Item and player</td>
86 86
 <td class="success">testBuySell()</td>
87
-<td class="success">0.002s</td>
87
+<td class="success">0.003s</td>
88 88
 <td class="success">passed</td>
89 89
 </tr>
90 90
 <tr>
... ...
@@ -96,7 +96,7 @@
96 96
 <tr>
97 97
 <td class="success">Item tests</td>
98 98
 <td class="success">testItem()</td>
99
-<td class="success">0.010s</td>
99
+<td class="success">0.009s</td>
100 100
 <td class="success">passed</td>
101 101
 </tr>
102 102
 <tr>
... ...
@@ -108,7 +108,7 @@
108 108
 <tr>
109 109
 <td class="success">majDeFinDeTour</td>
110 110
 <td class="success">testMajFinTour()</td>
111
-<td class="success">0.003s</td>
111
+<td class="success">0.002s</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">Natural Tests</td>
122 122
 <td class="success">testNatural()</td>
123
-<td class="success">0.004s</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">Constructor Player</td>
128 128
 <td class="success">testPlayerConstructor()</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>
... ...
@@ -157,7 +157,7 @@
157 157
 <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
158 158
 </label>
159 159
 </div>Generated by 
160
-<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 11:48:15</p>
160
+<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 12:05:19</p>
161 161
 </div>
162 162
 </div>
163 163
 </body>
... ...
@@ -38,7 +38,7 @@
38 38
 </td>
39 39
 <td>
40 40
 <div class="infoBox" id="duration">
41
-<div class="counter">0.200s</div>
41
+<div class="counter">0.205s</div>
42 42
 <p>duration</p>
43 43
 </div>
44 44
 </td>
... ...
@@ -85,7 +85,7 @@
85 85
 <td>13</td>
86 86
 <td>0</td>
87 87
 <td>0</td>
88
-<td>0.200s</td>
88
+<td>0.205s</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.163s</td>
115
+<td>0.169s</td>
116 116
 <td class="success">100%</td>
117 117
 </tr>
118 118
 <tr>
... ...
@@ -122,7 +122,7 @@
122 122
 <td>12</td>
123 123
 <td>0</td>
124 124
 <td>0</td>
125
-<td>0.037s</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 13 déc. 2024 à 11:48:15</p>
139
+<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 12:05:19</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.200s</div>
43
+<div class="counter">0.205s</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.163s</td>
86
+<td>0.169s</td>
87 87
 <td class="success">100%</td>
88 88
 </tr>
89 89
 <tr>
... ...
@@ -93,7 +93,7 @@
93 93
 <td>12</td>
94 94
 <td>0</td>
95 95
 <td>0</td>
96
-<td>0.037s</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 13 déc. 2024 à 11:48:15</p>
109
+<a href="http://www.gradle.org">Gradle 8.8</a> at 13 déc. 2024 à 12:05:19</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-13T10:48:15" hostname="clement-G551JM" time="0.163">
2
+<testsuite name="re.forestier.edu.GlobalTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2024-12-13T11:05:19" hostname="clement-G551JM" time="0.169">
3 3
   <properties/>
4
-  <testcase name="testAffichageBase()" classname="re.forestier.edu.GlobalTest" time="0.163"/>
4
+  <testcase name="testAffichageBase()" classname="re.forestier.edu.GlobalTest" time="0.169"/>
5 5
   <system-out><![CDATA[]]></system-out>
6 6
   <system-err><![CDATA[]]></system-err>
7 7
 </testsuite>
... ...
@@ -1,17 +1,17 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
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">
2
+<testsuite name="re.forestier.edu.UnitTests" tests="12" skipped="0" failures="0" errors="0" timestamp="2024-12-13T11:05:19" hostname="clement-G551JM" time="0.049">
3 3
   <properties/>
4
-  <testcase name="Item tests" classname="re.forestier.edu.UnitTests" time="0.01"/>
4
+  <testcase name="Item tests" classname="re.forestier.edu.UnitTests" time="0.009"/>
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.008"/>
7 7
   <testcase name="ex &amp; lvl" classname="re.forestier.edu.UnitTests" time="0.003"/>
8 8
   <testcase name="addMoney" classname="re.forestier.edu.UnitTests" time="0.001"/>
9 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"/>
10
+  <testcase name="Item and player" classname="re.forestier.edu.UnitTests" time="0.003"/>
11 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"/>
14
-  <testcase name="Natural Tests" classname="re.forestier.edu.UnitTests" time="0.004"/>
12
+  <testcase name="majDeFinDeTour" classname="re.forestier.edu.UnitTests" time="0.002"/>
13
+  <testcase name="Constructor Player" classname="re.forestier.edu.UnitTests" time="0.002"/>
14
+  <testcase name="Natural Tests" classname="re.forestier.edu.UnitTests" time="0.003"/>
15 15
   <testcase name="Sample test" classname="re.forestier.edu.UnitTests" time="0.001"/>
16 16
   <system-out><![CDATA[]]></system-out>
17 17
   <system-err><![CDATA[]]></system-err>
... ...
@@ -1,5 +1,10 @@
1 1
 package re.forestier.edu.rpg;
2 2
 
3
+import java.io.File;  
4
+import java.io.IOException;  
5
+import java.io.FileWriter; 
6
+
7
+
3 8
 public class Affichage {
4 9
 
5 10
     public static void afficherJoueur(Player player) 
... ...
@@ -7,4 +12,33 @@ public class Affichage {
7 12
         System.out.println(player.toString());
8 13
     }
9 14
 
15
+    public static void playerToMarkDown(Player p)
16
+    {
17
+        try 
18
+        {
19
+            File playerFile = new File("./"+p.getAvatarName()+".md");
20
+            FileWriter myWriter = new FileWriter(playerFile);
21
+            myWriter.write(p.toMarkDown());
22
+            myWriter.close();
23
+        } catch (IOException e) 
24
+        {
25
+            System.err.println("An error occurred.");
26
+            e.printStackTrace();
27
+        }
28
+    }
29
+
30
+    public static void playerToMarkDown(Player p, String path)
31
+    {
32
+        try 
33
+        {
34
+            File playerFile = new File(path+p.getAvatarName()+".md");
35
+            FileWriter myWriter = new FileWriter(playerFile);
36
+            myWriter.write(p.toMarkDown());
37
+            myWriter.close();
38
+        } catch (IOException e) 
39
+        {
40
+            System.err.println("An error occurred.");
41
+            e.printStackTrace();
42
+        }
43
+    }
10 44
 }
... ...
@@ -265,4 +265,33 @@ public class Player {
265 265
         });
266 266
         return sb.toString();
267 267
     }
268
+
269
+    public String toMarkDown()
270
+    {
271
+        StringBuilder sb = new StringBuilder("#Joueur ");
272
+        sb.append(this.avatarName);
273
+        sb.append("#\n**Joué par ");
274
+        sb.append(this.playerName);
275
+        sb.append("**\n**Niveau : ");
276
+        sb.append(this.level.toInt());
277
+        sb.append("** (XP totale : ");
278
+        sb.append(this.xp);
279
+        sb.append(")\n\n##Capacités :##");
280
+
281
+        ArrayList<Ability> abilitiesKey = new ArrayList<Ability>(this.abilities.keySet());
282
+        Collections.sort(abilitiesKey);
283
+        for(Ability a : abilitiesKey)
284
+        {
285
+            if(this.abilities.get(a) != 0)
286
+            {
287
+                sb.append("\n*" + a.toString() + " : " + this.abilities.get(a));
288
+            } 
289
+        } 
290
+
291
+        sb.append("\n\n##Inventaire :##");
292
+        this.inventory.forEach(item -> {
293
+            sb.append("\n*" + item);
294
+        });
295
+        return sb.toString();
296
+    }
268 297
 }
269 298
\ No newline at end of file
270 299