Cristiano Magro
2024-12-27 efa2e3cc901d8e30d9c2f0e58201d2f5addc9786
commit | author | age
14370b 1 <!DOCTYPE html>
CM 2 <html lang="en">
3   <head>
4     <meta charset="UTF-8" />
5     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6     <title>Vue Basics</title>
7     <link
8       href="https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap"
9       rel="stylesheet"
10     />
11     <link rel="stylesheet" href="styles.css" />
4a01d9 12     <script src="https://unpkg.com/vue@3.4.9/dist/vue.global.js"></script>
14370b 13     <script src="app.js" defer></script>
CM 14   </head>
15   <body>
16     <header>
17       <h1>Monster Slayer</h1>
18     </header>
19     <div id="game">
20       <section id="monster" class="container">
21         <h2>Monster Health</h2>
22         <div class="healthbar">
5529c7 23           <div class="healthbar__value" :style="monsterBarStyle"></div>
14370b 24         </div>
CM 25       </section>
26       <section id="player" class="container">
27         <h2>Your Health</h2>
28         <div class="healthbar">
5529c7 29           <div class="healthbar__value" :style="playerBarStyle"></div>
14370b 30         </div>
CM 31       </section>
807972 32       <section class="container" v-if="winner">
CM 33         <h2>Game Over!</h2>
08ed40 34         <h3 v-if="winner === 'monster'">You lost!</h3>
CM 35         <h3 v-else-if="winner === 'player'">You won!</h3>
807972 36         <h3 v-else>It's a Draw</h3>
08ed40 37         <button @click="startGame">Start new game</button>
807972 38       </section>
08ed40 39       <section id="controls" v-else>
8c672a 40         <button @click="attackMonster">ATTACK</button>
5529c7 41         <button @click="specialAttackMonster" :disabled="mayUseSpecialAttack">
CM 42           SPECIAL ATTACK
43         </button>
02ffa3 44         <button @click="healPlayer">HEAL</button>
08ed40 45         <button @click="surrender">SURRENDER</button>
14370b 46       </section>
CM 47       <section id="log" class="container">
48         <h2>Battle Log</h2>
efa2e3 49         <ul>
CM 50           <li v-for="logMessage in logMessages">
51             <span :class="{'log--player': logMessage.actionBy === 'player' , 'log--monster': logMessage.actionBy === 'monster'}"
52               >{{logMessage.actionBy === 'player' ? "Player" : 'Monster'}}
53             </span>
54             <span v-if="logMessage.actionType === 'heal'"
55               > heal himself for <span class="log--heal">{{logMessage.actionValue}} </span>
56             </span>
57             <span v-else>
58               attacks and deals <span class="log--damage">{{logMessage.actionValue}}</span></span>
59           </li>
60         </ul>
14370b 61       </section>
CM 62     </div>
63   </body>
64 </html>