| 1 | // Terminal interface for secret commands
|
| 2 |
|
| 3 | const TerminalPage = {
|
| 4 | render() {
|
| 5 | return `
|
| 6 | <section class="hero">
|
| 7 | <h1>ARCHIVE TERMINAL</h1>
|
| 8 | <p class="lead">Command line interface for archive access.</p>
|
| 9 | </section>
|
| 10 |
|
| 11 | <section class="panel terminal-panel">
|
| 12 | <div id="terminal" class="terminal">
|
| 13 | <div class="terminal-line">>>> ARCHIVE TERMINAL v2.1</div>
|
| 14 | <div class="terminal-line">>>> Type 'help' for available commands</div>
|
| 15 | <div class="terminal-line"></div>
|
| 16 | </div>
|
| 17 | <input type="text" id="terminal-input" class="terminal-input" placeholder="Enter command..." autocomplete="off" />
|
| 18 | </section>
|
| 19 | `;
|
| 20 | },
|
| 21 |
|
| 22 | attach() {
|
| 23 | const input = document.getElementById('terminal-input');
|
| 24 | const terminal = document.getElementById('terminal');
|
| 25 |
|
| 26 | input.addEventListener('keypress', (e) => {
|
| 27 | if (e.key === 'Enter') {
|
| 28 | const command = input.value.trim().toLowerCase();
|
| 29 | input.value = '';
|
| 30 |
|
| 31 | this.addLine(`> ${command}`);
|
| 32 | this.executeCommand(command);
|
| 33 | terminal.scrollTop = terminal.scrollHeight;
|
| 34 | }
|
| 35 | });
|
| 36 | },
|
| 37 |
|
| 38 | addLine(text) {
|
| 39 | const terminal = document.getElementById('terminal');
|
| 40 | const line = document.createElement('div');
|
| 41 | line.className = 'terminal-line';
|
| 42 | line.textContent = text;
|
| 43 | terminal.appendChild(line);
|
| 44 | },
|
| 45 |
|
| 46 | executeCommand(command) {
|
| 47 | const commands = {
|
| 48 | 'help': () => {
|
| 49 | this.addLine('Available commands:');
|
| 50 | this.addLine(' status - Current archive status');
|
| 51 | this.addLine(' progress - Completion percentage');
|
| 52 | this.addLine(' inventory - List collected items');
|
| 53 | this.addLine(' secrets - Show discovered secrets');
|
| 54 | this.addLine(' decrypt [text] - Quick caesar decoder (shift 3)');
|
| 55 | },
|
| 56 | 'status': () => {
|
| 57 | this.addLine(`Archive Status: ACT ${GameState.currentAct + 1}/5`);
|
| 58 | this.addLine(`Puzzles Solved: ${GameState.solvedPuzzles.size}`);
|
| 59 | this.addLine(`Secrets Found: ${GameState.discoveredSecrets.size}`);
|
| 60 | },
|
| 61 | 'progress': () => {
|
| 62 | this.addLine(`Progress: ${GameState.getCompletion()}%`);
|
| 63 | },
|
| 64 | 'inventory': () => {
|
| 65 | if (GameState.inventory.items.size === 0) {
|
| 66 | this.addLine('Inventory empty.');
|
| 67 | } else {
|
| 68 | GameState.inventory.items.forEach((item, id) => {
|
| 69 | this.addLine(`[${id}] ${item.name}`);
|
| 70 | });
|
| 71 | }
|
| 72 | }
|
| 73 | };
|
| 74 |
|
| 75 | if (command.startsWith('decrypt ')) {
|
| 76 | const text = command.replace('decrypt ', '');
|
| 77 | const result = Ciphers.caesar(text, 3);
|
| 78 | this.addLine(result);
|
| 79 | } else if (commands[command]) {
|
| 80 | commands[command]();
|
| 81 | } else {
|
| 82 | this.addLine('Unknown command. Type "help" for options.');
|
| 83 | }
|
| 84 | }
|
| 85 | };
|