-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaventure.html
More file actions
385 lines (383 loc) · 29.5 KB
/
aventure.html
File metadata and controls
385 lines (383 loc) · 29.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aventure Mystérieuse - Jeux de Benny</title>
<link rel="stylesheet" href="main.css">
<script src="admin-commun.js"></script>
<style>
body { background: #0f172a; }
.game-wrapper { max-width: 1100px; margin: 40px auto; padding: 0 20px; }
.game-title { text-align:center; font-size:2.4rem; font-weight:900; background:linear-gradient(135deg,#60a5fa,#a78bfa); -webkit-background-clip:text; -webkit-text-fill-color:transparent; margin-bottom:10px; }
.game-subtitle { text-align:center; color:#94a3b8; margin-bottom:30px; }
.stats-bar { display:flex; gap:12px; justify-content:center; flex-wrap:wrap; margin-bottom:20px; }
.stat-chip { background:rgba(96,165,250,0.12); border:2px solid #60a5fa; border-radius:30px; padding:7px 18px; font-weight:800; font-size:0.9rem; color:#e2e8f0; display:flex; align-items:center; gap:5px; }
.stat-chip.danger { border-color:#10b981; }
.stat-chip.gold { border-color:#f59e0b; background:rgba(245,158,11,0.12); }
.stat-chip.xp { border-color:#10b981; background:rgba(16,185,129,0.12); }
.game-layout { display:grid; grid-template-columns:1fr 360px; gap:18px; align-items:start; }
.map-panel { background:linear-gradient(135deg,#1e293b,#0f172a); border:2px solid #60a5fa; border-radius:20px; padding:22px; }
.map-title { color:#60a5fa; font-weight:800; font-size:0.95rem; margin-bottom:14px; text-align:center; letter-spacing:1px; }
#gameMap { display:grid; gap:3px; margin:0 auto; width:fit-content; }
.map-row { display:flex; gap:3px; }
.map-cell { width:54px; height:54px; border-radius:9px; display:flex; align-items:center; justify-content:center; font-size:1.45rem; transition:all 0.2s; user-select:none; }
.map-cell.wall { background:#0d1b2a; border:1px solid #1a2744; cursor:not-allowed; }
.map-cell.fog { background:#080f1e; border:1px solid #0d1625; cursor:default; color:#1a2744; font-size:1rem; }
.map-cell.floor { background:rgba(96,165,250,0.06); border:1px solid #1e3a5a; cursor:pointer; }
.map-cell.floor:hover { background:rgba(96,165,250,0.2); border-color:#60a5fa; transform:scale(1.08); }
.map-cell.player { background:rgba(96,165,250,0.28); border:2px solid #60a5fa; box-shadow:0 0 14px #60a5fa88; cursor:default; }
.map-cell.visited { background:rgba(96,165,250,0.03); border:1px solid #1e3a5a33; cursor:pointer; }
.map-cell.visited:hover { background:rgba(96,165,250,0.1); }
.map-cell.chest { background:rgba(245,158,11,0.15); border-color:#f59e0b; cursor:pointer; }
.map-cell.chest:hover { background:rgba(245,158,11,0.28); transform:scale(1.08); }
.map-cell.enemy { background:rgba(239,68,68,0.15); border-color:#ef4444; cursor:pointer; }
.map-cell.enemy:hover { background:rgba(239,68,68,0.28); transform:scale(1.08); }
.map-cell.exit-tile { background:rgba(16,185,129,0.2); border-color:#10b981; box-shadow:0 0 10px #10b98155; cursor:pointer; }
.map-cell.heal-tile { background:rgba(167,139,250,0.15); border-color:#a78bfa; cursor:pointer; }
.map-cell.heal-tile:hover { background:rgba(167,139,250,0.28); transform:scale(1.08); }
.map-cell.scroll-tile { background:rgba(96,165,250,0.12); border-color:#60a5fa; cursor:pointer; }
.map-cell.altar-tile { background:rgba(236,72,153,0.15); border-color:#ec4899; cursor:pointer; }
.controls { display:grid; grid-template-columns:repeat(3,1fr); gap:7px; width:155px; margin:14px auto 0; }
.ctrl-btn { background:rgba(96,165,250,0.15); border:2px solid #60a5fa; border-radius:9px; color:#e2e8f0; font-size:1.2rem; width:48px; height:48px; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:all 0.15s; }
.ctrl-btn:hover { background:rgba(96,165,250,0.35); transform:scale(1.08); }
.ctrl-btn:active { transform:scale(0.93); }
.ctrl-center { background:transparent; border-color:transparent; color:#94a3b8; font-size:0.9rem; width:48px; height:48px; display:flex; align-items:center; justify-content:center; }
.legend { display:flex; flex-wrap:wrap; gap:8px; margin-top:11px; justify-content:center; }
.legend-item { display:flex; align-items:center; gap:4px; font-size:0.75rem; color:#94a3b8; }
.side-panel { display:flex; flex-direction:column; gap:14px; }
.story-panel { background:linear-gradient(135deg,#1e293b,#0f172a); border:2px solid #a78bfa; border-radius:15px; padding:18px; min-height:150px; }
.story-panel h3 { color:#a78bfa; font-size:0.9rem; font-weight:800; margin-bottom:9px; letter-spacing:1px; }
#storyText { color:#cbd5e1; font-size:0.92rem; line-height:1.7; }
.choices-panel { background:linear-gradient(135deg,#1e293b,#0f172a); border:2px solid #60a5fa; border-radius:15px; padding:18px; }
.choices-panel h3 { color:#60a5fa; font-size:0.9rem; font-weight:800; margin-bottom:11px; letter-spacing:1px; }
#choicesContainer { display:flex; flex-direction:column; gap:7px; }
.choice-btn { background:linear-gradient(135deg,#60a5fa,#3b82f6); color:white; border:none; border-radius:9px; padding:10px 14px; font-weight:700; font-size:0.86rem; cursor:pointer; transition:all 0.2s; text-align:left; line-height:1.4; }
.choice-btn:hover { background:linear-gradient(135deg,#3b82f6,#1d4ed8); transform:translateX(4px); }
.choice-btn.dbtn { background:linear-gradient(135deg,#ef4444,#dc2626); }
.choice-btn.sbtn { background:linear-gradient(135deg,#10b981,#059669); }
.choice-btn.wbtn { background:linear-gradient(135deg,#f59e0b,#d97706); color:#1e293b; }
.inv-panel { background:linear-gradient(135deg,#1e293b,#0f172a); border:2px solid #334155; border-radius:15px; padding:16px; }
.inv-panel h3 { color:#94a3b8; font-size:0.85rem; font-weight:800; margin-bottom:9px; letter-spacing:1px; }
#inventoryList { display:flex; flex-wrap:wrap; gap:7px; min-height:34px; }
.inv-item { background:rgba(96,165,250,0.12); border:1px solid #60a5fa; border-radius:7px; padding:4px 11px; font-size:0.8rem; color:#e2e8f0; font-weight:600; }
.log-panel { background:linear-gradient(135deg,#1e293b,#0f172a); border:2px solid #1e293b; border-radius:15px; padding:14px; max-height:125px; overflow-y:auto; }
.log-panel h3 { color:#64748b; font-size:0.82rem; font-weight:800; margin-bottom:7px; }
.log-entry { font-size:0.8rem; color:#64748b; padding:2px 0; border-bottom:1px solid #0f172a; }
.log-entry.sl { color:#10b981; } .log-entry.dl { color:#ef4444; } .log-entry.il { color:#60a5fa; }
#gameOverScreen { position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,0.9); display:none; align-items:center; justify-content:center; z-index:9999; }
#gameOverScreen.show { display:flex; }
.go-box { background:linear-gradient(135deg,#1e293b,#0f172a); border-radius:22px; padding:50px 55px; text-align:center; max-width:480px; }
.go-box.victory { border:3px solid #10b981; box-shadow:0 0 40px #10b98155; }
.go-box.defeat { border:3px solid #ef4444; box-shadow:0 0 40px #ef444455; }
.go-box h2 { font-size:2rem; margin-bottom:14px; }
.go-box p { color:#94a3b8; margin-bottom:22px; font-size:0.95rem; }
.restart-btn { background:linear-gradient(135deg,#60a5fa,#3b82f6); color:white; border:none; border-radius:11px; padding:13px 38px; font-size:1rem; font-weight:800; cursor:pointer; transition:all 0.3s; }
.restart-btn:hover { background:linear-gradient(135deg,#3b82f6,#1d4ed8); transform:translateY(-2px); }
#startScreen { background:linear-gradient(135deg,#1e293b,#0f172a); border:2px solid #60a5fa; border-radius:20px; padding:55px 40px; text-align:center; max-width:600px; margin:70px auto; }
#startScreen h2 { font-size:2.4rem; font-weight:900; background:linear-gradient(135deg,#60a5fa,#a78bfa); -webkit-background-clip:text; -webkit-text-fill-color:transparent; margin-bottom:18px; }
#startScreen p { color:#94a3b8; margin-bottom:25px; font-size:1rem; line-height:1.8; }
.diff-select { display:flex; gap:11px; justify-content:center; margin-bottom:24px; flex-wrap:wrap; }
.diff-btn { padding:9px 20px; border-radius:10px; border:2px solid #334155; background:transparent; color:#94a3b8; font-weight:700; cursor:pointer; transition:all 0.2s; font-size:0.95rem; }
.diff-btn.active { border-color:#60a5fa; color:#60a5fa; background:rgba(96,165,250,0.1); }
.start-btn { background:linear-gradient(135deg,#60a5fa,#3b82f6); color:white; border:none; border-radius:13px; padding:15px 48px; font-size:1.1rem; font-weight:800; cursor:pointer; transition:all 0.3s; }
.start-btn:hover { transform:translateY(-3px); box-shadow:0 15px 35px rgba(96,165,250,0.4); }
@media(max-width:900px) { .game-layout{grid-template-columns:1fr;} .map-cell{width:42px;height:42px;font-size:1.1rem;} }
@media(max-width:500px) { .map-cell{width:33px;height:33px;font-size:0.9rem;} }
</style>
</head>
<body>
<header>
<div class="header-content">
<h1>🎮 Jeux de Benny</h1>
<p class="tagline">Plateforme de Jeux Interactifs Premium</p>
</div>
<nav>
<ul>
<li><a href="page.html">Accueil</a></li>
<li><a href="page.html#games">Jeux</a></li>
<li><a href="classement_aventure.html">Classement</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="connexion.html">Mon Compte</a></li>
</ul>
</nav>
</header>
<main>
<div class="game-wrapper">
<h1 class="game-title">🗝️ Aventure Mystérieuse</h1>
<p class="game-subtitle">Explorez le donjon, trouvez les trésors, survivez aux dangers</p>
<div id="startScreen">
<h2>🗝️ Aventure Mystérieuse</h2>
<p>Vous vous réveillez dans un <strong>donjon sombre et mystérieux</strong>.<br>
Explorez la carte, trouvez des trésors 💰, combattez des ennemis ⚔️,<br>
et atteignez la sortie 🚪 pour remporter la victoire !<br><br>
Utilisez les <strong>flèches ↑↓←→ ou WASD</strong> pour vous déplacer.<br>
⚠️ Brouillard de guerre — explorez pour révéler la carte !</p>
<div class="diff-select">
<button class="diff-btn active" data-diff="easy" onclick="selectDiff(this)">🌟 Facile</button>
<button class="diff-btn" data-diff="normal" onclick="selectDiff(this)">⚔️ Normal</button>
<button class="diff-btn" data-diff="hard" onclick="selectDiff(this)">💀 Difficile</button>
</div>
<button class="start-btn" onclick="startGame()">🚀 Commencer l'Aventure</button>
</div>
<div id="gameMain" style="display:none;">
<div class="stats-bar">
<div class="stat-chip danger" id="chipHp">❤️ <span id="statHp">100</span>/<span id="statMaxHp">100</span></div>
<div class="stat-chip gold">💰 <span id="statGold">0</span></div>
<div class="stat-chip xp">⭐ Niv.<span id="statLevel">1</span></div>
<div class="stat-chip">⚔️<span id="statAtk">10</span></div>
<div class="stat-chip">🛡️<span id="statDef">5</span></div>
<div class="stat-chip" id="chipSteps" style="display:none;">⏳<span id="statSteps">80</span></div>
</div>
<div class="game-layout">
<div class="map-panel">
<div class="map-title">🗺️ CARTE DU DONJON</div>
<div id="gameMap"></div>
<div class="controls">
<div></div>
<button class="ctrl-btn" onclick="move(0,-1)">⬆️</button>
<div></div>
<button class="ctrl-btn" onclick="move(-1,0)">⬅️</button>
<div class="ctrl-center">🧭</div>
<button class="ctrl-btn" onclick="move(1,0)">➡️</button>
<div></div>
<button class="ctrl-btn" onclick="move(0,1)">⬇️</button>
<div></div>
</div>
<div class="legend">
<div class="legend-item">🧙 Vous</div>
<div class="legend-item">💰 Coffre</div>
<div class="legend-item">👹 Ennemi</div>
<div class="legend-item">🚪 Sortie</div>
<div class="legend-item">💊 Potion</div>
<div class="legend-item">📜 Parchemin</div>
<div class="legend-item">🏺 Autel</div>
<div class="legend-item">🌫️ Brouillard</div>
</div>
</div>
<div class="side-panel">
<div class="story-panel">
<h3>📖 HISTOIRE</h3>
<div id="storyText">Déplacez-vous pour explorer le donjon...</div>
</div>
<div class="choices-panel">
<h3>⚡ ACTIONS</h3>
<div id="choicesContainer"><p style="color:#94a3b8;font-size:0.88rem;">Approchez-vous d'une case interactive.</p></div>
</div>
<div class="inv-panel">
<h3>🎒 INVENTAIRE</h3>
<div id="inventoryList"><span style="color:#64748b;font-size:0.82rem;">Vide</span></div>
</div>
<div class="log-panel">
<h3>📋 JOURNAL</h3>
<div id="logContainer"></div>
</div>
</div>
</div>
</div>
</div>
</main>
<div id="gameOverScreen">
<div id="goBox" class="go-box">
<h2 id="goTitle"></h2>
<p id="goMsg"></p>
<button class="restart-btn" onclick="restartGame()">🔄 Rejouer</button>
<br><br>
<a href="classement_aventure.html" style="color:#60a5fa;text-decoration:none;font-weight:700;">📊 Voir le classement</a>
</div>
</div>
<script>
var difficulty='easy', GS={}, MAP=[], VIS=[], MW=13, MH=11;
var T={WALL:0,FLOOR:1,CHEST:2,ENEMY:3,EXIT:4,HEAL:5,SCROLL:6,ALTAR:7,VISITED:8};
var DUNGEON=[
[0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,1,1,1,0,1,1,1,0,1,1,1,0],
[0,1,0,1,1,1,0,1,1,1,0,1,0],
[0,1,0,0,0,1,0,0,0,1,0,1,0],
[0,1,1,1,1,1,1,1,1,1,1,1,0],
[0,0,0,1,0,0,1,0,0,1,0,0,0],
[0,1,1,1,1,1,1,1,1,1,1,1,0],
[0,1,0,0,0,1,0,0,0,1,0,1,0],
[0,1,0,1,1,1,0,1,1,1,0,1,0],
[0,1,1,1,0,1,1,1,0,1,1,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0]
];
function selectDiff(btn){document.querySelectorAll('.diff-btn').forEach(b=>b.classList.remove('active'));btn.classList.add('active');difficulty=btn.dataset.diff;}
function startGame(){document.getElementById('startScreen').style.display='none';document.getElementById('gameMain').style.display='block';initGame();}
function restartGame(){document.getElementById('gameOverScreen').classList.remove('show');document.getElementById('gameMain').style.display='none';document.getElementById('startScreen').style.display='block';}
function initGame(){
var hp=difficulty==='easy'?150:difficulty==='hard'?70:100;
var atk=difficulty==='easy'?15:difficulty==='hard'?8:10;
var def=difficulty==='easy'?8:difficulty==='hard'?3:5;
GS={x:1,y:1,hp:hp,maxHp:hp,gold:0,level:1,atk:atk,def:def,xp:0,xpN:50,inventory:[],steps:80,kills:0};
MAP=DUNGEON.map(r=>[...r]);
var floors=[];
for(var y=0;y<MH;y++)for(var x=0;x<MW;x++)if(MAP[y][x]===T.FLOOR&&!(x===1&&y===1))floors.push({x:x,y:y});
for(var i=floors.length-1;i>0;i--){var j=Math.floor(Math.random()*(i+1));var tmp=floors[i];floors[i]=floors[j];floors[j]=tmp;}
var exitDone=false;
for(var k=0;k<floors.length;k++){if(Math.abs(floors[k].x-1)+Math.abs(floors[k].y-1)>8){MAP[floors[k].y][floors[k].x]=T.EXIT;exitDone=true;break;}}
if(!exitDone)MAP[9][11]=T.EXIT;
var items=[T.CHEST,T.CHEST,T.CHEST,T.CHEST,T.ENEMY,T.ENEMY,T.ENEMY,T.ENEMY,T.ENEMY,T.HEAL,T.HEAL,T.SCROLL,T.SCROLL,T.ALTAR];
var pi=0;
for(var k=0;k<floors.length&&pi<items.length;k++){if(MAP[floors[k].y][floors[k].x]===T.FLOOR){MAP[floors[k].y][floors[k].x]=items[pi++];}}
VIS=[];for(var y=0;y<MH;y++){VIS.push([]);for(var x=0;x<MW;x++)VIS[y].push(false);}
updateVis();renderMap();updateStats();
addLog('🗺️ Vous entrez dans le donjon des ombres...','il');
setStory('🌫️ <strong>Le Donjon des Ombres</strong><br><br>Vous vous réveillez dans une salle froide. Des torches vacillent. Explorez et trouvez la sortie !');
if(difficulty==='hard')document.getElementById('chipSteps').style.display='flex'; else document.getElementById('chipSteps').style.display='none';
}
function updateVis(){var x=GS.x,y=GS.y,r=3;for(var dy=-r;dy<=r;dy++)for(var dx=-r;dx<=r;dx++){var nx=x+dx,ny=y+dy;if(nx>=0&&nx<MW&&ny>=0&&ny<MH&&Math.abs(dx)+Math.abs(dy)<=r+1)VIS[ny][nx]=true;}}
function getCellClass(tile,vis,isPlayer){
if(!vis)return'map-cell fog';
if(isPlayer)return'map-cell player';
var map={0:'map-cell wall',1:'map-cell floor',2:'map-cell chest floor',3:'map-cell enemy floor',4:'map-cell exit-tile floor',5:'map-cell heal-tile floor',6:'map-cell scroll-tile floor',7:'map-cell altar-tile floor',8:'map-cell visited'};
return map[tile]||'map-cell floor';
}
function getCellEmoji(tile,vis,isPlayer){
if(!vis)return'🌫️';
if(isPlayer)return'🧙';
var map={0:'⬛',1:'',2:'💰',3:'👹',4:'🚪',5:'💊',6:'📜',7:'🏺',8:''};
return map[tile]||'';
}
function renderMap(){
var el=document.getElementById('gameMap');el.innerHTML='';
for(var y=0;y<MH;y++){var row=document.createElement('div');row.className='map-row';
for(var x=0;x<MW;x++){var cell=document.createElement('div');var tile=MAP[y][x];var vis=VIS[y][x];var isP=(x===GS.x&&y===GS.y);
cell.className=getCellClass(tile,vis,isP);cell.innerHTML=getCellEmoji(tile,vis,isP);
if(vis&&tile!==T.WALL&&!isP){(function(cx,cy){cell.onclick=function(){tryMoveTo(cx,cy);};})(x,y);}
row.appendChild(cell);}
el.appendChild(row);}
}
function tryMoveTo(tx,ty){var dx=tx-GS.x,dy=ty-GS.y;if(Math.abs(dx)+Math.abs(dy)===1)move(dx,dy);}
function move(dx,dy){
var nx=GS.x+dx,ny=GS.y+dy;
if(nx<0||nx>=MW||ny<0||ny>=MH)return;
var tile=MAP[ny][nx];
if(tile===T.WALL){addLog('🧱 Mur !','');return;}
GS.x=nx;GS.y=ny;
if(difficulty==='hard'){GS.steps--;document.getElementById('statSteps').textContent=GS.steps;if(GS.steps<=0){showGO(false,'⏰ Temps épuisé dans le donjon !');return;}}
updateVis();triggerTile(tile,nx,ny);updateStats();renderMap();
}
function triggerTile(tile,x,y){
clearChoices();
if(tile===T.FLOOR||tile===T.VISITED){setStory('👣 Vous avancez prudemment...');return;}
if(tile===T.EXIT){
setStory('🚪 <strong>LA SORTIE !</strong><br><br>La grande porte de sortie du donjon ! La lumière du jour brille au loin !');
addChoice('🎉 Sortir et remporter la victoire !',function(){var score=GS.gold*10+GS.level*100+GS.kills*50;saveScore(score);showGO(true,'🏆 Score: '+score+' pts');},'sbtn');
addChoice('🔍 Explorer encore',function(){setStory('Vous hésitez... peut-être d\'autres trésors ?');clearChoices();});
return;
}
if(tile===T.CHEST){
var gold=Math.floor(Math.random()*150)+50;
var items=['🗡️ Épée Acérée','🛡️ Bouclier Solide','💍 Anneau Magique','🧪 Potion Rare','📿 Amulette du Mage'];
var item=items[Math.floor(Math.random()*items.length)];
setStory('💰 <strong>COFFRE AU TRÉSOR !</strong><br><br>Un vieux coffre cerclé de fer. Il semble lourd...');
addChoice('💰 Prendre l\'or (+'+gold+')',function(){GS.gold+=gold;MAP[y][x]=T.VISITED;addLog('💰 +'+gold+' or !','sl');setStory('✅ Vous avez pris '+gold+' pièces d\'or !');clearChoices();gainXP(20);updateStats();renderMap();},'wbtn');
addChoice('🎁 Chercher un objet ('+item+')',function(){GS.gold+=Math.floor(gold/2);addItem(item);MAP[y][x]=T.VISITED;addLog('🎁 '+item+' !','sl');setStory('✅ '+item+' + '+Math.floor(gold/2)+' or !');clearChoices();gainXP(30);updateStats();renderMap();});
addChoice('❌ Laisser (peut-être piégé)',function(){setStory('Vous passez votre chemin prudemment.');clearChoices();});
return;
}
if(tile===T.ENEMY){
var enemies=[
{name:'🐀 Rat Géant',hp:20,atk:5,gold:15,xp:25},
{name:'💀 Squelette',hp:35,atk:10,gold:30,xp:40},
{name:'👺 Gobelin',hp:28,atk:8,gold:22,xp:32},
{name:'🧟 Zombie',hp:45,atk:13,gold:40,xp:55},
{name:'🐉 Mini Dragon',hp:60,atk:20,gold:80,xp:80},
{name:'🕷️ Araignée Géante',hp:18,atk:7,gold:12,xp:20},
];
var e=enemies[Math.floor(Math.random()*enemies.length)];
setStory('⚔️ <strong>COMBAT !</strong><br><br><strong>'+e.name+'</strong> surgit de l\'ombre !<br>PV: '+e.hp+' | ATK: '+e.atk);
addChoice('⚔️ Attaquer !',function(){doCombat(e,x,y);});
addChoice('✨ Magie (objet requis)',function(){
var hasMagic=GS.inventory.indexOf('📿 Amulette du Mage')!==-1||GS.inventory.indexOf('💍 Anneau Magique')!==-1;
if(hasMagic){var dmg=GS.atk*2;e.hp-=dmg;addLog('✨ Magie ! -'+dmg+' PV','sl');if(e.hp<=0)killEnemy(e,x,y);else{setStory('✨ '+e.name+' : '+e.hp+' PV restants.');clearChoices();addChoice('⚔️ Continuer',function(){doCombat(e,x,y);});addChoice('🏃 Fuir',function(){flee();});}}
else{addLog('❌ Pas d\'objet magique !','dl');setStory('❌ Vous manquez d\'objet magique !');clearChoices();addChoice('⚔️ Attaquer !',function(){doCombat(e,x,y);});addChoice('🏃 Fuir',function(){flee();});}
});
addChoice('🏃 Fuir',function(){flee();});
return;
}
if(tile===T.HEAL){
var h=Math.floor(Math.random()*30)+20;
setStory('💊 <strong>POTION DE SOIN</strong><br><br>Une fiole lumineuse sur un piédestal de pierre...');
addChoice('💊 Boire maintenant (+'+h+' PV)',function(){GS.hp=Math.min(GS.maxHp,GS.hp+h);MAP[y][x]=T.VISITED;addLog('💊 +'+h+' PV !','sl');setStory('✅ Vous vous sentez ragaillardi ! +'+h+' PV.');clearChoices();updateStats();renderMap();},'sbtn');
addChoice('🎒 Garder pour plus tard',function(){addItem('💊 Potion de Soin');MAP[y][x]=T.VISITED;setStory('Vous rangez la potion.');clearChoices();renderMap();});
return;
}
if(tile===T.SCROLL){
setStory('📜 <strong>PARCHEMIN ANCIEN</strong><br><br>Des runes mystérieuses brillent sur ce vieux parchemin...');
addChoice('📖 Lire le parchemin',function(){
var effs=[
function(){GS.atk+=5;addLog('⚔️ +5 ATK !','sl');return'+5 ATK permanent !';},
function(){GS.def+=3;addLog('🛡️ +3 DEF !','sl');return'+3 DEF permanent !';},
function(){GS.gold+=100;addLog('💰 +100 or !','sl');return'Pluie d\'or magique ! +100 pièces !';},
function(){gainXP(60);addLog('⭐ +60 XP !','sl');return'+60 XP ! Vous progressez !';},
function(){GS.hp=Math.min(GS.maxHp,GS.hp+50);addLog('❤️ +50 PV !','sl');return'Soin magique ! +50 PV !';}
];
var msg=effs[Math.floor(Math.random()*effs.length)]();
MAP[y][x]=T.VISITED;setStory('✨ '+msg);clearChoices();updateStats();renderMap();
},'sbtn');
addChoice('🔥 Brûler (hasard)',function(){
if(Math.random()>0.4){GS.hp-=20;addLog('🔥 -20 PV !','dl');setStory('🔥 Explosion ! -20 PV !');}
else{GS.gold+=200;addLog('💰 +200 or (explosion) !','sl');setStory('💥 Pluie d\'or ! +200 pièces !');}
MAP[y][x]=T.VISITED;if(GS.hp<=0)showGO(false,'Consumé par les flammes...');clearChoices();updateStats();renderMap();
},'dbtn');
return;
}
if(tile===T.ALTAR){
setStory('🏺 <strong>AUTEL MYSTIQUE</strong><br><br>Un autel de pierre gravé de runes lumineuses. Quelle offrande ?');
addChoice('💰 Sacrifier 50 or → Niveau+',function(){
if(GS.gold>=50){GS.gold-=50;levelUp();MAP[y][x]=T.VISITED;addLog('⭐ Niveau par l\'autel !','sl');setStory('✅ Les dieux acceptent ! Vous gagnez en puissance !');clearChoices();updateStats();renderMap();}
else setStory('❌ Pas assez d\'or (besoin: 50 💰)');
},'wbtn');
addChoice('❤️ Sacrifier 30 PV → +8 ATK +5 DEF',function(){
if(GS.hp>35){GS.hp-=30;GS.atk+=8;GS.def+=5;MAP[y][x]=T.VISITED;addLog('⚔️🛡️ +8 ATK +5 DEF !','sl');setStory('✅ Sang versé sur l\'autel... vous devenez plus fort !');clearChoices();updateStats();renderMap();}
else setStory('❌ Trop peu de PV pour ce sacrifice !');
},'dbtn');
addChoice('🚪 Ignorer',function(){setStory('Vous préférez ne pas tenter le sort.');clearChoices();});
return;
}
}
function doCombat(enemy,x,y){
var dmgE=Math.max(1,GS.atk+Math.floor(Math.random()*5)-2);
var dmgP=Math.max(1,enemy.atk-GS.def+Math.floor(Math.random()*4));
enemy.hp-=dmgE;GS.hp-=dmgP;
if(GS.hp<=0){GS.hp=0;showGO(false,'💀 Vous avez été vaincu par '+enemy.name+'...');return;}
if(enemy.hp<=0){killEnemy(enemy,x,y);return;}
addLog('⚔️ -'+dmgE+' ennemi, -'+dmgP+' vous','');
setStory('⚔️ <strong>COMBAT</strong><br><br>'+enemy.name+': '+enemy.hp+' PV<br>Vous: '+GS.hp+'/'+GS.maxHp+' PV<br><br>Vous infligez '+dmgE+'. Il vous touche pour '+dmgP+'.');
clearChoices();
addChoice('⚔️ Frapper encore !',function(){doCombat(enemy,x,y);});
addChoice('💊 Potion de soin',function(){
var idx=GS.inventory.indexOf('💊 Potion de Soin');
if(idx!==-1){GS.inventory.splice(idx,1);GS.hp=Math.min(GS.maxHp,GS.hp+40);addLog('💊 +40 PV !','sl');updateInventory();doCombat(enemy,x,y);}
else{addLog('❌ Aucune potion !','dl');}
},'sbtn');
addChoice('🏃 Fuir le combat',function(){flee();});
updateStats();
}
function killEnemy(e,x,y){MAP[y][x]=T.VISITED;GS.gold+=e.gold;GS.kills++;gainXP(e.xp);addLog('✅ '+e.name+' vaincu ! +'+e.gold+' or +'+e.xp+' XP','sl');setStory('🏆 <strong>'+e.name+' vaincu !</strong><br><br>+'+e.gold+' or, +'+e.xp+' XP');clearChoices();updateStats();renderMap();}
function flee(){var pen=Math.floor(Math.random()*15)+5;GS.hp-=pen;var dirs=[[-1,0],[1,0],[0,-1],[0,1]].sort(function(){return Math.random()-0.5;});for(var i=0;i<dirs.length;i++){var nx=GS.x+dirs[i][0],ny=GS.y+dirs[i][1];if(nx>=0&&nx<MW&&ny>=0&&ny<MH&&MAP[ny][nx]!==T.WALL){GS.x=nx;GS.y=ny;break;}}if(GS.hp<=0){showGO(false,'Fui, mais vos blessures vous ont emporté...');return;}addLog('🏃 Fuite ! -'+pen+' PV','dl');setStory('🏃 Fuite en catastrophe ! -'+pen+' PV');clearChoices();updateVis();updateStats();renderMap();}
function gainXP(a){GS.xp+=a;while(GS.xp>=GS.xpN)levelUp();}
function levelUp(){GS.level++;GS.xp-=GS.xpN;GS.xpN=Math.floor(GS.xpN*1.5);GS.maxHp+=20;GS.hp=Math.min(GS.maxHp,GS.hp+20);GS.atk+=3;GS.def+=2;addLog('⭐ NIVEAU '+GS.level+' ! +20 PV, +3 ATK, +2 DEF','il');}
function addItem(item){GS.inventory.push(item);updateInventory();}
function updateInventory(){var el=document.getElementById('inventoryList');if(GS.inventory.length===0){el.innerHTML='<span style="color:#64748b;font-size:0.82rem;">Vide</span>';}else{el.innerHTML=GS.inventory.map(function(i){return'<span class="inv-item">'+i+'</span>';}).join('');}}
function updateStats(){
document.getElementById('statHp').textContent=GS.hp;document.getElementById('statMaxHp').textContent=GS.maxHp;
document.getElementById('statGold').textContent=GS.gold;document.getElementById('statLevel').textContent=GS.level;
document.getElementById('statAtk').textContent=GS.atk;document.getElementById('statDef').textContent=GS.def;
if(GS.hp<GS.maxHp*0.3)document.getElementById('chipHp').style.borderColor='#ef4444';
else if(GS.hp<GS.maxHp*0.6)document.getElementById('chipHp').style.borderColor='#f59e0b';
else document.getElementById('chipHp').style.borderColor='#10b981';
if(difficulty==='hard')document.getElementById('statSteps').textContent=GS.steps;
}
function setStory(html){document.getElementById('storyText').innerHTML=html;}
function clearChoices(){document.getElementById('choicesContainer').innerHTML='';}
function addChoice(text,fn,cls){var btn=document.createElement('button');btn.className='choice-btn '+(cls||'');btn.innerHTML=text;btn.onclick=fn;document.getElementById('choicesContainer').appendChild(btn);}
function addLog(msg,type){var log=document.getElementById('logContainer');var e=document.createElement('div');e.className='log-entry '+(type||'');e.textContent=msg;log.insertBefore(e,log.firstChild);while(log.children.length>20)log.removeChild(log.lastChild);}
function saveScore(score){try{var user=JSON.parse(localStorage.getItem('currentUser')||'{}');var scores=JSON.parse(localStorage.getItem('scores_aventure')||'[]');scores.push({username:user.username||'Aventurier',score:score,date:new Date().toLocaleDateString('fr-FR'),kills:GS.kills,gold:GS.gold});scores.sort(function(a,b){return b.score-a.score;});localStorage.setItem('scores_aventure',JSON.stringify(scores.slice(0,50)));}catch(e){}}
function showGO(victory,msg){var screen=document.getElementById('gameOverScreen');var box=document.getElementById('goBox');box.className='go-box '+(victory?'victory':'defeat');document.getElementById('goTitle').textContent=victory?'🏆 Victoire !':'💀 Défaite !';document.getElementById('goMsg').innerHTML=msg+'<br><br>🌟 Niv.'+GS.level+' | 💰 '+GS.gold+' or | ⚔️ '+GS.kills+' victoires';screen.classList.add('show');}
document.addEventListener('keydown',function(e){if(document.getElementById('gameMain').style.display==='none')return;var m={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],w:[0,-1],s:[0,1],a:[-1,0],d:[1,0]};var d=m[e.key];if(d){e.preventDefault();move(d[0],d[1]);}});
</script>
</body>
</html>