terminull-arcade 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -182,6 +182,67 @@ var ALL_GAMES_METADATA = {
182
182
  { id: "perfect_streak", title: "Architectural Perfection", description: "Land 3 consecutive PERFECT drops" },
183
183
  { id: "stratosphere", title: "Orbit Reached", description: "Build a skyscraper 30 floors high" }
184
184
  ]
185
+ },
186
+ "byte-hopper": {
187
+ id: "byte-hopper",
188
+ name: "Byte Hopper",
189
+ tagline: "Dodge speeding highway packets and leap across memory rivers",
190
+ description: "The definitive terminal lane-dodger: hop your data frog across multi-lane high-speed traffic, balance on drifting memory logs, avoid digital river hazards, and fill all five destination sockets.",
191
+ category: "arcade",
192
+ difficultyLevels: ["easy", "normal", "hard", "insane"],
193
+ controls: [
194
+ { key: "Arrow Keys / WASD", action: "Hop Direction", description: "Leap one lane or column" },
195
+ { key: "Esc / P", action: "Pause Menu", description: "Open pause / exit dialog" },
196
+ { key: "R", action: "Restart Game", description: "Restart current round" },
197
+ { key: "Q", action: "Quit", description: "Return to arcade menu" }
198
+ ],
199
+ achievements: [
200
+ { id: "first_hop", title: "First Leap", description: "Cross the highway and leap onto a river log" },
201
+ { id: "socket_filled", title: "Data Linked", description: "Safely land in your first destination socket" },
202
+ { id: "all_sockets_cleared", title: "Full Protocol Cleared", description: "Fill all 5 destination sockets in a wave" }
203
+ ]
204
+ },
205
+ "cyber-sweeper": {
206
+ id: "cyber-sweeper",
207
+ name: "Cyber Sweeper",
208
+ tagline: "Probe corrupted memory matrices and flag hidden logic bombs",
209
+ description: "The definitive terminal minesweeper: navigate a corrupted digital sector, analyze adjacent threat proximity counts, flag hidden logic bombs, and chain recursive cascades to cleanse the matrix.",
210
+ category: "puzzle",
211
+ difficultyLevels: ["easy", "normal", "hard", "insane"],
212
+ controls: [
213
+ { key: "Arrow Keys / WASD", action: "Move Reticle", description: "Navigate cursor across sector grid" },
214
+ { key: "Space / Enter", action: "Probe Sector", description: "Reveal cell and trigger cascade reveals" },
215
+ { key: "F", action: "Flag / Unflag", description: "Mark suspicious cell with warning beacon" },
216
+ { key: "C", action: "Chord Probe", description: "Quick-reveal unflagged neighbors on satisfied cells" },
217
+ { key: "Esc / P", action: "Pause Menu", description: "Open pause / exit dialog" },
218
+ { key: "R", action: "Restart Game", description: "Generate fresh minefield seed" },
219
+ { key: "Q", action: "Quit", description: "Return to arcade menu" }
220
+ ],
221
+ achievements: [
222
+ { id: "first_sweep", title: "First Cleared", description: "Successfully probe your first safe memory sector" },
223
+ { id: "mine_defused", title: "Protocol Flagged", description: "Flag all corrupted sectors accurately" },
224
+ { id: "sector_cleansed", title: "Master Sweeper", description: "Clear an entire minefield sector without detonating" }
225
+ ]
226
+ },
227
+ "neon-flap": {
228
+ id: "neon-flap",
229
+ name: "Neon Flap",
230
+ tagline: "Pilot an agile cyber-probe through pulsating laser firewall gates",
231
+ description: "The definitive terminal gravity-flyer: activate directional vertical thrusters, navigate through high-voltage firewall conduit gaps, avoid floor and ceiling barriers, and master momentum in cyber-space.",
232
+ category: "arcade",
233
+ difficultyLevels: ["easy", "normal", "hard", "insane"],
234
+ controls: [
235
+ { key: "Space / Up / W", action: "Thruster Flap", description: "Fire vertical plasma impulse" },
236
+ { key: "Esc / P", action: "Pause Menu", description: "Open pause / exit dialog" },
237
+ { key: "R", action: "Quick Reboot", description: "Restart current flight run" },
238
+ { key: "Q", action: "Quit", description: "Return to arcade menu" }
239
+ ],
240
+ achievements: [
241
+ { id: "first_gate", title: "First Breach", description: "Successfully clear your first firewall conduit gate" },
242
+ { id: "cyber_aviator", title: "Cyber Aviator", description: "Navigate through 10 firewall gates in a single run" },
243
+ { id: "quantum_pilot", title: "Quantum Pilot", description: "Reach 25 cleared gates with unbroken cyber momentum" },
244
+ { id: "flawless_vector", title: "Flawless Vector", description: "Land 3 consecutive dead-center conduit passes" }
245
+ ]
185
246
  }
186
247
  };
187
248
 
@@ -5828,6 +5889,1698 @@ var CyberTowerGame = class {
5828
5889
  }
5829
5890
  };
5830
5891
 
