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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>AI Development and Game Programming Resource Management Game</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
10 |
+
background-color: #f0f0f0;
|
11 |
+
padding: 20px;
|
12 |
+
color: #333;
|
13 |
+
}
|
14 |
+
.container {
|
15 |
+
max-width: 1200px;
|
16 |
+
margin: 0 auto;
|
17 |
+
display: flex;
|
18 |
+
flex-wrap: wrap;
|
19 |
+
justify-content: space-between;
|
20 |
+
}
|
21 |
+
.resource, .actions, .events {
|
22 |
+
margin-bottom: 20px;
|
23 |
+
padding: 15px;
|
24 |
+
background-color: #fff;
|
25 |
+
border-radius: 8px;
|
26 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
27 |
+
flex-basis: calc(33% - 20px);
|
28 |
+
}
|
29 |
+
h1, h2 {
|
30 |
+
color: #2c3e50;
|
31 |
+
}
|
32 |
+
button {
|
33 |
+
margin: 5px;
|
34 |
+
padding: 10px 15px;
|
35 |
+
font-size: 16px;
|
36 |
+
background-color: #3498db;
|
37 |
+
color: white;
|
38 |
+
border: none;
|
39 |
+
border-radius: 5px;
|
40 |
+
cursor: pointer;
|
41 |
+
transition: background-color 0.3s;
|
42 |
+
}
|
43 |
+
button:hover {
|
44 |
+
background-color: #2980b9;
|
45 |
+
}
|
46 |
+
canvas {
|
47 |
+
border: 1px solid #ccc;
|
48 |
+
margin-top: 20px;
|
49 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
50 |
+
}
|
51 |
+
#resource-list {
|
52 |
+
display: flex;
|
53 |
+
flex-wrap: wrap;
|
54 |
+
gap: 10px;
|
55 |
+
}
|
56 |
+
.resource-item {
|
57 |
+
background-color: #ecf0f1;
|
58 |
+
padding: 10px;
|
59 |
+
border-radius: 5px;
|
60 |
+
text-align: center;
|
61 |
+
flex-grow: 1;
|
62 |
+
}
|
63 |
+
#event-result {
|
64 |
+
font-style: italic;
|
65 |
+
color: #e74c3c;
|
66 |
+
}
|
67 |
+
#game-log {
|
68 |
+
max-height: 150px;
|
69 |
+
overflow-y: auto;
|
70 |
+
background-color: #ecf0f1;
|
71 |
+
padding: 10px;
|
72 |
+
border-radius: 5px;
|
73 |
+
margin-top: 20px;
|
74 |
+
}
|
75 |
+
</style>
|
76 |
+
</head>
|
77 |
+
<body>
|
78 |
+
<h1>AI Development and Game Programming Resource Management Game</h1>
|
79 |
+
|
80 |
+
<div class="container">
|
81 |
+
<div class="resource" id="resources">
|
82 |
+
<h2>Current Resources</h2>
|
83 |
+
<div id="resource-list"></div>
|
84 |
+
</div>
|
85 |
+
|
86 |
+
<div class="actions">
|
87 |
+
<h2>Actions</h2>
|
88 |
+
<button onclick="performAction('Cook Chicken')">Cook Chicken</button>
|
89 |
+
<button onclick="performAction('Make Salad')">Make Salad</button>
|
90 |
+
<button onclick="performAction('Drink Water')">Drink Water</button>
|
91 |
+
<button onclick="performAction('Monster Zero')">Drink Monster Zero</button>
|
92 |
+
<button onclick="performAction('Code')">Code</button>
|
93 |
+
<button onclick="performAction('Debug')">Debug</button>
|
94 |
+
</div>
|
95 |
+
|
96 |
+
<div class="events">
|
97 |
+
<h2>Random Events</h2>
|
98 |
+
<button onclick="triggerRandomEvent()">Wait for Random Event</button>
|
99 |
+
<p id="event-result"></p>
|
100 |
+
</div>
|
101 |
+
</div>
|
102 |
+
|
103 |
+
<canvas id="gameCanvas" width="800" height="400"></canvas>
|
104 |
+
|
105 |
+
<div id="game-log"></div>
|
106 |
+
|
107 |
+
<script>
|
108 |
+
let gameState = {
|
109 |
+
"Monster Zero": 1,
|
110 |
+
"Water": 10,
|
111 |
+
"Chicken": 3,
|
112 |
+
"Salad": 5,
|
113 |
+
"Air Fryer": 1,
|
114 |
+
"Microwave": 1,
|
115 |
+
"Culligan Machine": 1,
|
116 |
+
"Energy": 100,
|
117 |
+
"Code Quality": 0,
|
118 |
+
"Bugs": 0
|
119 |
+
};
|
120 |
+
|
121 |
+
const RESOURCE_COSTS = {
|
122 |
+
"Cook Chicken": {"Chicken": 1, "Energy": 10},
|
123 |
+
"Make Salad": {"Salad": 1, "Energy": 5},
|
124 |
+
"Drink Water": {"Water": 1},
|
125 |
+
"Monster Zero": {"Monster Zero": 1},
|
126 |
+
"Code": {"Energy": 15},
|
127 |
+
"Debug": {"Energy": 20}
|
128 |
+
};
|
129 |
+
|
130 |
+
const RESOURCE_GAINS = {
|
131 |
+
"Cook Chicken": {"Energy": 20},
|
132 |
+
"Make Salad": {"Energy": 15},
|
133 |
+
"Drink Water": {"Energy": 5},
|
134 |
+
"Monster Zero": {"Energy": 30},
|
135 |
+
"Code": {"Code Quality": 10, "Bugs": 5},
|
136 |
+
"Debug": {"Code Quality": 5, "Bugs": -10}
|
137 |
+
};
|
138 |
+
|
139 |
+
function updateResources() {
|
140 |
+
const resourceList = document.getElementById('resource-list');
|
141 |
+
resourceList.innerHTML = '';
|
142 |
+
for (let resource in gameState) {
|
143 |
+
const resourceItem = document.createElement('div');
|
144 |
+
resourceItem.className = 'resource-item';
|
145 |
+
resourceItem.textContent = `${resource}: ${gameState[resource]}`;
|
146 |
+
resourceList.appendChild(resourceItem);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
function performAction(action) {
|
151 |
+
if (RESOURCE_COSTS.hasOwnProperty(action)) {
|
152 |
+
for (let resource in RESOURCE_COSTS[action]) {
|
153 |
+
if (gameState[resource] < RESOURCE_COSTS[action][resource]) {
|
154 |
+
logEvent(`Not enough ${resource} to perform ${action}`);
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
for (let resource in RESOURCE_COSTS[action]) {
|
159 |
+
gameState[resource] -= RESOURCE_COSTS[action][resource];
|
160 |
+
}
|
161 |
+
for (let resource in RESOURCE_GAINS[action]) {
|
162 |
+
gameState[resource] += RESOURCE_GAINS[action][resource];
|
163 |
+
}
|
164 |
+
logEvent(`Performed action: ${action}`);
|
165 |
+
updateResources();
|
166 |
+
drawScene();
|
167 |
+
checkGameOver();
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
function triggerRandomEvent() {
|
172 |
+
const events = [
|
173 |
+
"Found Water", "Lost Chicken", "Energy Boost", "Microwave Malfunction",
|
174 |
+
"Coding Inspiration", "Bug Infestation", "Coffee Break", "Power Outage"
|
175 |
+
];
|
176 |
+
const event = events[Math.floor(Math.random() * events.length)];
|
177 |
+
document.getElementById('event-result').textContent = `Event: ${event}`;
|
178 |
+
switch (event) {
|
179 |
+
case "Found Water":
|
180 |
+
gameState["Water"] += 3;
|
181 |
+
break;
|
182 |
+
case "Lost Chicken":
|
183 |
+
if (gameState["Chicken"] > 0) gameState["Chicken"] -= 1;
|
184 |
+
break;
|
185 |
+
case "Energy Boost":
|
186 |
+
gameState["Energy"] += 20;
|
187 |
+
break;
|
188 |
+
case "Microwave Malfunction":
|
189 |
+
if (gameState["Microwave"] > 0) gameState["Microwave"] -= 1;
|
190 |
+
break;
|
191 |
+
case "Coding Inspiration":
|
192 |
+
gameState["Code Quality"] += 15;
|
193 |
+
break;
|
194 |
+
case "Bug Infestation":
|
195 |
+
gameState["Bugs"] += 20;
|
196 |
+
break;
|
197 |
+
case "Coffee Break":
|
198 |
+
gameState["Energy"] += 10;
|
199 |
+
gameState["Water"] -= 1;
|
200 |
+
break;
|
201 |
+
case "Power Outage":
|
202 |
+
gameState["Energy"] -= 10;
|
203 |
+
gameState["Code Quality"] -= 5;
|
204 |
+
break;
|
205 |
+
}
|
206 |
+
logEvent(`Random event occurred: ${event}`);
|
207 |
+
updateResources();
|
208 |
+
drawScene();
|
209 |
+
checkGameOver();
|
210 |
+
}
|
211 |
+
|
212 |
+
function checkGameOver() {
|
213 |
+
if (gameState["Energy"] <= 0) {
|
214 |
+
logEvent("Game Over! You ran out of energy.");
|
215 |
+
} else if (gameState["Chicken"] === 0 && gameState["Salad"] === 0 && gameState["Water"] === 0) {
|
216 |
+
logEvent("Game Over! You ran out of all food resources.");
|
217 |
+
} else if (gameState["Bugs"] >= 100) {
|
218 |
+
logEvent("Game Over! Your code has too many bugs.");
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
function drawScene() {
|
223 |
+
const canvas = document.getElementById('gameCanvas');
|
224 |
+
const ctx = canvas.getContext('2d');
|
225 |
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
226 |
+
|
227 |
+
const BAR_WIDTH = 40;
|
228 |
+
const BAR_SPACING = 60;
|
229 |
+
const MAX_BAR_HEIGHT = 300;
|
230 |
+
|
231 |
+
let x = 50;
|
232 |
+
for (let resource in gameState) {
|
233 |
+
const value = gameState[resource];
|
234 |
+
const normalizedHeight = (value / 100) * MAX_BAR_HEIGHT;
|
235 |
+
|
236 |
+
// Draw 3D-like bar
|
237 |
+
ctx.fillStyle = 'rgba(100, 100, 250, 0.7)';
|
238 |
+
ctx.beginPath();
|
239 |
+
ctx.moveTo(x, canvas.height - normalizedHeight);
|
240 |
+
ctx.lineTo(x + BAR_WIDTH, canvas.height - normalizedHeight);
|
241 |
+
ctx.lineTo(x + BAR_WIDTH, canvas.height);
|
242 |
+
ctx.lineTo(x, canvas.height);
|
243 |
+
ctx.closePath();
|
244 |
+
ctx.fill();
|
245 |
+
|
246 |
+
// Draw top of the bar
|
247 |
+
ctx.fillStyle = 'rgba(150, 150, 255, 0.9)';
|
248 |
+
ctx.beginPath();
|
249 |
+
ctx.moveTo(x, canvas.height - normalizedHeight);
|
250 |
+
ctx.lineTo(x + BAR_WIDTH, canvas.height - normalizedHeight);
|
251 |
+
ctx.lineTo(x + BAR_WIDTH - 5, canvas.height - normalizedHeight - 5);
|
252 |
+
ctx.lineTo(x - 5, canvas.height - normalizedHeight - 5);
|
253 |
+
ctx.closePath();
|
254 |
+
ctx.fill();
|
255 |
+
|
256 |
+
// Draw side of the bar
|
257 |
+
ctx.fillStyle = 'rgba(80, 80, 200, 0.8)';
|
258 |
+
ctx.beginPath();
|
259 |
+
ctx.moveTo(x + BAR_WIDTH, canvas.height - normalizedHeight);
|
260 |
+
ctx.lineTo(x + BAR_WIDTH, canvas.height);
|
261 |
+
ctx.lineTo(x + BAR_WIDTH - 5, canvas.height - 5);
|
262 |
+
ctx.lineTo(x + BAR_WIDTH - 5, canvas.height - normalizedHeight - 5);
|
263 |
+
ctx.closePath();
|
264 |
+
ctx.fill();
|
265 |
+
|
266 |
+
// Draw outline
|
267 |
+
ctx.strokeStyle = 'black';
|
268 |
+
ctx.lineWidth = 2;
|
269 |
+
ctx.strokeRect(x, canvas.height - normalizedHeight, BAR_WIDTH, normalizedHeight);
|
270 |
+
|
271 |
+
// Draw label
|
272 |
+
ctx.fillStyle = 'black';
|
273 |
+
ctx.font = '12px Arial';
|
274 |
+
ctx.textAlign = 'center';
|
275 |
+
ctx.fillText(resource, x + BAR_WIDTH / 2, canvas.height - normalizedHeight - 10);
|
276 |
+
ctx.fillText(value, x + BAR_WIDTH / 2, canvas.height - normalizedHeight / 2);
|
277 |
+
|
278 |
+
x += BAR_SPACING;
|
279 |
+
}
|
280 |
+
}
|
281 |
+
|
282 |
+
function logEvent(message) {
|
283 |
+
const gameLog = document.getElementById('game-log');
|
284 |
+
const logEntry = document.createElement('p');
|
285 |
+
logEntry.textContent = message;
|
286 |
+
gameLog.insertBefore(logEntry, gameLog.firstChild);
|
287 |
+
if (gameLog.children.length > 5) {
|
288 |
+
gameLog.removeChild(gameLog.lastChild);
|
289 |
+
}
|
290 |
+
}
|
291 |
+
|
292 |
+
updateResources();
|
293 |
+
drawScene();
|
294 |
+
</script>
|
295 |
+
</body>
|
296 |
+
</html>
|