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