Spaces:
Running
Running
File size: 27,213 Bytes
d0e448d | 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 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 | <!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Screeps AI Wrapper</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
:root {
--matrix-green: #00ff41;
--matrix-green-dark: #00cc33;
--matrix-cyan: #00ffff;
--matrix-cyan-dark: #00cccc;
--bg-dark: #0a0a0a;
--bg-darker: #000000;
--panel-bg: #111111;
--border-color: #00aa00;
--text-primary: #00ff41;
--text-secondary: #00cc33;
--hover-bg: #003300;
--active-bg: #005500;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Courier New', monospace;
background-color: var(--bg-darker);
color: var(--matrix-green);
height: 100vh;
overflow: hidden;
}
.app-container {
display: grid;
grid-template-columns: 1fr 350px;
grid-template-rows: 60px 1fr 200px;
height: 100vh;
gap: 2px;
background-color: var(--border-color);
}
/* Header Styles */
.header {
grid-column: 1 / -1;
background-color: var(--panel-bg);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
border-bottom: 2px solid var(--border-color);
}
.logo {
font-size: 24px;
font-weight: bold;
color: var(--matrix-cyan);
}
.server-selector {
display: flex;
align-items: center;
gap: 10px;
}
.server-dropdown {
background-color: var(--bg-dark);
color: var(--matrix-green);
border: 1px solid var(--border-color);
padding: 8px 15px;
border-radius: 4px;
font-family: 'Courier New', monospace;
}
.auth-status {
display: flex;
align-items: center;
gap: 8px;
color: var(--matrix-cyan);
}
/* Game View Styles */
.game-view {
background-color: var(--panel-bg);
display: flex;
flex-direction: column;
}
.game-iframe {
flex: 1;
border: none;
background-color: var(--bg-dark);
}
.metrics-bar {
background-color: var(--bg-dark);
padding: 10px 20px;
display: flex;
justify-content: space-around;
border-top: 2px solid var(--border-color);
font-size: 14px;
}
.metric {
display: flex;
flex-direction: column;
align-items: center;
}
.metric-value {
font-weight: bold;
color: var(--matrix-cyan);
font-size: 18px;
}
/* Control Panel Styles */
.control-panel {
grid-column: 1 / -1;
background-color: var(--panel-bg);
display: grid;
grid-template-columns: 1fr auto;
gap: 2px;
background-color: var(--border-color);
}
.folder-tree {
background-color: var(--bg-dark);
padding: 15px;
overflow-y: auto;
min-height: 200px;
}
.folder-item, .file-item {
padding: 8px 12px;
cursor: pointer;
border-radius: 4px;
margin-bottom: 2px;
transition: background-color 0.2s;
}
.folder-item:hover, .file-item:hover {
background-color: var(--hover-bg);
}
.folder-item.active, .file-item.active {
background-color: var(--active-bg);
}
.folder-item {
font-weight: bold;
}
.file-item {
margin-left: 20px;
}
.branch-selector {
display: flex;
align-items: center;
gap: 10px;
padding: 15px;
background-color: var(--bg-dark);
}
.branch-dropdown {
background-color: var(--bg-dark);
color: var(--matrix-green);
border: 1px solid var(--border-color);
padding: 8px 15px;
border-radius: 4px;
font-family: 'Courier New', monospace;
}
.action-buttons {
display: flex;
gap: 10px;
padding: 15px;
background-color: var(--bg-dark);
flex-wrap: wrap;
}
.btn {
background-color: var(--bg-dark);
color: var(--matrix-green);
border: 1px solid var(--border-color);
padding: 10px 20px;
border-radius: 4px;
font-family: 'Courier New', monospace;
cursor: pointer;
transition: all 0.2s;
display: flex;
align-items: center;
gap: 8px;
}
.btn:hover {
background-color: var(--hover-bg);
}
.btn:active {
background-color: var(--matrix-green);
color: var(--bg-dark);
}
/* Chat Panel Styles */
.chat-panel {
grid-row: 2 / span 2;
background-color: var(--panel-bg);
display: flex;
flex-direction: column;
border-left: 2px solid var(--border-color);
}
.chat-header {
padding: 15px;
background-color: var(--bg-dark);
border-bottom: 2px solid var(--border-color);
font-weight: bold;
color: var(--matrix-cyan);
}
.chat-messages {
flex: 1;
padding: 15px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 10px;
}
.message {
padding: 10px;
border-radius: 4px;
max-width: 90%;
word-wrap: break-word;
}
.user-message {
background-color: var(--hover-bg);
align-self: flex-end;
text-align: right;
}
.ai-message {
background-color: var(--bg-dark);
align-self: flex-start;
}
.chat-input {
padding: 15px;
background-color: var(--bg-dark);
border-top: 2px solid var(--border-color);
display: flex;
gap: 10px;
}
.chat-input textarea {
flex: 1;
background-color: var(--bg-darker);
color: var(--matrix-green);
border: 1px solid var(--border-color);
padding: 10px;
border-radius: 4px;
font-family: 'Courier New', monospace;
resize: none;
}
.terminal {
background-color: var(--bg-dark);
padding: 15px;
border-top: 2px solid var(--border-color);
height: 200px;
overflow-y: auto;
font-family: 'Courier New', monospace;
font-size: 12px;
}
.terminal-line {
margin-bottom: 5px;
word-break: break-all;
}
.terminal-error {
color: #ff4141;
}
.terminal-log {
color: var(--matrix-green);
}
.terminal-info {
color: var(--matrix-cyan);
}
/* Login Modal */
.modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
.modal-content {
background-color: var(--panel-bg);
padding: 30px;
border: 2px solid var(--border-color);
border-radius: 8px;
width: 90%;
max-width: 500px;
}
.modal-header {
color: var(--matrix-cyan);
margin-bottom: 20px;
text-align: center;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 8px;
}
.form-group input, .form-group select {
width: 100%;
background-color: var(--bg-dark);
color: var(--matrix-green);
border: 1px solid var(--border-color);
padding: 10px;
border-radius: 4px;
font-family: 'Courier New', monospace;
}
.checkbox-group {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 20px;
}
/* Mobile Responsiveness */
@media (max-width: 768px) {
.app-container {
grid-template-columns: 1fr;
grid-template-rows: 60px 1fr 250px 200px;
}
.chat-panel {
grid-row: 3;
grid-column: 1;
border-left: none;
border-top: 2px solid var(--border-color);
}
.control-panel {
grid-template-columns: 1fr;
}
.branch-selector {
order: -1;
}
}
/* Scrollbar styling */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: var(--bg-darker);
}
::-webkit-scrollbar-thumb {
background: var(--border-color);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--matrix-green);
}
</style>
</head>
<body>
<div class="app-container">
<!-- Header -->
<div class="header">
<div class="logo">SCREEN AI WRAPPER</div>
<div class="server-selector">
<select class="server-dropdown" id="serverSelect">
<option value="main">Main Server</option>
<option value="simulation">Simulation Server</option>
<option value="ptr">PTR Server</option>
<option value="custom">Custom Server</option>
</select>
</div>
<div class="auth-status">
<i class="fas fa-user"></i>
<span id="authStatus">Nepřihlášen</span>
</div>
</div>
<!-- Game View -->
<div class="game-view">
<iframe class="game-iframe" id="screepsFrame" src="https://screeps.com"></iframe>
<div class="metrics-bar">
<div class="metric">
<div>CPU</div>
<div class="metric-value" id="cpuMetric">75%</div>
</div>
<div class="metric">
<div>GCL</div>
<div class="metric-value" id="gclMetric">5.2</div>
</div>
<div class="metric">
<div>Místnosti</div>
<div class="metric-value" id="roomsMetric">3/5</div>
</div>
<div class="metric">
<div>Creeps</div>
<div class="metric-value" id="creepsMetric">12</div>
</div>
</div>
</div>
<!-- Control Panel -->
<div class="control-panel">
<div class="folder-tree" id="folderTree">
<div class="folder-item active">server1</div>
<div class="file-item">main.js</div>
<div class="file-item">creeps.js</div>
<div class="file-item">structures.js</div>
<div class="folder-item">branches</div>
<div class="file-item">combat.js</div>
<div class="file-item">economy.js</div>
<div class="file-item">expansion.js</div>
</div>
<div class="branch-selector">
<select class="branch-dropdown" id="branchSelect">
<option value="main">main</option>
<option value="combat">combat</option>
<option value="economy">economy</option>
<option value="expansion">expansion</option>
</select>
<button class="btn" id="activateBranchBtn">
<i class="fas fa-play"></i> Aktivovat
</button>
</div>
<div class="action-buttons">
<button class="btn" id="deployBtn">
<i class="fas fa-upload"></i> Deploy
</button>
<button class="btn" id="optimizeBtn">
<i class="fas fa-rocket"></i> Optimize
</button>
<button class="btn" id="generateCodeBtn">
<i class="fas fa-code"></i> Generovat kód
</button>
<button class="btn" id="deleteBtn">
<i class="fas fa-trash"></i> Smazat
</button>
<button class="btn" id="settingsBtn">
<i class="fas fa-cog"></i> Nastavení
</button>
</div>
</div>
<!-- Chat Panel -->
<div class="chat-panel">
<div class="chat-header">AI Agent Chat</div>
<div class="chat-messages" id="chatMessages">
<div class="message ai-message">
Ahoj! Jsem Screeps AI Assistant. Jak ti mohu pomoci?
</div>
<div class="message user-message">
Vytvoř mi kód pro harvestery
</div>
<div class="message ai-message">
<pre><code>// Harvestery AI code
module.exports = {
run: function(creep) {
if(creep.store.getFreeCapacity() > 0) {
var sources = creep.room.find(FIND_SOURCES);
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0]);
}
} else {
if(creep.transfer(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(Game.spawns['Spawn1']);
}
}
}
};</code></pre>
</div>
</div>
<div class="chat-input">
<textarea id="messageInput" placeholder="Zadej příkaz pro AI agenta..."></textarea>
<button class="btn" id="sendBtn">
<i class="fas fa-paper-plane"></i>
</button>
</div>
<div class="terminal">
<div class="terminal-line terminal-info">[INFO] Screeps AI Wrapper inicializován</div>
<div class="terminal-line terminal-log">[LOG] CPU usage: 75%</div>
<div class="terminal-line terminal-error">[ERROR] Nenalezen soubor main.js</div>
<div class="terminal-line terminal-log">[LOG] Připojeno k serveru: main</div>
<div class="terminal-line terminal-info">[INFO] Větev 'economy' aktivována</div>
</div>
</div>
</div>
<!-- Login Modal -->
<div class="modal" id="loginModal">
<div class="modal-content">
<h2 class="modal-header">Přihlášení do Screeps</h2>
<div class="form-group">
<label for="serverType">Typ serveru:</label>
<select id="serverType">
<option value="official">Official Server</option>
<option value="custom">Custom Server</option>
</select>
</div>
<div class="form-group">
<label for="username">Uživatelské jméno:</label>
<input type="text" id="username" placeholder="Zadej uživatelské jméno">
</div>
<div class="form-group">
<label for="password">Heslo:</label>
<input type="password" id="password" placeholder="Zadej heslo">
</div>
<div class="form-group">
<label for="steamCode">Steam kód:</label>
<input type="text" id="steamCode" placeholder="Zadej 6-místný Steam kód">
</div>
<div class="form-group">
<label for="rootPath">Root cesta k serverům:</label>
<input type="text" id="rootPath" placeholder="/path/to/screeps/servers">
</div>
<div class="checkbox-group">
<input type="checkbox" id="rememberMe">
<label for="rememberMe">Zůstat přihlášen</label>
</div>
<button class="btn" id="loginBtn" style="width: 100%;">
<i class="fas fa-sign-in-alt"></i> Přihlásit se
</button>
</div>
</div>
<script>
// DOM Elements
const loginModal = document.getElementById('loginModal');
const authStatus = document.getElementById('authStatus');
const screepsFrame = document.getElementById('screepsFrame');
const serverSelect = document.getElementById('serverSelect');
const branchSelect = document.getElementById('branchSelect');
const chatMessages = document.getElementById('chatMessages');
const messageInput = document.getElementById('messageInput');
const folderTree = document.getElementById('folderTree');
// Sample data
let selectedFileTreeItem = null;
let isLoggedIn = false;
let credentials = JSON.parse(localStorage.getItem('screepsCredentials')) || null;
// Initialize
document.addEventListener('DOMContentLoaded', function() {
// Check if user has saved credentials
if (credentials) {
login(credentials);
} else {
loginModal.style.display = 'flex';
}
// Event listeners
document.getElementById('loginBtn').addEventListener('click', handleLogin);
document.getElementById('sendBtn').addEventListener('click', sendMessage);
messageInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
sendMessage();
}
});
serverSelect.addEventListener('change', function() {
const server = this.value;
if (server === 'custom') {
const customUrl = prompt('Zadej URL vlastního serveru:');
if (customUrl) {
screepsFrame.src = customUrl;
}
} else {
screepsFrame.src = `https://screeps.com/${server === 'main' ? '' : server}`;
}
});
branchSelect.addEventListener('change', function() {
// Branch selection change logic would go here
});
document.getElementById('activateBranchBtn').addEventListener('click', function() {
const branch = branchSelect.value;
this.classList.add('active');
setTimeout(() => this.classList.remove('active'), 200);
// Add terminal message
addTerminalMessage(`[INFO] Větev '${branch}' aktivována`, 'terminal-info');
});
// Action buttons
document.getElementById('deployBtn').addEventListener('click', function() {
this.classList.add('active');
setTimeout(() => this.classList.remove('active'), 200);
addTerminalMessage('[LOG] Deploying AI branch...', 'terminal-log');
setTimeout(() => addTerminalMessage('[INFO] Deploy success', 'terminal-info'), 1000);
});
document.getElementById('optimizeBtn').addEventListener('click', function() {
this.classList.add('active');
setTimeout(() => this.classList.remove('active'), 200);
addTerminalMessage('[LOG] Optimalizing code...', 'terminal-log');
setTimeout(() => addTerminalMessage('[INFO] Optimization complete', 'terminal-info'), 1500);
});
document.getElementById('generateCodeBtn').addEventListener('click', function() {
this.classList.add('active');
setTimeout(() => this.classList.remove('active'), 200);
addTerminalMessage('[LOG] Generating code...', 'terminal-log');
setTimeout(() => {
addTerminalMessage('[INFO] Code generated successfully', 'terminal-info');
addTerminalMessage('[LOG] Creeps: 12 (Optimized)', 'terminal-log');
}, 2000);
});
document.getElementById('settingsBtn').addEventListener('click', function() {
this.classList.add('active');
setTimeout(() => this.classList.remove('active'), 200);
alert('Otevřít nastavení');
});
document.getElementById('deleteBtn').addEventListener('click', function() {
this.classList.add('active');
setTimeout(() => this.classList.remove('active'), 200);
if (selectedFileTreeItem) {
if (confirm(`Opravdu chcete smazat ${selectedFileTreeItem.textContent}?`)) {
addTerminalMessage(`[INFO] Smazán soubor/složka: ${selectedFileTreeItem.textContent}`, 'terminal-info');
selectedFileTreeItem.remove();
selectedFileTreeItem = null;
}
} else {
alert('Nejprve vyberte soubor nebo složku ke smazání');
}
});
// File tree selection
folderTree.addEventListener('click', function(e) {
if (e.target.classList.contains('folder-item') || e.target.classList.contains('file-item')) {
// Remove previous selection
const activeItems = folderTree.querySelectorAll('.active');
activeItems.forEach(item => item.classList.remove('active'));
// Set new selection
e.target.classList.add('active');
selectedFileTreeItem = e.target;
}
});
// Update metrics periodically
setInterval(updateMetrics, 5000);
});
// Functions
function handleLogin() {
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const steamCode = document.getElementById('steamCode').value;
const rootPath = document.getElementById('rootPath').value;
const rememberMe = document.getElementById('rememberBtn').checked;
if (!username || !password || !steamCode) {
alert('Vyplňte všechna povinná pole');
return;
}
const creds = { username, password, steamCode, rootPath };
if (rememberMe) {
localStorage.setItem('screepsCredentials', JSON.stringify(creds));
}
login(creds);
}
function login(credentials) {
loginModal.style.display = 'none';
isLoggedIn = true;
authStatus.textContent = credentials.username;
addTerminalMessage('[INFO] Přihlášení úspěšné', 'terminal-info');
// Load folder tree based on root path
loadFolderTree(credentials.rootPath);
}
function sendMessage() {
const message = messageInput.value.trim();
if (!message) return;
// Add user message
addMessage(message, 'user-message');
messageInput.value = '';
// Simulate AI response
setTimeout(() => {
const responses = [
"Analyzuji váš požadavek...",
"Generuji optimalizovaný kód...",
"Připravuji strategický plán...",
"Kód byl aktualizován a nasazen.",
"Zjišťuji metriky z hry..."
];
const randomResponse = responses[Math.floor(Math.random() * responses.length)];
addMessage(randomResponse, 'ai-message');
// Add terminal response
addTerminalMessage(`[LOG] AI odpověď: ${randomResponse}`, 'terminal-log');
}, 1000);
}
function addMessage(text, className) {
const messageDiv = document.createElement('div');
messageDiv.classList.add('message', className);
messageDiv.textContent = text;
chatMessages.appendChild(messageDiv);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
function addTerminalMessage(text, className) {
const lineDiv = document.createElement('div');
lineDiv.classList.add('terminal-line', className);
lineDiv.textContent = text;
document.querySelector('.terminal').appendChild(lineDiv);
document.querySelector('.terminal').scrollTop = document.querySelector('.terminal').scrollHeight;
}
function loadFolderTree(rootPath) {
// In real implementation, this would load actual folder structure
// For now, we'll just show sample structure
addTerminalMessage(`[INFO] Načítám strukturu serverů z: ${rootPath}`, 'terminal-info');
}
function updateMetrics() {
// Simulate metric updates
document.getElementById('cpuMetric').textContent = Math.floor(Math.random() * 30 + 60) + '%';
document.getElementById('gclMetric').textContent = (Math.random() * 3 + 3).toFixed(1);
document.getElementById('roomsMetric').textContent = `${Math.floor(Math.random() * 3 + 2)}/5`;
document.getElementById('creepsMetric').textContent = Math.floor(Math.random() * 15 + 5);
}
// Close modal if clicked outside content
window.addEventListener('click', function(e) {
if (e.target === loginModal) {
loginModal.style.display = 'none';
}
});
</script>
</body>
</html> |