Spaces:
Running
Running
Update index.html
Browse files- index.html +142 -19
index.html
CHANGED
@@ -1,19 +1,142 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
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>Harmonies Game</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
font-family: Arial, sans-serif;
|
10 |
+
background-color: #f0f8ff;
|
11 |
+
margin: 0;
|
12 |
+
padding: 0;
|
13 |
+
display: flex;
|
14 |
+
flex-direction: column;
|
15 |
+
align-items: center;
|
16 |
+
}
|
17 |
+
h1 {
|
18 |
+
margin-top: 20px;
|
19 |
+
}
|
20 |
+
.game-board {
|
21 |
+
display: grid;
|
22 |
+
grid-template-columns: repeat(6, 60px);
|
23 |
+
gap: 5px;
|
24 |
+
margin-top: 20px;
|
25 |
+
}
|
26 |
+
.tile {
|
27 |
+
width: 60px;
|
28 |
+
height: 60px;
|
29 |
+
background-color: #ccc;
|
30 |
+
display: flex;
|
31 |
+
justify-content: center;
|
32 |
+
align-items: center;
|
33 |
+
border-radius: 5px;
|
34 |
+
cursor: pointer;
|
35 |
+
}
|
36 |
+
.water {
|
37 |
+
background-color: #87ceeb;
|
38 |
+
}
|
39 |
+
.forest {
|
40 |
+
background-color: #228b22;
|
41 |
+
}
|
42 |
+
.grass {
|
43 |
+
background-color: #98fb98;
|
44 |
+
}
|
45 |
+
.score-board {
|
46 |
+
margin-top: 20px;
|
47 |
+
padding: 10px;
|
48 |
+
background-color: #fff;
|
49 |
+
border: 1px solid #ddd;
|
50 |
+
border-radius: 5px;
|
51 |
+
}
|
52 |
+
.animal-card {
|
53 |
+
margin: 10px;
|
54 |
+
padding: 10px;
|
55 |
+
border: 1px solid #ccc;
|
56 |
+
border-radius: 5px;
|
57 |
+
background-color: #fff;
|
58 |
+
cursor: pointer;
|
59 |
+
}
|
60 |
+
</style>
|
61 |
+
</head>
|
62 |
+
<body>
|
63 |
+
<h1>Harmonies Game</h1>
|
64 |
+
|
65 |
+
<div class="game-board" id="gameBoard">
|
66 |
+
<!-- Tiles will be dynamically inserted here -->
|
67 |
+
</div>
|
68 |
+
|
69 |
+
<div class="score-board" id="scoreBoard">
|
70 |
+
<p>Player 1 Score: <span id="player1Score">0</span></p>
|
71 |
+
<p>Player 2 Score: <span id="player2Score">0</span></p>
|
72 |
+
</div>
|
73 |
+
|
74 |
+
<script>
|
75 |
+
// Game data
|
76 |
+
const tileTypes = ['water', 'forest', 'grass'];
|
77 |
+
const animalCards = [
|
78 |
+
{ name: 'Swan', habitat: 'water', points: 5 },
|
79 |
+
{ name: 'Deer', habitat: 'grass', points: 4 },
|
80 |
+
{ name: 'Bear', habitat: 'forest', points: 6 },
|
81 |
+
];
|
82 |
+
|
83 |
+
const board = [];
|
84 |
+
const boardSize = 6;
|
85 |
+
|
86 |
+
// Game state
|
87 |
+
let currentPlayer = 1;
|
88 |
+
const scores = { 1: 0, 2: 0 };
|
89 |
+
|
90 |
+
// Initialize the game board
|
91 |
+
function initBoard() {
|
92 |
+
const gameBoard = document.getElementById('gameBoard');
|
93 |
+
for (let i = 0; i < boardSize * boardSize; i++) {
|
94 |
+
const tile = document.createElement('div');
|
95 |
+
const tileType = tileTypes[Math.floor(Math.random() * tileTypes.length)];
|
96 |
+
tile.classList.add('tile', tileType);
|
97 |
+
tile.dataset.index = i;
|
98 |
+
tile.dataset.type = tileType;
|
99 |
+
tile.addEventListener('click', () => placeAnimal(i));
|
100 |
+
board.push({ type: tileType, animal: null });
|
101 |
+
gameBoard.appendChild(tile);
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
// Handle animal placement
|
106 |
+
function placeAnimal(index) {
|
107 |
+
const tile = board[index];
|
108 |
+
if (tile.animal) {
|
109 |
+
alert('This tile already has an animal!');
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
|
113 |
+
const selectedAnimal = animalCards[Math.floor(Math.random() * animalCards.length)];
|
114 |
+
|
115 |
+
if (selectedAnimal.habitat !== tile.type) {
|
116 |
+
alert(`${selectedAnimal.name} cannot live on ${tile.type} tile!`);
|
117 |
+
return;
|
118 |
+
}
|
119 |
+
|
120 |
+
tile.animal = selectedAnimal;
|
121 |
+
scores[currentPlayer] += selectedAnimal.points;
|
122 |
+
updateScores();
|
123 |
+
switchPlayer();
|
124 |
+
}
|
125 |
+
|
126 |
+
// Update scores
|
127 |
+
function updateScores() {
|
128 |
+
document.getElementById('player1Score').textContent = scores[1];
|
129 |
+
document.getElementById('player2Score').textContent = scores[2];
|
130 |
+
}
|
131 |
+
|
132 |
+
// Switch players
|
133 |
+
function switchPlayer() {
|
134 |
+
currentPlayer = currentPlayer === 1 ? 2 : 1;
|
135 |
+
alert(`Player ${currentPlayer}'s turn!`);
|
136 |
+
}
|
137 |
+
|
138 |
+
// Initialize the game
|
139 |
+
initBoard();
|
140 |
+
</script>
|
141 |
+
</body>
|
142 |
+
</html>
|