Update index.html
Browse files- index.html +278 -5
index.html
CHANGED
@@ -1,15 +1,288 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
-
|
4 |
<head>
|
5 |
<meta charset="UTF-8" />
|
6 |
<link rel="stylesheet" href="style.css" />
|
7 |
-
|
8 |
-
<
|
9 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
</head>
|
11 |
-
|
12 |
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
<h1>Object Detection w/ 🤗 Transformers.js</h1>
|
14 |
<label id="container" for="upload">
|
15 |
<svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8" />
|
5 |
<link rel="stylesheet" href="style.css" />
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>Angel Tarot Train Game</title>
|
8 |
+
<style>
|
9 |
+
body {
|
10 |
+
font-family: Arial, sans-serif;
|
11 |
+
display: flex;
|
12 |
+
flex-direction: column;
|
13 |
+
align-items: center;
|
14 |
+
}
|
15 |
+
#game-area {
|
16 |
+
display: flex;
|
17 |
+
flex-direction: column;
|
18 |
+
width: 100%;
|
19 |
+
max-width: 800px;
|
20 |
+
}
|
21 |
+
#player-hand {
|
22 |
+
display: flex;
|
23 |
+
justify-content: center;
|
24 |
+
margin-bottom: 20px;
|
25 |
+
}
|
26 |
+
.card {
|
27 |
+
width: 80px;
|
28 |
+
height: 120px;
|
29 |
+
background-color: #f0f0f0;
|
30 |
+
border: 1px solid #ccc;
|
31 |
+
border-radius: 5px;
|
32 |
+
margin: 0 5px;
|
33 |
+
display: flex;
|
34 |
+
flex-direction: column;
|
35 |
+
justify-content: flex-start;
|
36 |
+
align-items: center;
|
37 |
+
cursor: move;
|
38 |
+
position: relative;
|
39 |
+
}
|
40 |
+
.card-value {
|
41 |
+
position: absolute;
|
42 |
+
top: 5px;
|
43 |
+
left: 5px;
|
44 |
+
font-weight: bold;
|
45 |
+
}
|
46 |
+
.train-level {
|
47 |
+
height: 150px;
|
48 |
+
overflow-x: auto;
|
49 |
+
white-space: nowrap;
|
50 |
+
border: 1px solid #999;
|
51 |
+
margin-bottom: 10px;
|
52 |
+
}
|
53 |
+
.train-car {
|
54 |
+
display: inline-block;
|
55 |
+
width: 100px;
|
56 |
+
height: 140px;
|
57 |
+
background-color: #e0e0e0;
|
58 |
+
border: 1px solid #bbb;
|
59 |
+
margin: 5px;
|
60 |
+
vertical-align: top;
|
61 |
+
}
|
62 |
+
#score-display {
|
63 |
+
position: absolute;
|
64 |
+
top: 10px;
|
65 |
+
right: 10px;
|
66 |
+
font-size: 18px;
|
67 |
+
font-weight: bold;
|
68 |
+
}
|
69 |
+
#high-score {
|
70 |
+
position: fixed;
|
71 |
+
bottom: 10px;
|
72 |
+
left: 50%;
|
73 |
+
transform: translateX(-50%);
|
74 |
+
font-size: 16px;
|
75 |
+
font-weight: bold;
|
76 |
+
}
|
77 |
+
#reset-button {
|
78 |
+
margin-top: 20px;
|
79 |
+
}
|
80 |
+
#history {
|
81 |
+
margin-top: 20px;
|
82 |
+
max-height: 100px;
|
83 |
+
overflow-y: auto;
|
84 |
+
width: 100%;
|
85 |
+
max-width: 300px;
|
86 |
+
}
|
87 |
+
</style>
|
88 |
</head>
|
|
|
89 |
<body>
|
90 |
+
<h1>Angel Tarot Train Game</h1>
|
91 |
+
<div id="score-display">Score: 0</div>
|
92 |
+
<div id="game-area">
|
93 |
+
<div id="train-level-1" class="train-level"></div>
|
94 |
+
<div id="train-level-2" class="train-level"></div>
|
95 |
+
<div id="train-level-3" class="train-level"></div>
|
96 |
+
<div id="player-hand"></div>
|
97 |
+
</div>
|
98 |
+
<button id="reset-button">Reset Game</button>
|
99 |
+
<div id="history"></div>
|
100 |
+
<div id="high-score">High Score: 0</div>
|
101 |
+
|
102 |
+
<script>
|
103 |
+
const angelCards = [
|
104 |
+
{name: "Michael", value: 0},
|
105 |
+
{name: "Gabriel", value: 1},
|
106 |
+
{name: "Raphael", value: 2},
|
107 |
+
{name: "Uriel", value: 3},
|
108 |
+
{name: "Samael", value: 4},
|
109 |
+
{name: "Zadkiel", value: 5},
|
110 |
+
{name: "Camael", value: 6},
|
111 |
+
{name: "Haniel", value: 7},
|
112 |
+
{name: "Raziel", value: 8},
|
113 |
+
{name: "Metatron", value: 9},
|
114 |
+
{name: "Sandalphon", value: 10},
|
115 |
+
{name: "Azrael", value: 11},
|
116 |
+
{name: "Cassiel", value: 12},
|
117 |
+
{name: "Sachiel", value: 13},
|
118 |
+
{name: "Raguel", value: 14},
|
119 |
+
{name: "Remiel", value: 15},
|
120 |
+
{name: "Sariel", value: 16},
|
121 |
+
{name: "Jeremiel", value: 17},
|
122 |
+
{name: "Jophiel", value: 18},
|
123 |
+
{name: "Ariel", value: 19},
|
124 |
+
{name: "Chamuel", value: 20},
|
125 |
+
{name: "Seraphiel", value: 21}
|
126 |
+
];
|
127 |
+
|
128 |
+
let score = 0;
|
129 |
+
let highScore = 0;
|
130 |
+
let playedCards = [];
|
131 |
+
|
132 |
+
function shuffleArray(array) {
|
133 |
+
for (let i = array.length - 1; i > 0; i--) {
|
134 |
+
const j = Math.floor(Math.random() * (i + 1));
|
135 |
+
[array[i], array[j]] = [array[j], array[i]];
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
function createCard(card) {
|
140 |
+
const cardElement = document.createElement('div');
|
141 |
+
cardElement.className = 'card';
|
142 |
+
cardElement.draggable = true;
|
143 |
+
cardElement.textContent = card.name;
|
144 |
+
cardElement.dataset.value = card.value;
|
145 |
+
cardElement.dataset.name = card.name;
|
146 |
+
|
147 |
+
const valueElement = document.createElement('span');
|
148 |
+
valueElement.className = 'card-value';
|
149 |
+
valueElement.textContent = card.value;
|
150 |
+
cardElement.appendChild(valueElement);
|
151 |
+
|
152 |
+
return cardElement;
|
153 |
+
}
|
154 |
+
|
155 |
+
function dealCards() {
|
156 |
+
shuffleArray(angelCards);
|
157 |
+
const playerHand = document.getElementById('player-hand');
|
158 |
+
playerHand.innerHTML = '';
|
159 |
+
for (let i = 0; i < 5; i++) {
|
160 |
+
const card = angelCards[i];
|
161 |
+
const cardElement = createCard(card);
|
162 |
+
playerHand.appendChild(cardElement);
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
function createTrainCars() {
|
167 |
+
const trainLevels = document.querySelectorAll('.train-level');
|
168 |
+
trainLevels.forEach(level => {
|
169 |
+
for (let i = 0; i < 5; i++) {
|
170 |
+
const trainCar = document.createElement('div');
|
171 |
+
trainCar.className = 'train-car';
|
172 |
+
level.appendChild(trainCar);
|
173 |
+
}
|
174 |
+
});
|
175 |
+
}
|
176 |
+
|
177 |
+
function initDragAndDrop() {
|
178 |
+
const cards = document.querySelectorAll('.card');
|
179 |
+
const trainCars = document.querySelectorAll('.train-car');
|
180 |
+
|
181 |
+
cards.forEach(card => {
|
182 |
+
card.addEventListener('dragstart', dragStart);
|
183 |
+
});
|
184 |
+
|
185 |
+
trainCars.forEach(car => {
|
186 |
+
car.addEventListener('dragover', dragOver);
|
187 |
+
car.addEventListener('drop', drop);
|
188 |
+
});
|
189 |
+
}
|
190 |
+
|
191 |
+
function dragStart(e) {
|
192 |
+
e.dataTransfer.setData('text/plain', e.target.dataset.name);
|
193 |
+
}
|
194 |
+
|
195 |
+
function dragOver(e) {
|
196 |
+
e.preventDefault();
|
197 |
+
}
|
198 |
+
|
199 |
+
function drop(e) {
|
200 |
+
e.preventDefault();
|
201 |
+
const cardName = e.dataTransfer.getData('text');
|
202 |
+
const card = document.querySelector(`.card[data-name="${cardName}"]`);
|
203 |
+
|
204 |
+
if (card && e.target.classList.contains('train-car') && !e.target.hasChildNodes()) {
|
205 |
+
e.target.appendChild(card);
|
206 |
+
card.draggable = false;
|
207 |
+
activateCard(card);
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
function activateCard(card) {
|
212 |
+
const cardName = card.dataset.name;
|
213 |
+
const cardValue = parseInt(card.dataset.value);
|
214 |
+
playedCards.push({name: cardName, value: cardValue});
|
215 |
+
updateScore();
|
216 |
+
}
|
217 |
+
|
218 |
+
function updateScore() {
|
219 |
+
score = 0;
|
220 |
+
const letterCounts = {};
|
221 |
+
|
222 |
+
playedCards.forEach(card => {
|
223 |
+
// Count letters
|
224 |
+
for (let letter of card.name) {
|
225 |
+
letterCounts[letter] = (letterCounts[letter] || 0) + 1;
|
226 |
+
}
|
227 |
+
|
228 |
+
// Add point for each card
|
229 |
+
score++;
|
230 |
+
|
231 |
+
// Special rules for 0 and 21
|
232 |
+
if (card.value === 0) {
|
233 |
+
score *= 2; // Double the current score
|
234 |
+
} else if (card.value === 21) {
|
235 |
+
score += 10; // Add 10 bonus points
|
236 |
+
}
|
237 |
+
});
|
238 |
+
|
239 |
+
// Check for letter combinations
|
240 |
+
Object.values(letterCounts).forEach(count => {
|
241 |
+
if (count >= 3) {
|
242 |
+
score *= 3; // Triple the score for each letter with 3 or more occurrences
|
243 |
+
}
|
244 |
+
});
|
245 |
+
|
246 |
+
document.getElementById('score-display').textContent = `Score: ${score}`;
|
247 |
+
|
248 |
+
if (playedCards.length === 5) {
|
249 |
+
endGame();
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
function endGame() {
|
254 |
+
if (score > highScore) {
|
255 |
+
highScore = score;
|
256 |
+
document.getElementById('high-score').textContent = `High Score: ${highScore}`;
|
257 |
+
alert(`Congratulations! New high score: ${highScore}`);
|
258 |
+
}
|
259 |
+
|
260 |
+
const historyElement = document.getElementById('history');
|
261 |
+
historyElement.innerHTML += `<p>Game ended with score: ${score}</p>`;
|
262 |
+
historyElement.scrollTop = historyElement.scrollHeight;
|
263 |
+
}
|
264 |
+
|
265 |
+
function resetGame() {
|
266 |
+
score = 0;
|
267 |
+
playedCards = [];
|
268 |
+
document.getElementById('score-display').textContent = 'Score: 0';
|
269 |
+
|
270 |
+
const trainCars = document.querySelectorAll('.train-car');
|
271 |
+
trainCars.forEach(car => car.innerHTML = '');
|
272 |
+
|
273 |
+
dealCards();
|
274 |
+
initDragAndDrop();
|
275 |
+
}
|
276 |
+
|
277 |
+
function init() {
|
278 |
+
createTrainCars();
|
279 |
+
dealCards();
|
280 |
+
initDragAndDrop();
|
281 |
+
document.getElementById('reset-button').addEventListener('click', resetGame);
|
282 |
+
}
|
283 |
+
|
284 |
+
init();
|
285 |
+
</script>
|
286 |
<h1>Object Detection w/ 🤗 Transformers.js</h1>
|
287 |
<label id="container" for="upload">
|
288 |
<svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|