From 502e3089470d3dd64075ad5690d927e4fe663547 Mon Sep 17 00:00:00 2001 From: Aditi Bansal <142652964+Aditi22Bansal@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:24:55 +0530 Subject: [PATCH 1/4] Create manifest.json --- Slay the Spire/manifest.json | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Slay the Spire/manifest.json diff --git a/Slay the Spire/manifest.json b/Slay the Spire/manifest.json new file mode 100644 index 00000000..9f9c8806 --- /dev/null +++ b/Slay the Spire/manifest.json @@ -0,0 +1,27 @@ +{ + "name": "Card Battle Game", + "short_name": "Card Battle", + "description": "A web-based deck-building roguelike game inspired by Slay the Spire.", + "version": "1.0.0", + "manifest_version": 2, + "start_url": "index.html", + "display": "standalone", + "background_color": "#f5f5f5", + "theme_color": "#ffffff", + "orientation": "portrait", + "icons": [ + { + "src": "icons/icon-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/icon-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "permissions": [ + "storage" + ] +} From fb156fea5d189edb795d4544558d45d53724080f Mon Sep 17 00:00:00 2001 From: Aditi Bansal <142652964+Aditi22Bansal@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:25:21 +0530 Subject: [PATCH 2/4] Create index.html --- Slay the Spire/index.html | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Slay the Spire/index.html diff --git a/Slay the Spire/index.html b/Slay the Spire/index.html new file mode 100644 index 00000000..f5e48a49 --- /dev/null +++ b/Slay the Spire/index.html @@ -0,0 +1,26 @@ + + + + + + + Card Battle Game + + + +
+

Card Battle Game

+
+

Player

+

Health: 50

+
+
+
+

Enemy

+

Health: 30

+
+ +
+ + + From 50b0713329b517e100c997c25d4b4b08b1b07c27 Mon Sep 17 00:00:00 2001 From: Aditi Bansal <142652964+Aditi22Bansal@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:25:49 +0530 Subject: [PATCH 3/4] Create styles.css --- Slay the Spire/styles.css | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Slay the Spire/styles.css diff --git a/Slay the Spire/styles.css b/Slay the Spire/styles.css new file mode 100644 index 00000000..e6134db5 --- /dev/null +++ b/Slay the Spire/styles.css @@ -0,0 +1,38 @@ + +body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + background-color: #f5f5f5; +} + +.container { + text-align: center; + background-color: #fff; + padding: 20px; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +#player, #enemy { + margin: 20px 0; +} + +#playerDeck { + display: flex; + justify-content: center; + gap: 10px; +} + +.card { + padding: 10px; + border: 1px solid #ccc; + border-radius: 5px; + cursor: pointer; +} + +.card:hover { + background-color: #f0f0f0; +} From c4567a4573e2e872fe6bd8a8961cdd1d388049e9 Mon Sep 17 00:00:00 2001 From: Aditi Bansal <142652964+Aditi22Bansal@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:26:11 +0530 Subject: [PATCH 4/4] Create script.js --- Slay the Spire/script.js | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Slay the Spire/script.js diff --git a/Slay the Spire/script.js b/Slay the Spire/script.js new file mode 100644 index 00000000..90d8dbcd --- /dev/null +++ b/Slay the Spire/script.js @@ -0,0 +1,42 @@ + +document.addEventListener('DOMContentLoaded', () => { + const playerHealthElement = document.getElementById('playerHealth'); + const enemyHealthElement = document.getElementById('enemyHealth'); + const playerDeckElement = document.getElementById('playerDeck'); + const drawCardButton = document.getElementById('drawCardButton'); + + let playerHealth = 50; + let enemyHealth = 30; + + const cards = [ + { name: 'Attack', damage: 10 }, + { name: 'Heal', heal: 10 } + ]; + + function updateHealth() { + playerHealthElement.textContent = `Health: ${playerHealth}`; + enemyHealthElement.textContent = `Health: ${enemyHealth}`; + } + + function drawCard() { + const randomCard = cards[Math.floor(Math.random() * cards.length)]; + const cardElement = document.createElement('div'); + cardElement.classList.add('card'); + cardElement.textContent = randomCard.name; + cardElement.addEventListener('click', () => playCard(randomCard, cardElement)); + playerDeckElement.appendChild(cardElement); + } + + function playCard(card, cardElement) { + if (card.damage) { + enemyHealth -= card.damage; + } else if (card.heal) { + playerHealth += card.heal; + } + updateHealth(); + cardElement.remove(); + } + + drawCardButton.addEventListener('click', drawCard); + updateHealth(); +});