-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2110 from Aditi22Bansal/master
Solved #2089- Slay the spire
- Loading branch information
Showing
4 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Card Battle Game</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Card Battle Game</h1> | ||
<div id="player"> | ||
<h2>Player</h2> | ||
<p id="playerHealth">Health: 50</p> | ||
<div id="playerDeck"></div> | ||
</div> | ||
<div id="enemy"> | ||
<h2>Enemy</h2> | ||
<p id="enemyHealth">Health: 30</p> | ||
</div> | ||
<button id="drawCardButton">Draw Card</button> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |