-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
285 lines (246 loc) · 9.13 KB
/
Copy pathscript.js
File metadata and controls
285 lines (246 loc) · 9.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
// Game State
let gameState = {
hunger: 100,
money: 1000,
happiness: 50
};
// DOM Elements
const hungerBar = document.getElementById('hungerBar');
const hungerText = document.getElementById('hungerText');
const moneyDisplay = document.getElementById('money');
const happinessDisplay = document.getElementById('happiness');
const speechBubble = document.getElementById('speechBubble');
const character = document.getElementById('character');
const mouth = document.getElementById('mouth');
const notifications = document.getElementById('notifications');
// Funny Messages
const messages = {
hungry: [
"Đói quá... cho ăn đi anh em ơi! 🥺",
"Bụng kêu ọc ọc rồi! 😭",
"Anh em đâu rồi? Em đói lắm! 🍚",
"Sao không cho em ăn vậy? 😢",
"Em muốn ăn... bất cứ thứ gì! 🤤",
"Đói đến mức muốn ăn cả màn hình luôn! 😤",
"Nhìn cái menu mà nuốt nước bọt! 🤤"
],
satisfied: [
"Ơ, có vẻ ổn rồi đó! 😊",
"Cảm ơn anh em nhé! 😁",
"Ngon quá đi mất! 😋",
"Hơi no rồi nè! 🙂",
"Vẫn còn ăn được nữa! 😄"
],
full: [
"No căng bụng luôn! 🤰",
"Ăn no rồi, nghỉ tý! 😴",
"Sướng quá đi mất! 🥰",
"Cảm ơn anh em đã nuôi! ❤️",
"No nê rồi, có thể chiến game! 🎮",
"배불러! (Bụng no quá!) 😂"
],
veryHungry: [
"ĐÓIIIIII! CHO ĂN ĐI! 😭😭😭",
"Sắp chết đói rồi anh em ơi! ☠️",
"Cứu em với! Đói lắm rồi! 🆘",
"Em sắp ngất đói mất! 😵",
"Nhanh lên đi! Bụng em kêu ầm ầm! 🔊"
],
noMoney: [
"Hết tiền rồi! Đi làm thêm đi! 💸",
"Nghèo quá! Phải kiếm tiền thôi! 😢",
"Ví trống rỗng! Lương đâu? 💰",
"Làm việc đi anh em! Hết tiền rồi! 😭"
],
afterEating: [
"Ngon lành cành đào! 😋",
"Cảm ơn meal! 🙏",
"Đã đời! 🤩",
"Trời ơi, ngon quá! 😍",
"5 sao cho món này! ⭐⭐⭐⭐⭐"
]
};
// Initialize Game
function init() {
updateUI();
startHungerTimer();
}
// Update UI
function updateUI() {
// Update hunger bar
hungerBar.style.width = gameState.hunger + '%';
hungerText.textContent = gameState.hunger + '%';
// Update money
moneyDisplay.textContent = gameState.money + 'đ';
// Update happiness emoji
if (gameState.hunger < 20) {
happinessDisplay.textContent = '😭';
mouth.className = 'mouth sad';
} else if (gameState.hunger < 50) {
happinessDisplay.textContent = '😟';
mouth.className = 'mouth';
} else if (gameState.hunger < 80) {
happinessDisplay.textContent = '😊';
mouth.className = 'mouth';
} else {
happinessDisplay.textContent = '🤩';
mouth.className = 'mouth happy';
}
// Update speech bubble
updateSpeechBubble();
}
// Update Speech Bubble
function updateSpeechBubble() {
let messageArray;
if (gameState.hunger < 15) {
messageArray = messages.veryHungry;
} else if (gameState.hunger < 40) {
messageArray = messages.hungry;
} else if (gameState.hunger < 80) {
messageArray = messages.satisfied;
} else {
messageArray = messages.full;
}
const randomMessage = messageArray[Math.floor(Math.random() * messageArray.length)];
speechBubble.textContent = randomMessage;
}
// Hunger Timer
function startHungerTimer() {
setInterval(() => {
if (gameState.hunger > 0) {
gameState.hunger = Math.max(0, gameState.hunger - 1);
updateUI();
// Warning notification when very hungry
if (gameState.hunger === 10) {
showNotification('⚠️ Anh em sắp chết đói rồi!', 'error');
}
} else {
showNotification('💀 Game Over! Anh em đói chết rồi!', 'error');
}
}, 3000); // Decrease hunger every 3 seconds
}
// Feed Character
function feedCharacter(foodName, price, hungerRestore) {
if (gameState.money < price) {
showNotification('❌ Không đủ tiền! Đi làm thêm đi!', 'error');
const randomMessage = messages.noMoney[Math.floor(Math.random() * messages.noMoney.length)];
speechBubble.textContent = randomMessage;
return;
}
// Deduct money and restore hunger
gameState.money -= price;
gameState.hunger = Math.min(100, gameState.hunger + hungerRestore);
// Play eating animation
character.classList.add('eating');
setTimeout(() => {
character.classList.remove('eating');
}, 1500);
// Show notification
const randomAfterEating = messages.afterEating[Math.floor(Math.random() * messages.afterEating.length)];
showNotification(`🍴 Đã ăn ${foodName}! ${randomAfterEating}`, 'success');
// Update speech bubble with random message
setTimeout(() => {
const messageArray = gameState.hunger > 80 ? messages.full : messages.satisfied;
const randomMessage = messageArray[Math.floor(Math.random() * messageArray.length)];
speechBubble.textContent = randomMessage;
}, 1000);
updateUI();
}
// Show Notification
function showNotification(message, type = 'success') {
const notification = document.createElement('div');
notification.className = `notification ${type}`;
notification.textContent = message;
notifications.appendChild(notification);
setTimeout(() => {
notification.style.animation = 'slideIn 0.3s ease reverse';
setTimeout(() => {
notifications.removeChild(notification);
}, 300);
}, 3000);
}
// Earn Money
function earnMoney() {
const earnings = Math.floor(Math.random() * 100) + 50;
gameState.money += earnings;
const funnyEarnMessages = [
`💰 Kiếm được ${earnings}đ! Giàu vcl! 💸`,
`🤑 +${earnings}đ! Streamer à? 🎮`,
`💵 Nhận ${earnings}đ! Đi làm thêm giỏi đấy! 💪`,
`💴 Lương ${earnings}đ đây! Mua đồ ăn đi! 🍕`,
`💷 Được ${earnings}đ! Sugar daddy đó à? 😏`
];
const randomEarnMessage = funnyEarnMessages[Math.floor(Math.random() * funnyEarnMessages.length)];
showNotification(randomEarnMessage, 'success');
speechBubble.textContent = "Wow! Giàu rồi! Mua đồ ăn cho em đi! 🤩";
updateUI();
}
// Reset Game
function resetGame() {
if (confirm('Chơi lại từ đầu? Tất cả tiến trình sẽ mất! 🔄')) {
gameState = {
hunger: 100,
money: 1000,
happiness: 50
};
updateUI();
showNotification('🎮 Đã reset game! Chơi lại nào!', 'success');
speechBubble.textContent = 'Xin chào! Nuôi em đi anh em ơi! 😊';
}
}
// Event Listeners
document.querySelectorAll('.food-item').forEach(button => {
button.addEventListener('click', (e) => {
const foodName = button.dataset.food;
const price = parseInt(button.dataset.price);
const hungerRestore = parseInt(button.dataset.hunger);
feedCharacter(foodName, price, hungerRestore);
});
});
document.getElementById('earnMoney').addEventListener('click', earnMoney);
document.getElementById('resetGame').addEventListener('click', resetGame);
// Easter Eggs
let clickCount = 0;
character.addEventListener('click', () => {
clickCount++;
const easterEggMessages = [
"Đừng bấm vào mặt em! 😤",
"Gì zậy trời? 🤨",
"Ngứa à? 😏",
"Đừng có bấm nữa! 😠",
"Anh em thích chọc em à? 🙄",
"Đau đó nha! 😭",
"Chơi khăm à? 😤"
];
if (clickCount % 3 === 0) {
const randomEgg = easterEggMessages[Math.floor(Math.random() * easterEggMessages.length)];
speechBubble.textContent = randomEgg;
}
});
// Konami Code Easter Egg (↑↑↓↓←→←→BA)
let konamiCode = [];
const konamiSequence = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a'];
document.addEventListener('keydown', (e) => {
konamiCode.push(e.key);
konamiCode = konamiCode.slice(-10);
if (konamiCode.join(',') === konamiSequence.join(',')) {
gameState.money += 9999;
updateUI();
showNotification('🎮 CHEAT CODE ACTIVATED! +9999đ! You are a legend! 🏆', 'success');
speechBubble.textContent = 'Hack à? Được đó, giờ mua hết đồ ăn đi! 😎';
}
});
// Random funny messages every 30 seconds
setInterval(() => {
if (Math.random() > 0.7) {
const allMessages = [...messages.hungry, ...messages.satisfied, ...messages.full];
const randomMsg = allMessages[Math.floor(Math.random() * allMessages.length)];
speechBubble.textContent = randomMsg;
}
}, 30000);
// Initialize the game
init();
// Welcome message
setTimeout(() => {
showNotification('🎮 Chào mừng đến với Nuôi Anh Em! Đừng để anh em đói nhé! 😊', 'success');
}, 500);