5892
+ // src/games/byte-hopper/index.ts
5893
+ import chalk6 from "chalk";
5894
+ var ARENA_WIDTH5 = 48;
5895
+ var ARENA_ROWS = 12;
5896
+ var TOTAL_WIDTH3 = 54;
5897
+ var START_X = 23;
5898
+ var START_Y = 11;
5899
+ var ByteHopperGame = class {
5900
+ id = "byte-hopper";
5901
+ metadata = ALL_GAMES_METADATA["byte-hopper"];
5902
+ config = null;
5903
+ renderer = defaultRenderer;
5904
+ input = new TerminalInputHandler();
5905
+ rng = new DeterministicRNG();
5906
+ gameLoopTimer = null;
5907
+ secondTimer = null;
5908
+ tickIntervalMs = 50;
5909
+ // Smooth 20 FPS game loop
5910
+ nextObstacleId = 1;
5911
+ speedMultiplier = 1;
5912
+ baseTimeLimit = 35;
5913
+ state = {
5914
+ playerX: START_X,
5915
+ playerY: START_Y,
5916
+ lives: 3,
5917
+ score: 0,
5918
+ highScore: 0,
5919
+ level: 1,
5920
+ timeRemainingSec: 35,
5921
+ goalSockets: [],
5922
+ lanes: [],
5923
+ isDying: false,
5924
+ deathTicks: 0,
5925
+ isGameOver: false,
5926
+ isWon: false,
5927
+ highestRowReached: START_Y
5928
+ };
5929
+ isPaused = false;
5930
+ pauseMenuIndex = 0;
5931
+ showTutorial = true;
5932
+ deathMessage = "";
5933
+ init(config) {
5934
+ this.config = config;
5935
+ this.renderer.setTheme(config.theme);
5936
+ this.rng = new DeterministicRNG(config.seed || Date.now());
5937
+ if (config.skipTutorial !== void 0) {
5938
+ this.showTutorial = !config.skipTutorial;
5939
+ }
5940
+ this.applyDifficulty(config.difficulty);
5941
+ this.resetGame();
5942
+ }
5943
+ start() {
5944
+ this.isPaused = false;
5945
+ this.render();
5946
+ this.input.start(
5947
+ (key) => this.handleInput(key),
5948
+ () => {
5949
+ this.destroy();
5950
+ this.config?.onExit?.();
5951
+ }
5952
+ );
5953
+ if (!this.showTutorial) {
5954
+ this.scheduleNextTick();
5955
+ this.startSecondTimer();
5956
+ }
5957
+ }
5958
+ pause() {
5959
+ this.isPaused = true;
5960
+ this.clearTimers();
5961
+ }
5962
+ resume() {
5963
+ this.isPaused = false;
5964
+ this.scheduleNextTick();
5965
+ this.startSecondTimer();
5966
+ }
5967
+ restart() {
5968
+ this.resetGame();
5969
+ this.render();
5970
+ this.scheduleNextTick();
5971
+ this.startSecondTimer();
5972
+ }
5973
+ saveState() {
5974
+ return {
5975
+ state: this.state,
5976
+ showTutorial: this.showTutorial
5977
+ };
5978
+ }
5979
+ loadState(saved) {
5980
+ if (saved["state"]) this.state = saved["state"];
5981
+ if (saved["showTutorial"] !== void 0) this.showTutorial = !!saved["showTutorial"];
5982
+ }
5983
+ getState() {
5984
+ return this.state;
5985
+ }
5986
+ handleInputForTest(key) {
5987
+ this.handleInput(key);
5988
+ }
5989
+ destroy() {
5990
+ this.clearTimers();
5991
+ this.input.stop();
5992
+ }
5993
+ clearTimers() {
5994
+ if (this.gameLoopTimer) {
5995
+ clearTimeout(this.gameLoopTimer);
5996
+ this.gameLoopTimer = null;
5997
+ }
5998
+ if (this.secondTimer) {
5999
+ clearInterval(this.secondTimer);
6000
+ this.secondTimer = null;
6001
+ }
6002
+ }
6003
+ startSecondTimer() {
6004
+ if (this.secondTimer) clearInterval(this.secondTimer);
6005
+ this.secondTimer = setInterval(() => {
6006
+ if (this.isPaused || this.showTutorial || this.state.isGameOver || this.state.isDying) return;
6007
+ this.state.timeRemainingSec--;
6008
+ if (this.state.timeRemainingSec <= 0) {
6009
+ this.triggerDeath("TIME EXPIRED!");
6010
+ }
6011
+ this.render();
6012
+ }, 1e3);
6013
+ }
6014
+ applyDifficulty(diff) {
6015
+ switch (diff) {
6016
+ case "easy":
6017
+ this.state.lives = 4;
6018
+ this.speedMultiplier = 0.75;
6019
+ this.baseTimeLimit = 45;
6020
+ break;
6021
+ case "hard":
6022
+ this.state.lives = 2;
6023
+ this.speedMultiplier = 1.25;
6024
+ this.baseTimeLimit = 25;
6025
+ break;
6026
+ case "insane":
6027
+ this.state.lives = 1;
6028
+ this.speedMultiplier = 1.5;
6029
+ this.baseTimeLimit = 20;
6030
+ break;
6031
+ case "normal":
6032
+ default:
6033
+ this.state.lives = 3;
6034
+ this.speedMultiplier = 1;
6035
+ this.baseTimeLimit = 35;
6036
+ break;
6037
+ }
6038
+ }
6039
+ resetGame() {
6040
+ this.state.score = 0;
6041
+ this.state.level = 1;
6042
+ this.state.isGameOver = false;
6043
+ this.state.isWon = false;
6044
+ this.state.isDying = false;
6045
+ this.state.deathTicks = 0;
6046
+ this.initGoalSockets();
6047
+ this.initLanes();
6048
+ this.resetPlayerPosition();
6049
+ }
6050
+ initGoalSockets() {
6051
+ this.state.goalSockets = [
6052
+ { index: 0, x: 4, filled: false },
6053
+ { index: 1, x: 13, filled: false },
6054
+ { index: 2, x: 22, filled: false },
6055
+ { index: 3, x: 31, filled: false },
6056
+ { index: 4, x: 40, filled: false }
6057
+ ];
6058
+ }
6059
+ resetPlayerPosition() {
6060
+ this.state.playerX = START_X;
6061
+ this.state.playerY = START_Y;
6062
+ this.state.highestRowReached = START_Y;
6063
+ this.state.timeRemainingSec = this.baseTimeLimit;
6064
+ }
6065
+ initLanes() {
6066
+ const s = this.speedMultiplier;
6067
+ this.state.lanes = [
6068
+ // Row 0: Goal Sockets (handled separately)
6069
+ { row: 0, type: "goal", speed: 0, obstacles: [], obstacleWidth: 0, obstacleType: "car", spacing: 0 },
6070
+ // Row 1: River Bank Shore (safe ground)
6071
+ { row: 1, type: "safe", speed: 0, obstacles: [], obstacleWidth: 0, obstacleType: "car", spacing: 0 },
6072
+ // River Lanes (Rows 2, 3, 4, 5)
6073
+ // Row 2: Medium Logs floating Right
6074
+ this.createLane(2, "river", 0.35 * s, 7, "log", 16),
6075
+ // Row 3: Diving Cyber Turtles floating Left
6076
+ this.createLane(3, "river", -0.45 * s, 5, "turtle", 14),
6077
+ // Row 4: Long Memory Bus floating Right
6078
+ this.createLane(4, "river", 0.3 * s, 11, "long_log", 20),
6079
+ // Row 5: Fast Turtles floating Left
6080
+ this.createLane(5, "river", -0.55 * s, 4, "turtle", 12),
6081
+ // Row 6: Median Strip (safe ground)
6082
+ { row: 6, type: "safe", speed: 0, obstacles: [], obstacleWidth: 0, obstacleType: "car", spacing: 0 },
6083
+ // Road Lanes (Rows 7, 8, 9, 10)
6084
+ // Row 7: Race Cars moving Left
6085
+ this.createLane(7, "road", -0.65 * s, 4, "racer", 15),
6086
+ // Row 8: Heavy Firewall Trucks moving Right
6087
+ this.createLane(8, "road", 0.35 * s, 7, "truck", 18),
6088
+ // Row 9: Packet Cars moving Left
6089
+ this.createLane(9, "road", -0.45 * s, 4, "car", 14),
6090
+ // Row 10: Slow Data Tractors moving Right
6091
+ this.createLane(10, "road", 0.3 * s, 4, "tractor", 13),
6092
+ // Row 11: Starting Sidewalk (safe ground)
6093
+ { row: 11, type: "safe", speed: 0, obstacles: [], obstacleWidth: 0, obstacleType: "car", spacing: 0 }
6094
+ ];
6095
+ }
6096
+ createLane(row, type, speed, obstacleWidth, obstacleType, spacing) {
6097
+ const obstacles = [];
6098
+ const count = Math.ceil(ARENA_WIDTH5 / spacing) + 1;
6099
+ for (let i = 0; i < count; i++) {
6100
+ obstacles.push({
6101
+ id: this.nextObstacleId++,
6102
+ x: i * spacing,
6103
+ width: obstacleWidth,
6104
+ type: obstacleType
6105
+ });
6106
+ }
6107
+ return {
6108
+ row,
6109
+ type,
6110
+ speed,
6111
+ obstacles,
6112
+ obstacleWidth,
6113
+ obstacleType,
6114
+ spacing
6115
+ };
6116
+ }
6117
+ scheduleNextTick() {
6118
+ if (this.isPaused || this.state.isGameOver || this.showTutorial) return;
6119
+ this.gameLoopTimer = setTimeout(() => {
6120
+ this.tick();
6121
+ this.scheduleNextTick();
6122
+ }, this.tickIntervalMs);
6123
+ }
6124
+ tick() {
6125
+ if (this.isPaused || this.showTutorial || this.state.isGameOver) return;
6126
+ if (this.state.isDying) {
6127
+ this.state.deathTicks--;
6128
+ if (this.state.deathTicks <= 0) {
6129
+ this.state.isDying = false;
6130
+ if (this.state.lives <= 0) {
6131
+ this.state.isGameOver = true;
6132
+ this.config?.onGameOver?.(this.state.score);
6133
+ } else {
6134
+ this.resetPlayerPosition();
6135
+ }
6136
+ }
6137
+ this.render();
6138
+ return;
6139
+ }
6140
+ for (const lane of this.state.lanes) {
6141
+ if (lane.speed === 0) continue;
6142
+ for (const obs of lane.obstacles) {
6143
+ obs.x += lane.speed;
6144
+ if (lane.speed > 0 && obs.x > ARENA_WIDTH5) {
6145
+ obs.x = -obs.width;
6146
+ } else if (lane.speed < 0 && obs.x < -obs.width) {
6147
+ obs.x = ARENA_WIDTH5;
6148
+ }
6149
+ }
6150
+ }
6151
+ const currentLane = this.state.lanes[this.state.playerY];
6152
+ if (!currentLane) return;
6153
+ if (currentLane.type === "road") {
6154
+ for (const obs of currentLane.obstacles) {
6155
+ if (this.state.playerX >= obs.x && this.state.playerX < obs.x + obs.width) {
6156
+ this.triggerDeath("CRASHED INTO A HIGHWAY PACKET!");
6157
+ return;
6158
+ }
6159
+ }
6160
+ } else if (currentLane.type === "river") {
6161
+ const riding = currentLane.obstacles.find(
6162
+ (obs) => this.state.playerX >= obs.x && this.state.playerX < obs.x + obs.width
6163
+ );
6164
+ if (riding) {
6165
+ this.state.playerX += currentLane.speed;
6166
+ this.config?.onAchievementUnlock?.("first_hop");
6167
+ if (this.state.playerX < 0 || this.state.playerX >= ARENA_WIDTH5) {
6168
+ this.triggerDeath("SWEPT OFFSCREEN BY DIGITAL STREAM!");
6169
+ return;
6170
+ }
6171
+ } else {
6172
+ this.triggerDeath("DROWNED IN THE DIGITAL RIVER!");
6173
+ return;
6174
+ }
6175
+ }
6176
+ this.render();
6177
+ }
6178
+ triggerDeath(msg) {
6179
+ if (this.state.isDying) return;
6180
+ this.state.lives--;
6181
+ this.state.isDying = true;
6182
+ this.state.deathTicks = 4;
6183
+ this.deathMessage = msg;
6184
+ if (this.config?.soundEnabled) playTerminalBell();
6185
+ this.render();
6186
+ }
6187
+ handleHop(dx, dy) {
6188
+ if (this.state.isDying || this.state.isGameOver || this.isPaused || this.showTutorial) return;
6189
+ const newX = Math.max(1, Math.min(ARENA_WIDTH5 - 2, this.state.playerX + dx));
6190
+ const newY = Math.max(0, Math.min(11, this.state.playerY + dy));
6191
+ if (newY === 0) {
6192
+ const socket = this.state.goalSockets.find((s) => Math.abs(newX - s.x) <= 2);
6193
+ if (socket) {
6194
+ if (socket.filled) {
6195
+ this.triggerDeath("DESTINATION SOCKET ALREADY OCCUPIED!");
6196
+ return;
6197
+ }
6198
+ socket.filled = true;
6199
+ const timeBonus = this.state.timeRemainingSec * 10;
6200
+ this.addScore(250 + timeBonus);
6201
+ this.config?.onAchievementUnlock?.("socket_filled");
6202
+ if (this.config?.soundEnabled) playTerminalBell();
6203
+ if (this.state.goalSockets.every((s) => s.filled)) {
6204
+ this.handleWaveCleared();
6205
+ } else {
6206
+ this.resetPlayerPosition();
6207
+ }
6208
+ this.render();
6209
+ return;
6210
+ } else {
6211
+ if (this.config?.soundEnabled) playTerminalBell();
6212
+ return;
6213
+ }
6214
+ }
6215
+ if (newY < this.state.highestRowReached) {
6216
+ this.addScore(10);
6217
+ this.state.highestRowReached = newY;
6218
+ if (newY <= 5) {
6219
+ this.config?.onAchievementUnlock?.("first_hop");
6220
+ }
6221
+ }
6222
+ this.state.playerX = newX;
6223
+ this.state.playerY = newY;
6224
+ if (this.config?.soundEnabled) playTerminalBell();
6225
+ this.render();
6226
+ }
6227
+ handleWaveCleared() {
6228
+ this.addScore(1e3);
6229
+ this.state.level++;
6230
+ this.config?.onAchievementUnlock?.("all_sockets_cleared");
6231
+ this.speedMultiplier *= 1.12;
6232
+ this.initGoalSockets();
6233
+ this.initLanes();
6234
+ this.resetPlayerPosition();
6235
+ if (this.config?.soundEnabled) playTerminalBell();
6236
+ }
6237
+ addScore(pts) {
6238
+ this.state.score += pts;
6239
+ if (this.state.score > this.state.highScore) {
6240
+ this.state.highScore = this.state.score;
6241
+ }
6242
+ this.config?.onScoreUpdate?.(this.state.score);
6243
+ }
6244
+ handleInput(key) {
6245
+ if (this.showTutorial) {
6246
+ if (key.name === "return" || key.name === "space") {
6247
+ this.showTutorial = false;
6248
+ this.scheduleNextTick();
6249
+ this.startSecondTimer();
6250
+ this.render();
6251
+ } else if (key.name === "escape" || key.name === "q") {
6252
+ this.destroy();
6253
+ this.config?.onExit?.();
6254
+ }
6255
+ return;
6256
+ }
6257
+ if (this.isPaused) {
6258
+ if (key.name === "up" || key.name === "w") {
6259
+ this.pauseMenuIndex = (this.pauseMenuIndex - 1 + 3) % 3;
6260
+ this.render();
6261
+ } else if (key.name === "down" || key.name === "s") {
6262
+ this.pauseMenuIndex = (this.pauseMenuIndex + 1) % 3;
6263
+ this.render();
6264
+ } else if (key.name === "return" || key.name === "space") {
6265
+ if (this.pauseMenuIndex === 0) {
6266
+ this.isPaused = false;
6267
+ this.scheduleNextTick();
6268
+ this.startSecondTimer();
6269
+ this.render();
6270
+ } else if (this.pauseMenuIndex === 1) {
6271
+ this.isPaused = false;
6272
+ this.restart();
6273
+ } else if (this.pauseMenuIndex === 2) {
6274
+ this.destroy();
6275
+ this.config?.onExit?.();
6276
+ }
6277
+ } else if (key.name === "escape" || key.name === "p") {
6278
+ this.isPaused = false;
6279
+ this.scheduleNextTick();
6280
+ this.startSecondTimer();
6281
+ this.render();
6282
+ } else if (key.name === "q") {
6283
+ this.destroy();
6284
+ this.config?.onExit?.();
6285
+ }
6286
+ return;
6287
+ }
6288
+ if (key.name === "escape" || key.name === "p") {
6289
+ this.isPaused = true;
6290
+ this.pauseMenuIndex = 0;
6291
+ this.clearTimers();
6292
+ this.render();
6293
+ return;
6294
+ }
6295
+ if (key.name === "q") {
6296
+ this.destroy();
6297
+ this.config?.onExit?.();
6298
+ return;
6299
+ }
6300
+ if (key.name === "r") {
6301
+ this.restart();
6302
+ return;
6303
+ }
6304
+ if (this.state.isGameOver) {
6305
+ if (key.name === "return" || key.name === "space" || key.name === "r") {
6306
+ this.resetGame();
6307
+ this.render();
6308
+ this.scheduleNextTick();
6309
+ this.startSecondTimer();
6310
+ }
6311
+ return;
6312
+ }
6313
+ if (key.name === "up" || key.name === "w") {
6314
+ this.handleHop(0, -1);
6315
+ } else if (key.name === "down" || key.name === "s") {
6316
+ this.handleHop(0, 1);
6317
+ } else if (key.name === "left" || key.name === "a") {
6318
+ this.handleHop(-2, 0);
6319
+ } else if (key.name === "right" || key.name === "d") {
6320
+ this.handleHop(2, 0);
6321
+ }
6322
+ }
6323
+ render() {
6324
+ const t = this.renderer.getTheme();
6325
+ if (this.showTutorial) {
6326
+ const lines = [
6327
+ "",
6328
+ t.highlight("BYTE HOPPER // PROTOCOL CROSSING"),
6329
+ "",
6330
+ "\u2022 Guide your Byte Hopper from the bottom sidewalk to the top sockets.",
6331
+ "\u2022 ZONE 1 (HIGHWAY): Dodge speeding data cars, racers, and firewall trucks.",
6332
+ "\u2022 ZONE 2 (RIVER): Leap onto drifting memory logs and cyber turtles.",
6333
+ "\u2022 Stepping into open digital water or crashing into traffic is LETHAL.",
6334
+ "\u2022 Fill all 5 destination sockets to clear the security wave.",
6335
+ "",
6336
+ t.muted("Controls:"),
6337
+ " Arrow Keys / WASD : Hop 1 Cell in Direction",
6338
+ " P / Esc : Pause System",
6339
+ " R : Instant Restart",
6340
+ " Q : Quit to Arcade Menu",
6341
+ "",
6342
+ t.highlight("Press [ENTER] or [SPACE] to Initialize Hopper..."),
6343
+ ""
6344
+ ];
6345
+ const box2 = this.renderer.createBox(lines, TOTAL_WIDTH3, "MISSION BRIEFING");
6346
+ this.renderer.draw(this.renderer.centerBlock(box2, TOTAL_WIDTH3));
6347
+ return;
6348
+ }
6349
+ if (this.isPaused) {
6350
+ const menuItems = ["RESUME HOPPER", "RESTART MISSION", "EXIT TO ROSTER"];
6351
+ const lines = [
6352
+ "",
6353
+ t.highlight("BYTE HOPPER // PROTOCOL PAUSED"),
6354
+ "",
6355
+ ...menuItems.map((item, idx) => {
6356
+ if (idx === this.pauseMenuIndex) {
6357
+ return t.highlight(` \u25BA [ ${item} ]`);
6358
+ }
6359
+ return t.muted(` ${item} `);
6360
+ }),
6361
+ "",
6362
+ t.muted("Use Up/Down to select, Enter to confirm"),
6363
+ ""
6364
+ ];
6365
+ const box2 = this.renderer.createBox(lines, TOTAL_WIDTH3, "SYSTEM PAUSED");
6366
+ this.renderer.draw(this.renderer.centerBlock(box2, TOTAL_WIDTH3));
6367
+ return;
6368
+ }
6369
+ if (this.state.isGameOver) {
6370
+ const lines = [
6371
+ "",
6372
+ t.error("COMMUNICATION SEVERED // HOPPER DERAILED"),
6373
+ "",
6374
+ this.deathMessage ? t.error(`Failure: ${this.deathMessage}`) : "",
6375
+ `Final Score: ${t.highlight(this.state.score.toLocaleString())}`,
6376
+ `Sectors Reached: ${t.secondary(this.state.level.toString())}`,
6377
+ `Sockets Linked: ${t.secondary(this.state.goalSockets.filter((s) => s.filled).length.toString() + " / 5")}`,
6378
+ "",
6379
+ t.highlight("Press [R] or [SPACE] to Retry Crossing"),
6380
+ t.muted("Press [Q] to Return to Arcade Roster"),
6381
+ ""
6382
+ ].filter(Boolean);
6383
+ const box2 = this.renderer.createBox(lines, TOTAL_WIDTH3, "MISSION DEFEAT");
6384
+ this.renderer.draw(this.renderer.centerBlock(box2, TOTAL_WIDTH3));
6385
+ return;
6386
+ }
6387
+ const livesStr = "\u2665 ".repeat(Math.max(0, this.state.lives));
6388
+ const scoreStr = `SCORE: ${this.state.score.toLocaleString()}`;
6389
+ const timeStr = `TIME: ${this.state.timeRemainingSec}s`;
6390
+ const levelStr = `SECTOR ${this.state.level}`;
6391
+ const topBar = `${t.secondary(levelStr)} ${t.highlight(scoreStr)} ${t.accent(timeStr)} ${t.error(livesStr)}`;
6392
+ const grid = Array.from(
6393
+ { length: ARENA_ROWS },
6394
+ () => Array.from({ length: ARENA_WIDTH5 }, () => " ")
6395
+ );
6396
+ for (let c = 0; c < ARENA_WIDTH5; c++) {
6397
+ grid[0][c] = "\u2593";
6398
+ }
6399
+ for (const socket of this.state.goalSockets) {
6400
+ const sx = socket.x;
6401
+ grid[0][sx] = "[";
6402
+ grid[0][sx + 1] = socket.filled ? "\u2605" : " ";
6403
+ grid[0][sx + 2] = "]";
6404
+ }
6405
+ for (let c = 0; c < ARENA_WIDTH5; c++) {
6406
+ grid[1][c] = "\u2593";
6407
+ }
6408
+ for (let r = 2; r <= 5; r++) {
6409
+ for (let c = 0; c < ARENA_WIDTH5; c++) {
6410
+ grid[r][c] = "\u2248";
6411
+ }
6412
+ const lane = this.state.lanes[r];
6413
+ for (const obs of lane.obstacles) {
6414
+ const ox = Math.round(obs.x);
6415
+ for (let i = 0; i < obs.width; i++) {
6416
+ const gx = ox + i;
6417
+ if (gx >= 0 && gx < ARENA_WIDTH5) {
6418
+ if (obs.type === "log" || obs.type === "long_log") {
6419
+ if (i === 0) grid[r][gx] = "[";
6420
+ else if (i === obs.width - 1) grid[r][gx] = "]";
6421
+ else grid[r][gx] = "\u2550";
6422
+ } else if (obs.type === "turtle") {
6423
+ if (i === 0) grid[r][gx] = "<";
6424
+ else if (i === obs.width - 1) grid[r][gx] = ">";
6425
+ else grid[r][gx] = "\u25CF";
6426
+ }
6427
+ }
6428
+ }
6429
+ }
6430
+ }
6431
+ for (let c = 0; c < ARENA_WIDTH5; c++) {
6432
+ grid[6][c] = "\u2591";
6433
+ }
6434
+ for (let r = 7; r <= 10; r++) {
6435
+ const lane = this.state.lanes[r];
6436
+ for (const obs of lane.obstacles) {
6437
+ const ox = Math.round(obs.x);
6438
+ for (let i = 0; i < obs.width; i++) {
6439
+ const gx = ox + i;
6440
+ if (gx >= 0 && gx < ARENA_WIDTH5) {
6441
+ if (obs.type === "truck") {
6442
+ if (i === 0) grid[r][gx] = "[";
6443
+ else if (i === obs.width - 1) grid[r][gx] = "]";
6444
+ else grid[r][gx] = "\u2588";
6445
+ } else if (obs.type === "racer") {
6446
+ if (i === 0) grid[r][gx] = "\u25C4";
6447
+ else if (i === obs.width - 1) grid[r][gx] = "\u25BA";
6448
+ else grid[r][gx] = "\u25A0";
6449
+ } else if (obs.type === "car") {
6450
+ if (i === 0) grid[r][gx] = "\u25C4";
6451
+ else if (i === obs.width - 1) grid[r][gx] = "\u25BA";
6452
+ else grid[r][gx] = "\u2550";
6453
+ } else {
6454
+ grid[r][gx] = "\u2593";
6455
+ }
6456
+ }
6457
+ }
6458
+ }
6459
+ }
6460
+ for (let c = 0; c < ARENA_WIDTH5; c++) {
6461
+ grid[11][c] = "\u2591";
6462
+ }
6463
+ const py = this.state.playerY;
6464
+ const px = Math.round(this.state.playerX);
6465
+ if (py >= 0 && py < ARENA_ROWS && px >= 0 && px < ARENA_WIDTH5) {
6466
+ grid[py][px] = this.state.isDying ? "\u{1F4A5}" : "\u25B2";
6467
+ }
6468
+ const arenaLines = [];
6469
+ for (let r = 0; r < ARENA_ROWS; r++) {
6470
+ let line = "";
6471
+ for (let c = 0; c < ARENA_WIDTH5; c++) {
6472
+ const char = grid[r][c];
6473
+ if (r === py && c === px) {
6474
+ line += this.state.isDying ? chalk6.red("\u{1F4A5}") : chalk6.bold.greenBright("\u25B2");
6475
+ } else if (r === 0) {
6476
+ if (char === "\u2605") line += chalk6.bold.yellowBright("\u2605");
6477
+ else if (char === "[" || char === "]") line += chalk6.greenBright(char);
6478
+ else line += chalk6.hex("#1b5e20")("\u2593");
6479
+ } else if (r === 1) {
6480
+ line += chalk6.hex("#1b5e20")("\u2593");
6481
+ } else if (r >= 2 && r <= 5) {
6482
+ if (char === "\u2248") line += chalk6.hex("#0d47a1")("\u2248");
6483
+ else if (char === "[" || char === "]" || char === "\u2550") line += chalk6.hex("#a1887f")(char);
6484
+ else if (char === "<" || char === ">" || char === "\u25CF") line += chalk6.hex("#4dd0e1")(char);
6485
+ else line += char;
6486
+ } else if (r === 6 || r === 11) {
6487
+ line += chalk6.hex("#616161")("\u2591");
6488
+ } else if (r >= 7 && r <= 10) {
6489
+ if (char === "\u2588" || char === "[" || char === "]") line += chalk6.hex("#d50000")(char);
6490
+ else if (char === "\u25C4" || char === "\u25BA" || char === "\u25A0") line += chalk6.hex("#ffd600")(char);
6491
+ else if (char === "\u2550") line += chalk6.hex("#00e5ff")(char);
6492
+ else if (char === "\u2593") line += chalk6.hex("#ff6d00")(char);
6493
+ else line += " ";
6494
+ } else {
6495
+ line += char;
6496
+ }
6497
+ }
6498
+ arenaLines.push(`\u2551${line}\u2551`);
6499
+ }
6500
+ const topBorder = `\u2554${"\u2550".repeat(ARENA_WIDTH5)}\u2557`;
6501
+ const bottomBorder = `\u255A${"\u2550".repeat(ARENA_WIDTH5)}\u255D`;
6502
+ const frameLines = [
6503
+ topBar,
6504
+ t.muted("Hop across the highway and river to the top sockets"),
6505
+ topBorder,
6506
+ ...arenaLines,
6507
+ bottomBorder,
6508
+ t.muted("Controls: Arrow Keys / WASD : Hop | P: Pause | R: Reset | Q: Quit")
6509
+ ];
6510
+ const box = this.renderer.centerBlock(frameLines.join("\n"), TOTAL_WIDTH3);
6511
+ this.renderer.draw(box);
6512
+ }
6513
+ };
6514
+
6515
+ // src/games/cyber-sweeper/index.ts
6516
+ import chalk7 from "chalk";
6517
+ var TOTAL_WIDTH4 = 56;
6518
+ var CyberSweeperGame = class {
6519
+ id = "cyber-sweeper";
6520
+ metadata = ALL_GAMES_METADATA["cyber-sweeper"];
6521
+ config = null;
6522
+ renderer = defaultRenderer;
6523
+ input = new TerminalInputHandler();
6524
+ rng = new DeterministicRNG();
6525
+ timer = null;
6526
+ state = {
6527
+ grid: [],
6528
+ rows: 10,
6529
+ cols: 10,
6530
+ mineCount: 15,
6531
+ cursorR: 0,
6532
+ cursorC: 0,
6533
+ flagsPlaced: 0,
6534
+ cellsRevealed: 0,
6535
+ isFirstClick: true,
6536
+ isGameOver: false,
6537
+ isWon: false,
6538
+ score: 0,
6539
+ elapsedSeconds: 0
6540
+ };
6541
+ isPaused = false;
6542
+ pauseMenuIndex = 0;
6543
+ showTutorial = true;
6544
+ init(config) {
6545
+ this.config = config;
6546
+ this.renderer.setTheme(config.theme);
6547
+ this.rng = new DeterministicRNG(config.seed || Date.now());
6548
+ if (config.skipTutorial !== void 0) {
6549
+ this.showTutorial = !config.skipTutorial;
6550
+ }
6551
+ this.applyDifficulty(config.difficulty);
6552
+ this.resetGame();
6553
+ }
6554
+ start() {
6555
+ this.isPaused = false;
6556
+ this.render();
6557
+ this.input.start(
6558
+ (key) => this.handleInput(key),
6559
+ () => {
6560
+ this.destroy();
6561
+ this.config?.onExit?.();
6562
+ }
6563
+ );
6564
+ if (!this.showTutorial) {
6565
+ this.startTimer();
6566
+ }
6567
+ }
6568
+ pause() {
6569
+ this.isPaused = true;
6570
+ this.stopTimer();
6571
+ this.render();
6572
+ }
6573
+ resume() {
6574
+ this.isPaused = false;
6575
+ this.startTimer();
6576
+ this.render();
6577
+ }
6578
+ restart() {
6579
+ this.resetGame();
6580
+ this.render();
6581
+ this.startTimer();
6582
+ }
6583
+ saveState() {
6584
+ return {
6585
+ state: this.state,
6586
+ showTutorial: this.showTutorial
6587
+ };
6588
+ }
6589
+ loadState(saved) {
6590
+ if (saved["state"]) this.state = saved["state"];
6591
+ if (saved["showTutorial"] !== void 0) this.showTutorial = !!saved["showTutorial"];
6592
+ }
6593
+ getState() {
6594
+ return this.state;
6595
+ }
6596
+ handleInputForTest(key) {
6597
+ this.handleInput(key);
6598
+ }
6599
+ destroy() {
6600
+ this.stopTimer();
6601
+ this.input.stop();
6602
+ }
6603
+ startTimer() {
6604
+ this.stopTimer();
6605
+ this.timer = setInterval(() => {
6606
+ if (this.isPaused || this.showTutorial || this.state.isGameOver || this.state.isWon) return;
6607
+ this.state.elapsedSeconds++;
6608
+ this.render();
6609
+ }, 1e3);
6610
+ }
6611
+ stopTimer() {
6612
+ if (this.timer) {
6613
+ clearInterval(this.timer);
6614
+ this.timer = null;
6615
+ }
6616
+ }
6617
+ applyDifficulty(diff) {
6618
+ switch (diff) {
6619
+ case "easy":
6620
+ this.state.rows = 8;
6621
+ this.state.cols = 8;
6622
+ this.state.mineCount = 9;
6623
+ break;
6624
+ case "hard":
6625
+ this.state.rows = 12;
6626
+ this.state.cols = 12;
6627
+ this.state.mineCount = 28;
6628
+ break;
6629
+ case "insane":
6630
+ this.state.rows = 14;
6631
+ this.state.cols = 14;
6632
+ this.state.mineCount = 42;
6633
+ break;
6634
+ case "normal":
6635
+ default:
6636
+ this.state.rows = 10;
6637
+ this.state.cols = 10;
6638
+ this.state.mineCount = 16;
6639
+ break;
6640
+ }
6641
+ }
6642
+ resetGame() {
6643
+ const { rows, cols } = this.state;
6644
+ this.state.grid = [];
6645
+ this.state.cursorR = Math.floor(rows / 2);
6646
+ this.state.cursorC = Math.floor(cols / 2);
6647
+ this.state.flagsPlaced = 0;
6648
+ this.state.cellsRevealed = 0;
6649
+ this.state.isFirstClick = true;
6650
+ this.state.isGameOver = false;
6651
+ this.state.isWon = false;
6652
+ this.state.score = 0;
6653
+ this.state.elapsedSeconds = 0;
6654
+ for (let r = 0; r < rows; r++) {
6655
+ const row = [];
6656
+ for (let c = 0; c < cols; c++) {
6657
+ row.push({
6658
+ r,
6659
+ c,
6660
+ isMine: false,
6661
+ state: "hidden",
6662
+ adjacentMines: 0
6663
+ });
6664
+ }
6665
+ this.state.grid.push(row);
6666
+ }
6667
+ }
6668
+ populateMines(safeR, safeC) {
6669
+ const { rows, cols, mineCount } = this.state;
6670
+ let placed = 0;
6671
+ while (placed < mineCount) {
6672
+ const r = Math.floor(this.rng.next() * rows);
6673
+ const c = Math.floor(this.rng.next() * cols);
6674
+ if (Math.abs(r - safeR) <= 1 && Math.abs(c - safeC) <= 1) continue;
6675
+ const cell = this.state.grid[r][c];
6676
+ if (!cell.isMine) {
6677
+ cell.isMine = true;
6678
+ placed++;
6679
+ }
6680
+ }
6681
+ for (let r = 0; r < rows; r++) {
6682
+ for (let c = 0; c < cols; c++) {
6683
+ const cell = this.state.grid[r][c];
6684
+ if (!cell.isMine) {
6685
+ cell.adjacentMines = this.countAdjacentMines(r, c);
6686
+ }
6687
+ }
6688
+ }
6689
+ }
6690
+ countAdjacentMines(r, c) {
6691
+ let count = 0;
6692
+ for (let dr = -1; dr <= 1; dr++) {
6693
+ for (let dc = -1; dc <= 1; dc++) {
6694
+ if (dr === 0 && dc === 0) continue;
6695
+ const nr = r + dr;
6696
+ const nc = c + dc;
6697
+ if (nr >= 0 && nr < this.state.rows && nc >= 0 && nc < this.state.cols) {
6698
+ if (this.state.grid[nr][nc].isMine) count++;
6699
+ }
6700
+ }
6701
+ }
6702
+ return count;
6703
+ }
6704
+ probeCell(r, c) {
6705
+ if (this.state.isGameOver || this.state.isWon) return;
6706
+ const cell = this.state.grid[r]?.[c];
6707
+ if (!cell || cell.state === "flagged") return;
6708
+ if (this.state.isFirstClick) {
6709
+ this.state.isFirstClick = false;
6710
+ this.populateMines(r, c);
6711
+ }
6712
+ if (cell.state === "revealed") {
6713
+ this.chordCell(r, c);
6714
+ return;
6715
+ }
6716
+ if (cell.isMine) {
6717
+ cell.state = "revealed";
6718
+ cell.exploded = true;
6719
+ this.handleDetonation();
6720
+ return;
6721
+ }
6722
+ this.revealCascade(r, c);
6723
+ if (this.config?.soundEnabled) playTerminalBell();
6724
+ this.checkWinCondition();
6725
+ this.render();
6726
+ }
6727
+ revealCascade(r, c) {
6728
+ const cell = this.state.grid[r]?.[c];
6729
+ if (!cell || cell.state !== "hidden" || cell.isMine) return;
6730
+ cell.state = "revealed";
6731
+ this.state.cellsRevealed++;
6732
+ this.addScore(15);
6733
+ if (this.state.cellsRevealed === 1) {
6734
+ this.config?.onAchievementUnlock?.("first_sweep");
6735
+ }
6736
+ if (cell.adjacentMines === 0) {
6737
+ for (let dr = -1; dr <= 1; dr++) {
6738
+ for (let dc = -1; dc <= 1; dc++) {
6739
+ if (dr === 0 && dc === 0) continue;
6740
+ const nr = r + dr;
6741
+ const nc = c + dc;
6742
+ if (nr >= 0 && nr < this.state.rows && nc >= 0 && nc < this.state.cols) {
6743
+ this.revealCascade(nr, nc);
6744
+ }
6745
+ }
6746
+ }
6747
+ }
6748
+ }
6749
+ toggleFlag(r, c) {
6750
+ if (this.state.isGameOver || this.state.isWon) return;
6751
+ const cell = this.state.grid[r]?.[c];
6752
+ if (!cell || cell.state === "revealed") return;
6753
+ if (cell.state === "flagged") {
6754
+ cell.state = "hidden";
6755
+ this.state.flagsPlaced--;
6756
+ } else {
6757
+ cell.state = "flagged";
6758
+ this.state.flagsPlaced++;
6759
+ }
6760
+ if (this.config?.soundEnabled) playTerminalBell();
6761
+ this.render();
6762
+ }
6763
+ chordCell(r, c) {
6764
+ const cell = this.state.grid[r]?.[c];
6765
+ if (!cell || cell.state !== "revealed" || cell.adjacentMines === 0) return;
6766
+ let flagCount = 0;
6767
+ const neighbors = [];
6768
+ for (let dr = -1; dr <= 1; dr++) {
6769
+ for (let dc = -1; dc <= 1; dc++) {
6770
+ if (dr === 0 && dc === 0) continue;
6771
+ const nr = r + dr;
6772
+ const nc = c + dc;
6773
+ if (nr >= 0 && nr < this.state.rows && nc >= 0 && nc < this.state.cols) {
6774
+ const neighbor = this.state.grid[nr][nc];
6775
+ neighbors.push(neighbor);
6776
+ if (neighbor.state === "flagged") flagCount++;
6777
+ }
6778
+ }
6779
+ }
6780
+ if (flagCount === cell.adjacentMines) {
6781
+ for (const n of neighbors) {
6782
+ if (n.state === "hidden") {
6783
+ if (n.isMine) {
6784
+ n.state = "revealed";
6785
+ n.exploded = true;
6786
+ this.handleDetonation();
6787
+ return;
6788
+ }
6789
+ this.revealCascade(n.r, n.c);
6790
+ }
6791
+ }
6792
+ if (this.config?.soundEnabled) playTerminalBell();
6793
+ this.checkWinCondition();
6794
+ this.render();
6795
+ }
6796
+ }
6797
+ handleDetonation() {
6798
+ this.state.isGameOver = true;
6799
+ this.stopTimer();
6800
+ for (const row of this.state.grid) {
6801
+ for (const cell of row) {
6802
+ if (cell.isMine) {
6803
+ cell.state = "revealed";
6804
+ }
6805
+ }
6806
+ }
6807
+ if (this.config?.soundEnabled) playTerminalBell();
6808
+ this.config?.onGameOver?.(this.state.score);
6809
+ this.render();
6810
+ }
6811
+ checkWinCondition() {
6812
+ const totalCells = this.state.rows * this.state.cols;
6813
+ const nonMineCells = totalCells - this.state.mineCount;
6814
+ if (this.state.cellsRevealed >= nonMineCells) {
6815
+ this.state.isWon = true;
6816
+ this.stopTimer();
6817
+ for (const row of this.state.grid) {
6818
+ for (const cell of row) {
6819
+ if (cell.isMine) cell.state = "flagged";
6820
+ }
6821
+ }
6822
+ const timeBonus = Math.max(0, 300 - this.state.elapsedSeconds) * 10;
6823
+ this.addScore(500 + timeBonus);
6824
+ this.config?.onAchievementUnlock?.("mine_defused");
6825
+ this.config?.onAchievementUnlock?.("sector_cleansed");
6826
+ if (this.config?.soundEnabled) playTerminalBell();
6827
+ this.config?.onGameOver?.(this.state.score);
6828
+ this.render();
6829
+ }
6830
+ }
6831
+ addScore(pts) {
6832
+ this.state.score += pts;
6833
+ this.config?.onScoreUpdate?.(this.state.score);
6834
+ }
6835
+ handleInput(key) {
6836
+ if (this.showTutorial) {
6837
+ if (key.name === "return" || key.name === "space") {
6838
+ this.showTutorial = false;
6839
+ this.startTimer();
6840
+ this.render();
6841
+ } else if (key.name === "escape" || key.name === "q") {
6842
+ this.destroy();
6843
+ this.config?.onExit?.();
6844
+ }
6845
+ return;
6846
+ }
6847
+ if (this.isPaused) {
6848
+ if (key.name === "up" || key.name === "w") {
6849
+ this.pauseMenuIndex = (this.pauseMenuIndex - 1 + 3) % 3;
6850
+ this.render();
6851
+ } else if (key.name === "down" || key.name === "s") {
6852
+ this.pauseMenuIndex = (this.pauseMenuIndex + 1) % 3;
6853
+ this.render();
6854
+ } else if (key.name === "return" || key.name === "space") {
6855
+ if (this.pauseMenuIndex === 0) {
6856
+ this.isPaused = false;
6857
+ this.startTimer();
6858
+ this.render();
6859
+ } else if (this.pauseMenuIndex === 1) {
6860
+ this.isPaused = false;
6861
+ this.restart();
6862
+ } else if (this.pauseMenuIndex === 2) {
6863
+ this.destroy();
6864
+ this.config?.onExit?.();
6865
+ }
6866
+ } else if (key.name === "escape" || key.name === "p") {
6867
+ this.isPaused = false;
6868
+ this.startTimer();
6869
+ this.render();
6870
+ } else if (key.name === "q") {
6871
+ this.destroy();
6872
+ this.config?.onExit?.();
6873
+ }
6874
+ return;
6875
+ }
6876
+ if (key.name === "escape" || key.name === "p") {
6877
+ this.isPaused = true;
6878
+ this.pauseMenuIndex = 0;
6879
+ this.stopTimer();
6880
+ this.render();
6881
+ return;
6882
+ }
6883
+ if (key.name === "q") {
6884
+ this.destroy();
6885
+ this.config?.onExit?.();
6886
+ return;
6887
+ }
6888
+ if (key.name === "r") {
6889
+ this.restart();
6890
+ return;
6891
+ }
6892
+ if (this.state.isGameOver || this.state.isWon) {
6893
+ if (key.name === "return" || key.name === "space" || key.name === "r") {
6894
+ this.resetGame();
6895
+ this.render();
6896
+ this.startTimer();
6897
+ }
6898
+ return;
6899
+ }
6900
+ if (key.name === "up" || key.name === "w") {
6901
+ this.state.cursorR = Math.max(0, this.state.cursorR - 1);
6902
+ this.render();
6903
+ } else if (key.name === "down" || key.name === "s") {
6904
+ this.state.cursorR = Math.min(this.state.rows - 1, this.state.cursorR + 1);
6905
+ this.render();
6906
+ } else if (key.name === "left" || key.name === "a") {
6907
+ this.state.cursorC = Math.max(0, this.state.cursorC - 1);
6908
+ this.render();
6909
+ } else if (key.name === "right" || key.name === "d") {
6910
+ this.state.cursorC = Math.min(this.state.cols - 1, this.state.cursorC + 1);
6911
+ this.render();
6912
+ }
6913
+ if (key.name === "space" || key.name === "return") {
6914
+ this.probeCell(this.state.cursorR, this.state.cursorC);
6915
+ } else if (key.name === "f") {
6916
+ this.toggleFlag(this.state.cursorR, this.state.cursorC);
6917
+ } else if (key.name === "c") {
6918
+ this.chordCell(this.state.cursorR, this.state.cursorC);
6919
+ }
6920
+ }
6921
+ formatCell(cell, isCursor) {
6922
+ let content = " ";
6923
+ if (cell.state === "flagged") {
6924
+ content = chalk7.yellowBright.bold("\u2691");
6925
+ } else if (cell.state === "hidden") {
6926
+ content = chalk7.hex("#546e7a")("\u25A0");
6927
+ } else if (cell.exploded) {
6928
+ content = chalk7.bold.white.bgRed("\u{1F4A5}");
6929
+ } else if (cell.isMine) {
6930
+ content = chalk7.bold.redBright("\u263C");
6931
+ } else if (cell.adjacentMines === 0) {
6932
+ content = " ";
6933
+ } else {
6934
+ switch (cell.adjacentMines) {
6935
+ case 1:
6936
+ content = chalk7.hex("#42a5f5").bold("1");
6937
+ break;
6938
+ case 2:
6939
+ content = chalk7.hex("#66bb6a").bold("2");
6940
+ break;
6941
+ case 3:
6942
+ content = chalk7.hex("#ef5350").bold("3");
6943
+ break;
6944
+ case 4:
6945
+ content = chalk7.hex("#5c6bc0").bold("4");
6946
+ break;
6947
+ case 5:
6948
+ content = chalk7.hex("#ff7043").bold("5");
6949
+ break;
6950
+ case 6:
6951
+ content = chalk7.hex("#26a69a").bold("6");
6952
+ break;
6953
+ case 7:
6954
+ content = chalk7.hex("#ab47bc").bold("7");
6955
+ break;
6956
+ case 8:
6957
+ content = chalk7.hex("#90a4ae").bold("8");
6958
+ break;
6959
+ }
6960
+ }
6961
+ if (isCursor) {
6962
+ return chalk7.bold.cyanBright("[") + content + chalk7.bold.cyanBright("]");
6963
+ }
6964
+ return " " + content + " ";
6965
+ }
6966
+ render() {
6967
+ const t = this.renderer.getTheme();
6968
+ if (this.showTutorial) {
6969
+ const lines = [
6970
+ "",
6971
+ t.highlight("CYBER SWEEPER // THREAT DEFUSAL PROTOCOL"),
6972
+ "",
6973
+ "\u2022 Navigate the corrupted memory sector with ARROW KEYS or WASD.",
6974
+ "\u2022 Press [SPACE] to probe a cell and reveal threat counts.",
6975
+ "\u2022 Numbers indicate how many adjacent bombs surround that tile (1 to 8).",
6976
+ "\u2022 Press [F] to place a warning flag beacon on suspected logic bombs.",
6977
+ "\u2022 Press [C] on a satisfied numbered tile to quick-reveal unflagged neighbors.",
6978
+ "\u2022 Clear all safe sectors without detonating any corrupted cores!",
6979
+ "",
6980
+ t.muted("Controls:"),
6981
+ " Arrow Keys / WASD : Navigate Reticle",
6982
+ " Space / Enter : Probe Sector",
6983
+ " F : Flag / Unflag Bomb",
6984
+ " C : Chord Neighbor Probe",
6985
+ " P / Esc : Pause Menu",
6986
+ " R : Instant Reset",
6987
+ " Q : Quit to Arcade Menu",
6988
+ "",
6989
+ t.highlight("Press [ENTER] or [SPACE] to Initialize Scanner..."),
6990
+ ""
6991
+ ];
6992
+ const box2 = this.renderer.createBox(lines, TOTAL_WIDTH4, "MISSION BRIEFING");
6993
+ this.renderer.draw(this.renderer.centerBlock(box2, TOTAL_WIDTH4));
6994
+ return;
6995
+ }
6996
+ if (this.isPaused) {
6997
+ const menuItems = ["RESUME SCAN", "REBOOT SECTOR", "EXIT TO ROSTER"];
6998
+ const lines = [
6999
+ "",
7000
+ t.highlight("CYBER SWEEPER // SCANNER SUSPENDED"),
7001
+ "",
7002
+ ...menuItems.map((item, idx) => {
7003
+ if (idx === this.pauseMenuIndex) {
7004
+ return t.highlight(` \u25BA [ ${item} ]`);
7005
+ }
7006
+ return t.muted(` ${item} `);
7007
+ }),
7008
+ "",
7009
+ t.muted("Use Up/Down to select, Enter to confirm"),
7010
+ ""
7011
+ ];
7012
+ const box2 = this.renderer.createBox(lines, TOTAL_WIDTH4, "SYSTEM PAUSED");
7013
+ this.renderer.draw(this.renderer.centerBlock(box2, TOTAL_WIDTH4));
7014
+ return;
7015
+ }
7016
+ if (this.state.isWon) {
7017
+ const lines = [
7018
+ "",
7019
+ chalk7.bold.greenBright("\u2605 \u2605 \u2605 SECTOR CLEANSED // ALL MINES DEFUSED \u2605 \u2605 \u2605"),
7020
+ "",
7021
+ `Defusal Score: ${t.highlight(this.state.score.toLocaleString())}`,
7022
+ `Defusal Time: ${t.secondary(`${this.state.elapsedSeconds}s`)}`,
7023
+ `Flags Positioned: ${t.secondary(`${this.state.flagsPlaced} / ${this.state.mineCount}`)}`,
7024
+ "",
7025
+ t.highlight("Press [R] or [SPACE] to Scan Next Sector"),
7026
+ t.muted("Press [Q] to Return to Arcade Roster"),
7027
+ ""
7028
+ ];
7029
+ const box2 = this.renderer.createBox(lines, TOTAL_WIDTH4, "SECTOR SECURED");
7030
+ this.renderer.draw(this.renderer.centerBlock(box2, TOTAL_WIDTH4));
7031
+ return;
7032
+ }
7033
+ if (this.state.isGameOver) {
7034
+ const lines = [
7035
+ "",
7036
+ t.error("DETONATION DETECTED // CORRUPTED CORE EXPLODED"),
7037
+ "",
7038
+ `Final Score: ${t.highlight(this.state.score.toLocaleString())}`,
7039
+ `Time Survived: ${t.secondary(`${this.state.elapsedSeconds}s`)}`,
7040
+ `Sectors Uncovered: ${t.secondary(`${this.state.cellsRevealed} / ${this.state.rows * this.state.cols - this.state.mineCount}`)}`,
7041
+ "",
7042
+ t.highlight("Press [R] or [SPACE] to Retry Sector"),
7043
+ t.muted("Press [Q] to Return to Arcade Roster"),
7044
+ ""
7045
+ ];
7046
+ const box2 = this.renderer.createBox(lines, TOTAL_WIDTH4, "CORE BREACH");
7047
+ this.renderer.draw(this.renderer.centerBlock(box2, TOTAL_WIDTH4));
7048
+ return;
7049
+ }
7050
+ const minesLeft = Math.max(0, this.state.mineCount - this.state.flagsPlaced);
7051
+ const scoreStr = `SCORE: ${this.state.score.toLocaleString()}`;
7052
+ const timeStr = `TIME: ${this.state.elapsedSeconds}s`;
7053
+ const flagsStr = `BOMBS: ${minesLeft.toString().padStart(2, "0")}`;
7054
+ const topBar = `${t.secondary(flagsStr)} ${t.highlight(scoreStr)} ${t.accent(timeStr)}`;
7055
+ const gridRows = [];
7056
+ const colWidth = 3;
7057
+ const innerWidth = this.state.cols * colWidth;
7058
+ const topGridBorder = chalk7.cyan(" \u2554" + "\u2550".repeat(innerWidth) + "\u2557");
7059
+ const bottomGridBorder = chalk7.cyan(" \u255A" + "\u2550".repeat(innerWidth) + "\u255D");
7060
+ gridRows.push(topGridBorder);
7061
+ for (let r = 0; r < this.state.rows; r++) {
7062
+ let rowContent = "";
7063
+ for (let c = 0; c < this.state.cols; c++) {
7064
+ const isCursor = r === this.state.cursorR && c === this.state.cursorC;
7065
+ rowContent += this.formatCell(this.state.grid[r][c], isCursor);
7066
+ }
7067
+ gridRows.push(chalk7.cyan(" \u2551") + rowContent + chalk7.cyan("\u2551"));
7068
+ }
7069
+ gridRows.push(bottomGridBorder);
7070
+ const bottomBar = t.muted("Controls: Arrows/WASD: Move | Space: Probe | F: Flag | C: Chord | R: Reset");
7071
+ const frameLines = [
7072
+ topBar,
7073
+ "",
7074
+ ...gridRows,
7075
+ "",
7076
+ bottomBar
7077
+ ];
7078
+ const box = this.renderer.createBox(frameLines, TOTAL_WIDTH4, "CYBER SWEEPER // MEMORY DEFUSAL");
7079
+ this.renderer.draw(this.renderer.centerBlock(box, TOTAL_WIDTH4));
7080
+ }
7081
+ };
7082
+
7083
+ // src/games/neon-flap/index.ts
7084
+ var ARENA_WIDTH6 = 48;
7085
+ var ARENA_HEIGHT5 = 16;
7086
+ var TOTAL_WIDTH5 = 54;
7087
+ var DRONE_X = 10;
7088
+ var PIPE_WIDTH = 3;
7089
+ var DIFFICULTY_MAP = {
7090
+ easy: {
7091
+ gravity: 0.1,
7092
+ flapImpulse: -0.75,
7093
+ gapHeight: 5,
7094
+ pipeSpeed: 0.5,
7095
+ tickIntervalMs: 55,
7096
+ minPipeDistance: 22
7097
+ },
7098
+ normal: {
7099
+ gravity: 0.12,
7100
+ flapImpulse: -0.82,
7101
+ gapHeight: 4.5,
7102
+ pipeSpeed: 0.65,
7103
+ tickIntervalMs: 45,
7104
+ minPipeDistance: 19
7105
+ },
7106
+ hard: {
7107
+ gravity: 0.15,
7108
+ flapImpulse: -0.88,
7109
+ gapHeight: 4,
7110
+ pipeSpeed: 0.8,
7111
+ tickIntervalMs: 38,
7112
+ minPipeDistance: 17
7113
+ },
7114
+ insane: {
7115
+ gravity: 0.18,
7116
+ flapImpulse: -0.95,
7117
+ gapHeight: 3.5,
7118
+ pipeSpeed: 1,
7119
+ tickIntervalMs: 30,
7120
+ minPipeDistance: 15
7121
+ }
7122
+ };
7123
+ var NeonFlapGame = class {
7124
+ id = "neon-flap";
7125
+ metadata = ALL_GAMES_METADATA["neon-flap"];
7126
+ config = null;
7127
+ renderer = defaultRenderer;
7128
+ input = new TerminalInputHandler();
7129
+ rng = new DeterministicRNG();
7130
+ gameLoopTimer = null;
7131
+ nextPipeId = 1;
7132
+ groundOffset = 0;
7133
+ state = {
7134
+ droneY: 7,
7135
+ droneVelocityY: 0,
7136
+ score: 0,
7137
+ highScore: 0,
7138
+ conduitsPassed: 0,
7139
+ perfectPasses: 0,
7140
+ streak: 0,
7141
+ pipes: [],
7142
+ particles: [],
7143
+ isGameOver: false,
7144
+ isFlapping: false,
7145
+ flapCooldown: 0,
7146
+ distanceTraveled: 0
7147
+ };
7148
+ isPaused = false;
7149
+ pauseMenuIndex = 0;
7150
+ showTutorial = true;
7151
+ settings = DIFFICULTY_MAP.normal;
7152
+ init(config) {
7153
+ this.config = config;
7154
+ this.renderer.setTheme(config.theme);
7155
+ this.rng = new DeterministicRNG(config.seed || Date.now());
7156
+ if (config.skipTutorial !== void 0) {
7157
+ this.showTutorial = !config.skipTutorial;
7158
+ }
7159
+ this.settings = DIFFICULTY_MAP[config.difficulty] || DIFFICULTY_MAP.normal;
7160
+ this.resetState(config.difficulty);
7161
+ }
7162
+ resetState(difficulty) {
7163
+ const savedHighScore = this.config?.storage?.getHighScore(this.id, difficulty) || 0;
7164
+ this.state = {
7165
+ droneY: Math.floor(ARENA_HEIGHT5 / 2) - 1,
7166
+ droneVelocityY: -0.3,
7167
+ score: 0,
7168
+ highScore: savedHighScore,
7169
+ conduitsPassed: 0,
7170
+ perfectPasses: 0,
7171
+ streak: 0,
7172
+ pipes: [],
7173
+ particles: [],
7174
+ isGameOver: false,
7175
+ isFlapping: false,
7176
+ flapCooldown: 0,
7177
+ distanceTraveled: 0
7178
+ };
7179
+ this.nextPipeId = 1;
7180
+ this.groundOffset = 0;
7181
+ this.isPaused = false;
7182
+ this.pauseMenuIndex = 0;
7183
+ this.spawnPipe(ARENA_WIDTH6 + 6);
7184
+ this.spawnPipe(ARENA_WIDTH6 + 6 + this.settings.minPipeDistance);
7185
+ }
7186
+ spawnPipe(startX) {
7187
+ const x = startX !== void 0 ? startX : ARENA_WIDTH6 + 2;
7188
+ const gapHeight = this.settings.gapHeight;
7189
+ const minGapTop = 2;
7190
+ const maxGapTop = Math.floor(ARENA_HEIGHT5 - gapHeight - 2);
7191
+ const gapY = this.rng.nextInt(minGapTop, Math.max(minGapTop, maxGapTop));
7192
+ this.state.pipes.push({
7193
+ id: this.nextPipeId++,
7194
+ x,
7195
+ gapY,
7196
+ gapHeight,
7197
+ passed: false
7198
+ });
7199
+ }
7200
+ start() {
7201
+ this.renderer.enterScreen();
7202
+ this.input.start((key) => this.handleInput(key));
7203
+ if (!this.showTutorial) {
7204
+ this.scheduleNextTick();
7205
+ }
7206
+ this.render();
7207
+ }
7208
+ destroy() {
7209
+ if (this.gameLoopTimer) {
7210
+ clearTimeout(this.gameLoopTimer);
7211
+ this.gameLoopTimer = null;
7212
+ }
7213
+ this.input.stop();
7214
+ }
7215
+ restart() {
7216
+ if (this.config) {
7217
+ this.resetState(this.config.difficulty);
7218
+ this.scheduleNextTick();
7219
+ this.render();
7220
+ }
7221
+ }
7222
+ tick() {
7223
+ if (this.state.isGameOver || this.isPaused || this.showTutorial) return;
7224
+ this.state.droneVelocityY += this.settings.gravity;
7225
+ if (this.state.droneVelocityY > 1.1) this.state.droneVelocityY = 1.1;
7226
+ if (this.state.droneVelocityY < -1.1) this.state.droneVelocityY = -1.1;
7227
+ this.state.droneY += this.state.droneVelocityY;
7228
+ this.state.distanceTraveled += this.settings.pipeSpeed;
7229
+ this.groundOffset = (this.groundOffset + 1) % 4;
7230
+ if (this.state.flapCooldown > 0) {
7231
+ this.state.flapCooldown--;
7232
+ if (this.state.flapCooldown === 0) {
7233
+ this.state.isFlapping = false;
7234
+ }
7235
+ }
7236
+ for (let i = this.state.particles.length - 1; i >= 0; i--) {
7237
+ const p = this.state.particles[i];
7238
+ p.x -= this.settings.pipeSpeed * 1.2;
7239
+ p.life--;
7240
+ if (p.life <= 0 || p.x < 0) {
7241
+ this.state.particles.splice(i, 1);
7242
+ }
7243
+ }
7244
+ for (const pipe of this.state.pipes) {
7245
+ pipe.x -= this.settings.pipeSpeed;
7246
+ if (!pipe.passed && pipe.x + 1 <= DRONE_X) {
7247
+ pipe.passed = true;
7248
+ this.state.conduitsPassed++;
7249
+ const gapCenter = pipe.gapY + pipe.gapHeight / 2;
7250
+ const distFromCenter = Math.abs(this.state.droneY - gapCenter);
7251
+ const isCenterPass = distFromCenter <= 0.85;
7252
+ if (isCenterPass) {
7253
+ this.state.perfectPasses++;
7254
+ this.state.streak++;
7255
+ } else {
7256
+ this.state.streak = 1;
7257
+ }
7258
+ const streakMultiplier = Math.min(4, Math.max(1, this.state.streak));
7259
+ const earnedScore = 100 * streakMultiplier + (isCenterPass ? 50 : 0);
7260
+ this.state.score += earnedScore;
7261
+ if (this.state.score > this.state.highScore) {
7262
+ this.state.highScore = this.state.score;
7263
+ }
7264
+ this.checkAchievements();
7265
+ }
7266
+ }
7267
+ this.state.pipes = this.state.pipes.filter((p) => p.x + PIPE_WIDTH >= -2);
7268
+ const lastPipe = this.state.pipes[this.state.pipes.length - 1];
7269
+ if (!lastPipe || lastPipe.x <= ARENA_WIDTH6 - this.settings.minPipeDistance) {
7270
+ this.spawnPipe(ARENA_WIDTH6 + 2);
7271
+ }
7272
+ if (this.checkCollision()) {
7273
+ this.triggerGameOver();
7274
+ return;
7275
+ }
7276
+ this.render();
7277
+ this.scheduleNextTick();
7278
+ }
7279
+ flap() {
7280
+ if (this.state.isGameOver || this.isPaused || this.showTutorial) return;
7281
+ this.state.droneVelocityY = this.settings.flapImpulse;
7282
+ this.state.isFlapping = true;
7283
+ this.state.flapCooldown = 3;
7284
+ this.state.particles.push({
7285
+ x: DRONE_X - 1,
7286
+ y: Math.floor(this.state.droneY),
7287
+ life: 4,
7288
+ char: "\u2022"
7289
+ });
7290
+ this.state.particles.push({
7291
+ x: DRONE_X - 2,
7292
+ y: Math.floor(this.state.droneY),
7293
+ life: 3,
7294
+ char: "\xB7"
7295
+ });
7296
+ if (this.config?.soundEnabled) {
7297
+ playTerminalBell();
7298
+ }
7299
+ }
7300
+ checkCollision() {
7301
+ const droneY = this.state.droneY;
7302
+ if (droneY < 0.2 || droneY >= ARENA_HEIGHT5 - 0.8) {
7303
+ return true;
7304
+ }
7305
+ const droneLeft = DRONE_X;
7306
+ const droneRight = DRONE_X + 1;
7307
+ for (const pipe of this.state.pipes) {
7308
+ const pipeLeft = Math.floor(pipe.x);
7309
+ const pipeRight = pipeLeft + PIPE_WIDTH - 1;
7310
+ if (droneRight >= pipeLeft && droneLeft <= pipeRight) {
7311
+ const insideGap = droneY >= pipe.gapY - 0.1 && droneY <= pipe.gapY + pipe.gapHeight - 0.2;
7312
+ if (!insideGap) {
7313
+ return true;
7314
+ }
7315
+ }
7316
+ }
7317
+ return false;
7318
+ }
7319
+ triggerGameOver() {
7320
+ this.state.isGameOver = true;
7321
+ if (this.gameLoopTimer) {
7322
+ clearTimeout(this.gameLoopTimer);
7323
+ this.gameLoopTimer = null;
7324
+ }
7325
+ if (this.config && this.state.score > 0) {
7326
+ this.config.storage?.saveHighScore(this.id, this.config.difficulty, this.state.score);
7327
+ }
7328
+ this.render();
7329
+ }
7330
+ checkAchievements() {
7331
+ if (!this.config?.achievements) return;
7332
+ if (this.state.conduitsPassed >= 1) {
7333
+ this.config.achievements.unlock(this.id, "first_gate");
7334
+ }
7335
+ if (this.state.conduitsPassed >= 10) {
7336
+ this.config.achievements.unlock(this.id, "cyber_aviator");
7337
+ }
7338
+ if (this.state.conduitsPassed >= 25) {
7339
+ this.config.achievements.unlock(this.id, "quantum_pilot");
7340
+ }
7341
+ if (this.state.streak >= 3) {
7342
+ this.config.achievements.unlock(this.id, "flawless_vector");
7343
+ }
7344
+ }
7345
+ scheduleNextTick() {
7346
+ if (this.state.isGameOver || this.isPaused || this.showTutorial) return;
7347
+ this.gameLoopTimer = setTimeout(() => {
7348
+ this.tick();
7349
+ }, this.settings.tickIntervalMs);
7350
+ }
7351
+ handleInput(key) {
7352
+ if (this.showTutorial) {
7353
+ if (key.name === "return" || key.name === "space") {
7354
+ this.showTutorial = false;
7355
+ this.scheduleNextTick();
7356
+ this.render();
7357
+ } else if (key.name === "escape" || key.name === "q") {
7358
+ this.destroy();
7359
+ this.config?.onExit?.();
7360
+ }
7361
+ return;
7362
+ }
7363
+ if (this.isPaused) {
7364
+ if (key.name === "up" || key.name === "w") {
7365
+ this.pauseMenuIndex = (this.pauseMenuIndex - 1 + 3) % 3;
7366
+ this.render();
7367
+ } else if (key.name === "down" || key.name === "s") {
7368
+ this.pauseMenuIndex = (this.pauseMenuIndex + 1) % 3;
7369
+ this.render();
7370
+ } else if (key.name === "return" || key.name === "space") {
7371
+ if (this.pauseMenuIndex === 0) {
7372
+ this.isPaused = false;
7373
+ this.scheduleNextTick();
7374
+ this.render();
7375
+ } else if (this.pauseMenuIndex === 1) {
7376
+ this.isPaused = false;
7377
+ this.restart();
7378
+ } else if (this.pauseMenuIndex === 2) {
7379
+ this.destroy();
7380
+ this.config?.onExit?.();
7381
+ }
7382
+ } else if (key.name === "escape" || key.name === "p") {
7383
+ this.isPaused = false;
7384
+ this.scheduleNextTick();
7385
+ this.render();
7386
+ }
7387
+ return;
7388
+ }
7389
+ if (key.name === "q") {
7390
+ this.destroy();
7391
+ this.config?.onExit?.();
7392
+ return;
7393
+ }
7394
+ if (this.state.isGameOver) {
7395
+ if (key.name === "r") {
7396
+ this.restart();
7397
+ } else if (key.name === "escape" || key.name === "q") {
7398
+ this.destroy();
7399
+ this.config?.onExit?.();
7400
+ }
7401
+ return;
7402
+ }
7403
+ if (key.name === "p" || key.name === "escape") {
7404
+ this.isPaused = true;
7405
+ if (this.gameLoopTimer) {
7406
+ clearTimeout(this.gameLoopTimer);
7407
+ this.gameLoopTimer = null;
7408
+ }
7409
+ this.pauseMenuIndex = 0;
7410
+ this.render();
7411
+ return;
7412
+ }
7413
+ if (key.name === "r") {
7414
+ this.restart();
7415
+ return;
7416
+ }
7417
+ if (key.name === "space" || key.name === "up" || key.name === "w") {
7418
+ this.flap();
7419
+ }
7420
+ }
7421
+ render() {
7422
+ const t = this.renderer.getTheme();
7423
+ if (this.showTutorial) {
7424
+ const lines = [
7425
+ "",
7426
+ t.highlight("NEON FLAP // CYBER-CONDUIT FLIGHT MANUAL"),
7427
+ "",
7428
+ "\u2022 Press Space, Up, or W to fire directional THRUSTERS.",
7429
+ "\u2022 Counter constant terminal gravity to stay aloft.",
7430
+ "\u2022 Navigate between high-voltage firewall conduit beams.",
7431
+ "\u2022 Colliding with the ceiling, floor, or conduit is fatal.",
7432
+ "\u2022 Center-gate passes earn streak multipliers (up to 4x)!",
7433
+ "",
7434
+ t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
7435
+ t.primary("Press Space or Enter to launch \u2502 Q: Abort Run")
7436
+ ];
7437
+ const box = this.renderer.createBox(lines, TOTAL_WIDTH5, "NEON FLAP PROTOCOL");
7438
+ this.renderer.renderFrame(this.renderer.centerBlock(box, TOTAL_WIDTH5));
7439
+ return;
7440
+ }
7441
+ if (this.isPaused) {
7442
+ const pauseItems = ["Resume Flight (Esc / Enter)", "Reboot Run (R)", "Return to Arcade Menu (Q)"];
7443
+ const pauseLines = [
7444
+ "",
7445
+ t.highlight("\u2550\u2550\u2550 FLIGHT FLUX PAUSED \u2550\u2550\u2550"),
7446
+ "",
7447
+ ...pauseItems.map((item, idx) => {
7448
+ if (idx === this.pauseMenuIndex) {
7449
+ return t.primary(` \u25B6 ${t.highlight(item)}`);
7450
+ }
7451
+ return t.muted(` ${item}`);
7452
+ }),
7453
+ "",
7454
+ t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
7455
+ t.muted("Use Up/Down to navigate \u2502 Enter: Select")
7456
+ ];
7457
+ const pauseBox = this.renderer.createBox(pauseLines, TOTAL_WIDTH5, "SYSTEM PAUSE");
7458
+ this.renderer.renderFrame(this.renderer.centerBlock(pauseBox, TOTAL_WIDTH5));
7459
+ return;
7460
+ }
7461
+ const header = this.renderer.renderHeader(
7462
+ {
7463
+ title: "NEON FLAP",
7464
+ category: "ARCADE",
7465
+ difficulty: this.config?.difficulty,
7466
+ score: this.state.score,
7467
+ highScore: this.state.highScore
7468
+ },
7469
+ TOTAL_WIDTH5
7470
+ );
7471
+ const grid = Array.from(
7472
+ { length: ARENA_HEIGHT5 },
7473
+ () => Array.from({ length: ARENA_WIDTH6 }, () => " ")
7474
+ );
7475
+ for (const pipe of this.state.pipes) {
7476
+ const pipeX = Math.floor(pipe.x);
7477
+ const gapTop = Math.floor(pipe.gapY);
7478
+ const gapBottom = Math.floor(pipe.gapY + pipe.gapHeight);
7479
+ for (let col = 0; col < PIPE_WIDTH; col++) {
7480
+ const renderCol = pipeX + col;
7481
+ if (renderCol < 0 || renderCol >= ARENA_WIDTH6) continue;
7482
+ for (let row = 0; row < gapTop; row++) {
7483
+ if (row === gapTop - 1) {
7484
+ grid[row][renderCol] = t.error("\u25BC");
7485
+ } else {
7486
+ const char = col === 0 ? "\u2551" : col === 1 ? "\u2588" : "\u2551";
7487
+ grid[row][renderCol] = t.secondary(char);
7488
+ }
7489
+ }
7490
+ for (let row = gapTop; row < gapBottom; row++) {
7491
+ if (col === 0 || col === PIPE_WIDTH - 1) {
7492
+ grid[row][renderCol] = t.muted("\xB7");
7493
+ }
7494
+ }
7495
+ for (let row = gapBottom; row < ARENA_HEIGHT5; row++) {
7496
+ if (row === gapBottom) {
7497
+ grid[row][renderCol] = t.error("\u25B2");
7498
+ } else {
7499
+ const char = col === 0 ? "\u2551" : col === 1 ? "\u2588" : "\u2551";
7500
+ grid[row][renderCol] = t.secondary(char);
7501
+ }
7502
+ }
7503
+ }
7504
+ }
7505
+ for (const p of this.state.particles) {
7506
+ const px = Math.floor(p.x);
7507
+ const py = p.y;
7508
+ if (px >= 0 && px < ARENA_WIDTH6 && py >= 0 && py < ARENA_HEIGHT5) {
7509
+ grid[py][px] = t.accent(p.char);
7510
+ }
7511
+ }
7512
+ const droneRow = Math.max(0, Math.min(ARENA_HEIGHT5 - 1, Math.floor(this.state.droneY)));
7513
+ let droneGlyphLeft = "\u25BA";
7514
+ let droneGlyphRight = "\u25BA";
7515
+ if (this.state.droneVelocityY < -0.2) {
7516
+ droneGlyphLeft = "\u25BA";
7517
+ droneGlyphRight = "\u25B2";
7518
+ } else if (this.state.droneVelocityY > 0.2) {
7519
+ droneGlyphLeft = "\u25BA";
7520
+ droneGlyphRight = "\u25BC";
7521
+ }
7522
+ if (this.state.isGameOver) {
7523
+ droneGlyphLeft = "\xD7";
7524
+ droneGlyphRight = "\xD7";
7525
+ }
7526
+ if (DRONE_X >= 0 && DRONE_X < ARENA_WIDTH6) {
7527
+ const droneColor = this.state.isGameOver ? t.error : this.state.isFlapping ? t.highlight : t.primary;
7528
+ grid[droneRow][DRONE_X] = droneColor(droneGlyphLeft);
7529
+ if (DRONE_X + 1 < ARENA_WIDTH6) {
7530
+ grid[droneRow][DRONE_X + 1] = droneColor(droneGlyphRight);
7531
+ }
7532
+ }
7533
+ const arenaLines = [];
7534
+ arenaLines.push(
7535
+ t.border("\u250C") + t.error("\u2550".repeat(ARENA_WIDTH6)) + t.border("\u2510")
7536
+ );
7537
+ for (let r = 0; r < ARENA_HEIGHT5; r++) {
7538
+ arenaLines.push(t.border("\u2502") + grid[r].join("") + t.border("\u2502"));
7539
+ }
7540
+ const trackPattern = ["\u2592\u2591\u2592\u2591", "\u2591\u2592\u2591\u2592", "\u2592\u2592\u2591\u2591", "\u2591\u2591\u2592\u2592"][this.groundOffset] || "\u2592\u2591\u2592\u2591";
7541
+ const floorBar = trackPattern.repeat(Math.ceil(ARENA_WIDTH6 / 4)).slice(0, ARENA_WIDTH6);
7542
+ arenaLines.push(
7543
+ t.border("\u2514") + t.border(floorBar) + t.border("\u2518")
7544
+ );
7545
+ const streakDisplay = this.state.streak > 1 ? t.highlight(` ${this.state.streak}x STREAK `) : "";
7546
+ const telemetry = ` GATES: ${t.primary(String(this.state.conduitsPassed).padStart(2, "0"))} \u2502 V: ${this.state.droneVelocityY >= 0 ? "+" : ""}${this.state.droneVelocityY.toFixed(1)}${streakDisplay}`;
7547
+ const controls = t.muted(" [Space/W] Flap [P] Pause [R] Reboot [Q] Exit ");
7548
+ if (this.state.isGameOver) {
7549
+ const goLines = [
7550
+ t.error(" CONDUIT COLLISION DETECTED "),
7551
+ t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
7552
+ ` FINAL SCORE: ${t.highlight(String(this.state.score))} HIGH SCORE: ${t.primary(String(this.state.highScore))}`,
7553
+ ` GATES CLEARED: ${t.highlight(String(this.state.conduitsPassed))} CENTER PASSES: ${t.accent(String(this.state.perfectPasses))}`,
7554
+ "",
7555
+ t.highlight(" Press [R] to Quick Reboot \u2502 [Q] Menu ")
7556
+ ];
7557
+ const goBox = this.renderer.createBox(goLines, 44, "SYSTEM CRITICAL");
7558
+ const boxLines = goBox.split("\n");
7559
+ const startY = Math.max(1, Math.floor((ARENA_HEIGHT5 - boxLines.length) / 2) + 1);
7560
+ for (let i = 0; i < boxLines.length; i++) {
7561
+ if (startY + i < arenaLines.length - 1) {
7562
+ const padded = this.renderer.centerBlock(boxLines[i], TOTAL_WIDTH5);
7563
+ arenaLines[startY + i] = padded;
7564
+ }
7565
+ }
7566
+ }
7567
+ const frame = [
7568
+ header,
7569
+ ...arenaLines,
7570
+ telemetry,
7571
+ controls
7572
+ ].join("\n");
7573
+ this.renderer.renderFrame(this.renderer.centerBlock(frame, TOTAL_WIDTH5));
7574
+ }
7575
+ // Testing & Inspection API
7576
+ getState() {
7577
+ return JSON.parse(JSON.stringify(this.state));
7578
+ }
7579
+ setState(partial) {
7580
+ this.state = { ...this.state, ...partial };
7581
+ }
7582
+ };
7583
+
5831
7584
  export {
5832
7585
  APP_NAME,
5833
7586
  APP_TAGLINE,
@@ -5866,6 +7619,9 @@ export {
5866
7619
  CyberDinoGame,
5867
7620
  CyberBreakoutGame,
5868
7621
  Cyber2048Game,
5869
- CyberTowerGame
7622
+ CyberTowerGame,
7623
+ ByteHopperGame,
7624
+ CyberSweeperGame,
7625
+ NeonFlapGame
5870
7626
  };
5871
- //# sourceMappingURL=chunk-EQAKR7UF.js.map
7627
+ //# sourceMappingURL=chunk-Z5UIN4FP.js.map