Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 8952x 8952x 2162x 2162x 2162x 2162x 270x 270x 2162x 6790x 8952x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 305x 305x 3747x 3747x 3180x 305x 305x 8952x 8647x 8647x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 73x 73x 73x 73x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8647x 8647x 5496x 5496x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 4161x 4161x 4161x 4161x 4161x 4161x 3942x 3942x 3942x 3942x 3942x 71x 71x 71x 71x 71x 3942x 3942x 3942x 3942x 3942x 3942x 3942x 4161x 4161x 4161x 4161x 4161x 73x 73x 3853x 3853x 3853x 3853x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 308x 308x 308x 308x 308x 308x 308x 308x 308x 73x 73x 73x 73x 9330x 9330x 73x 73x 73x 73x 73x 73x 73x 73x 8656x 8656x 8656x 8656x 65908x 65908x 8656x 8656x 8656x 65908x 8656x 8656x 8656x 8656x 8656x 8656x 8656x 8656x 8656x 8656x 8656x 8656x 8656x 73x 73x 73x 8647x 8647x 8647x 8647x 8647x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 8952x 475x 8952x 23x 23x 23x 23x 8477x 8454x 8454x 8454x 8454x 8454x 8454x 8952x 8952x 8952x 8952x 8952x 73x 73x 73x 73x 73x 73x 73x 73x 8987x 8987x 8987x 8987x 73x 8454x 8454x 8454x 8454x 73x 23x 23x 23x 23x 3x 23x 3x 23x 23x 23x 17x 23x 23x 23x 73x 22154x 22154x 22154x 22154x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 171x 171x 171x 171x 171x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 40x 40x 40x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x | // botl.js -- Bottom line status display (port of botl.c)
// Handles the status bar at the bottom of the screen.
// No RNG consumed in any function.
import { game } from './gstate.js';
import { ACURR } from './attrib.js';
import { depth, highc, mungspaces, str_start_is } from './hacklib.js';
import { In_endgame, In_quest, Role_switch, Ugender, Upolyd } from './macros.js';
import {
Hallucination, Blind, Deaf, Stunned, Confusion,
Levitation, Flying, Stoned, Slimed, Strangled, Sick,
Glib, Wounded_legs, Underwater,
} from './macros.js';
import { near_capacity } from './pickup.js';
import { money_cnt } from './hack.js';
import { pushRngLogEntry } from './rng.js';
import { setBotlx } from './display.js';
import { pmname } from './do_name.js';
import { hu_stat } from './eat.js';
import { newuexp } from './exper.js';
import { roles } from './roles.js';
import { mons } from './monsters.js';
import { A_CHA, A_CHAOTIC, A_CON, A_DEX, A_INT, A_NEUTRAL, A_STR, A_WIS, BL_AC, BL_ALIGN, BL_CAP, BL_CH, BL_CO, BL_CONDITION, BL_DX, BL_ENE, BL_ENEMAX, BL_EXP, BL_GOLD, BL_HD, BL_HP, BL_HPMAX, BL_HUNGER, BL_IN, BL_LEVELDESC, BL_SCORE, BL_STR, BL_TIME, BL_TITLE, BL_VERS, BL_WI, BL_XP, BOTL_NSIZ, COLNO, FEMALE, Is_rogue_level, MAXBLSTATS, MAXVALWIDTH, NON_PM, NOT_HUNGRY, SICK_NONVOMITABLE, SICK_VOMITABLE, STR18, UNENCUMBERED } from './const.js';
import { COIN_CLASS, GOLD_PIECE } from './objects.js';
import { dunlev } from './dungeon.js';
export {
BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH,
BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX,
BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, BL_HPMAX,
BL_LEVELDESC, BL_EXP, BL_CONDITION, BL_VERS, MAXBLSTATS,
};
// ── Encumbrance strings (C: botl.c:12) ──
export const enc_stat = [
'', 'Burdened', 'Stressed',
'Strained', 'Overtaxed', 'Overloaded',
];
// ── Strength display (C: botl.c:22 get_strength_str) ──
export function get_strength_str() {
const st = ACURR(A_STR);
if (st > 18) {
if (st > STR18(100))
return String(st - 100);
else if (st < STR18(100))
return `18/${String(st - 18).padStart(2, '0')}`;
else
return '18/**';
}
return String(st);
}
// ── check_gold_symbol (C: botl.c:40) ──
export function check_gold_symbol() {
// iflags.invis_goldsym -- not critical for gameplay, stub
}
// ── do_statusline1 (C: botl.c:49) ──
//
// C ref: do_statusline1 builds:
// "<Name> the <Rank/Monster> <pad to mrank_sz+15>St:<stats> <Align>"
// Empirically C's output in recorded sessions always aligns "St:" at
// column 31 for the 20-char "Astrid the Stripling" case, implying
// mrank_sz=16 (mrank_sz+15=31). JS's max_rank_sz computes 13 for
// Valkyrie; the discrepancy is unexplained — possibly C picks up extra
// padding somewhere we haven't traced. Until that's understood, match
// C's observed STATS_COL=31 directly so recorded sessions render
// identically.
export function do_statusline1() {
const g = game;
const u = g.u;
if (!u) return '';
if (suppress_map_output()) return '';
let newbot1 = g.plname || '';
if (newbot1.length > 0 && newbot1[0] >= 'a' && newbot1[0] <= 'z')
newbot1 = String.fromCharCode(newbot1.charCodeAt(0) + ('A'.charCodeAt(0) - 'a'.charCodeAt(0))) + newbot1.slice(1);
newbot1 = newbot1.substring(0, BOTL_NSIZ);
let nb = ' the ';
if (Upolyd()) {
let mbot = pmname(mons[u.umonnum], Ugender());
mbot = mbot.split('').map((c, k) => {
if ((k === 0 || (k > 0 && mbot[k - 1] === ' ')) && c >= 'a' && c <= 'z')
return String.fromCharCode(c.charCodeAt(0) + ('A'.charCodeAt(0) - 'a'.charCodeAt(0)));
return c;
}).join('');
nb += mbot;
} else {
nb += rank();
}
newbot1 += nb;
// C ref: " " + pad. Total "St:" starts at column 31 (observed from
// recorded sessions — see note above). C's formula is
// newbot1 += " "; if (mrank_sz+15 > strlen) pad with diff
// which empirically produces 31 for all tested roles.
const STATS_COL = 31;
const pad = Math.max(2, STATS_COL - newbot1.length);
newbot1 += ' '.repeat(pad);
newbot1 += `St:${get_strength_str()} Dx:${ACURR(A_DEX)} Co:${ACURR(A_CON)} In:${ACURR(A_INT)} Wi:${ACURR(A_WIS)} Ch:${ACURR(A_CHA)}`;
const u_align = u.ualign?.type ?? 0;
// C source has " " prefix but recorded session output shows one space
// (likely swallowed by TTY end-of-line erase / column clipping).
newbot1 += (u_align === A_CHAOTIC) ? ' Chaotic'
: (u_align === A_NEUTRAL) ? ' Neutral'
: ' Lawful';
return newbot1;
}
// ── do_statusline2 (C: botl.c:101) ──
export function do_statusline2() {
const g = game;
const u = g.u;
if (!u) return '';
if (suppress_map_output()) return '';
// Dungeon level + gold
let dloc = describe_level('', 1);
let money = money_cnt(g.invent);
if (money < 0) money = 0;
const goldSymbol = Is_rogue_level(g.u?.uz) ? '*' : '$';
dloc += `${goldSymbol}:${Math.min(money, 999999)}`;
const dln = dloc.length;
const dx = 0; // no \G encoding in JS
// Health + AC
let hp = Upolyd() ? u.mh : u.uhp;
const hpmax = Upolyd() ? u.mhmax : u.uhpmax;
if (hp < 0) hp = 0;
const hlth = `HP:${Math.min(hp, 9999)}(${Math.min(hpmax, 9999)}) Pw:${Math.min(u.uen, 9999)}(${Math.min(u.uenmax, 9999)}) AC:${u.uac}`;
const hln = hlth.length;
// Experience
let expr;
if (Upolyd())
expr = `HD:${mons[u.umonnum].mlevel}`;
else if (g.flags?.showexp)
expr = `Xp:${u.ulevel}/${u.uexp}`;
else
expr = `Xp:${u.ulevel}`;
const xln = expr.length;
// Time/moves
let tmmv = '';
if (g.flags?.time)
tmmv = `T:${g.moves}`;
const tln = tmmv.length;
// Status conditions
let cond = '';
if (Stoned()) cond += ' Stone';
if (Slimed()) cond += ' Slime';
if (Strangled()) cond += ' Strngl';
if (Sick()) {
if ((u.usick_type & SICK_VOMITABLE)) cond += ' FoodPois';
if ((u.usick_type & SICK_NONVOMITABLE)) cond += ' TermIll';
}
if (u.uhs !== NOT_HUNGRY)
cond += ` ${hu_stat[u.uhs]}`;
const cap = near_capacity();
if (cap > UNENCUMBERED)
cond += ` ${enc_stat[cap]}`;
if (Levitation()) cond += ' Lev';
if (Flying()) cond += ' Fly';
if (Blind()) cond += ' Blind';
if (Deaf()) cond += ' Deaf';
if (Stunned()) cond += ' Stun';
if (Confusion()) cond += ' Conf';
if (Hallucination()) cond += ' Hallu';
if (u.usteed) cond += ' Ride';
const cln = cond.length;
// Version: omitted
const vers = '';
const vrn = 0;
// Assemble (C: botl.c:228)
let newbot2;
if ((dln - dx) + 1 + hln + 1 + xln + 1 + tln + 1 + cln + vrn <= COLNO) {
newbot2 = `${dloc} ${hlth} ${expr} ${tmmv} ${cond}${vers}`;
} else if ((dln - dx) + 1 + hln + 1 + xln + 1 + cln <= COLNO) {
newbot2 = `${dloc} ${hlth} ${expr} ${cond} ${tmmv}${vers}`;
} else if ((dln - dx) + 1 + hln + 1 + cln <= COLNO) {
newbot2 = `${dloc} ${hlth} ${cond} ${expr} ${tmmv}${vers}`;
} else {
newbot2 = `${hlth} ${cond} ${dloc} ${expr} ${tmmv}${vers}`;
}
// Squeeze consecutive spaces
newbot2 = mungspaces(newbot2);
return newbot2;
}
// ── bot (C: botl.c:253) ──
//
// C ref:
// void bot(void) {
// if (gb.bot_disabled) return;
// if (u.uhp != -1 && gy.youmonst.data
// && iflags.status_updates && !suppress_map_output()) {
// if (VIA_WINDOWPORT()) bot_via_windowport();
// else {
// curs(WIN_STATUS, 1, 0);
// putstr(WIN_STATUS, 0, do_statusline1());
// curs(WIN_STATUS, 1, 1);
// putmixed(WIN_STATUS, 0, do_statusline2());
// }
// }
// disp.botl = disp.botlx = disp.time_botl = FALSE;
// }
//
// The C header wraps external bot() calls with midlog enter/exit
// (#ifndef MIDLOG_IN_BOTL_C). Calls from inside botl.c (notably
// timebot() → bot()) bypass that macro and do NOT emit midlogs. To
// match, we split into the exported wrapper bot() (emits >bot/<bot)
// and an internal _bot_core() used by timebot.
async function _bot_core() {
const g = game;
const u = g.u;
if (g.bot_disabled) return;
if (u?.uhp !== -1 && g.youmonst?.data
&& (g.iflags?.status_updates !== false) && !suppress_map_output()) {
// TTY non-windowport path: render lines 22 and 23.
// C writes to WIN_STATUS at row 1 col 0/1; JS grid maps status to
// rows 22–23 of a 24-row terminal.
const display = g.nhDisplay || null;
if (!g._statusWindowDataInit) {
// C ref: first bot() after tty_clear_nhwindow(STATUS) flags the
// row as newly-cleared so the next draw is a fresh write.
setBotlx('tty_clear_nhwindow');
g._statusWindowDataInit = true;
}
if (display) {
display.clearRow(22);
display.putstr(0, 22, do_statusline1());
display.clearRow(23);
display.putstr(0, 23, do_statusline2());
}
}
g.disp = g.disp || {};
g.disp.botl = 0;
g.disp.botlx = 0;
g.disp.time_botl = 0;
}
export async function bot() {
pushRngLogEntry('>bot');
await _bot_core();
pushRngLogEntry('<bot');
}
// ── timebot (C: botl.c:275) ──
//
// C ref:
// void timebot(void) {
// if (gb.bot_disabled) return;
// if (flags.time && iflags.status_updates && !suppress_map_output()) {
// if (VIA_WINDOWPORT()) stat_update_time();
// else bot(); // non-windowport: full status redraw
// }
// disp.time_botl = FALSE;
// }
//
// C's internal bot() call skips the midlog wrapper (MIDLOG_IN_BOTL_C),
// so we call _bot_core() directly instead of the public bot().
export async function timebot() {
const g = game;
if (g.bot_disabled) return;
if (g.flags?.time && (g.iflags?.status_updates !== false)
&& !suppress_map_output()) {
await _bot_core();
}
g.disp = g.disp || {};
g.disp.time_botl = 0;
}
// ── xlev_to_rank (C: botl.c:303) ──
export function xlev_to_rank(xlev) {
return (xlev <= 2) ? 0 : (xlev <= 30) ? Math.trunc((xlev + 2) / 4) : 8;
}
// ── rank_to_xlev (C: botl.c:321) ──
export function rank_to_xlev(rk) {
return (rk < 1) ? 1 : (rk < 2) ? 3
: (rk < 8) ? ((rk * 4) - 2) : 30;
}
// ── rank_of (C: botl.c:338) ──
export function rank_of(lev, monnum, female) {
const g = game;
// Find the role matching monnum
let role = null;
for (let r = 0; r < roles.length; r++) {
if (!roles[r].name.m) break; // sentinel
if (monnum === roles[r].mnum) {
role = roles[r];
break;
}
}
if (!role) {
// Use player's current role
const roleIdx = g.flags?.initrole ?? 0;
role = roles[roleIdx];
}
if (!role) return 'Player';
// Find the rank
for (let i = xlev_to_rank(lev); i >= 0; i--) {
if (female && role.rank[i]?.f)
return role.rank[i].f;
if (role.rank[i]?.m)
return role.rank[i].m;
}
// Try the role name instead
if (female && role.name.f)
return role.name.f;
else if (role.name.m)
return role.name.m;
return 'Player';
}
// ── rank (C: botl.c:367 -- static) ──
function rank() {
const g = game;
const u = g.u;
return rank_of(u.ulevel, Role_switch(), g.flags?.female);
}
// ── title_to_mon (C: botl.c:373) ──
export function title_to_mon(str, result) {
// result = { rank_indx: 0, title_length: 0 }
for (let i = 0; i < roles.length; i++) {
if (!roles[i].name.m) break;
for (let j = 0; j < 9; j++) {
if (roles[i].rank[j]?.m
&& str_start_is(str, roles[i].rank[j].m, true)) {
if (result) {
result.rank_indx = j;
result.title_length = roles[i].rank[j].m.length;
}
return roles[i].mnum;
}
if (roles[i].rank[j]?.f
&& str_start_is(str, roles[i].rank[j].f, true)) {
if (result) {
result.rank_indx = j;
result.title_length = roles[i].rank[j].f.length;
}
return roles[i].mnum;
}
}
}
if (result) result.title_length = 0;
return NON_PM;
}
// ── max_rank_sz (C: botl.c:408) ──
export function max_rank_sz() {
const g = game;
const roleIdx = g.flags?.initrole ?? 0;
const role = roles[roleIdx];
if (!role?.rank) { g._mrank_sz = 0; return; }
let maxr = 0;
for (let i = 0; i < 9; i++) {
const r = role.rank[i];
if (r?.m && r.m.length > maxr) maxr = r.m.length;
if (r?.f && r.f.length > maxr) maxr = r.f.length;
}
g._mrank_sz = maxr;
}
// helper: read cached mrank_sz
function compute_mrank_sz() {
const g = game;
if (g._mrank_sz != null) return g._mrank_sz;
max_rank_sz();
return g._mrank_sz ?? 16;
}
// ── botl_score (C: botl.c:425, #ifdef SCORE_ON_BOTL) ──
export function botl_score() {
// Simplified: full implementation requires deepest_lev_reached, hidden_gold
return 0;
}
// ── describe_level (C: botl.c:447) ──
export function describe_level(buf_unused, dflgs) {
const g = game;
const u = g.u;
const uz = u?.uz;
if (!uz) return 'Dlvl:1 ';
const addspace = (dflgs & 1) !== 0;
let addbranch = (dflgs & 2) !== 0;
let buf = '';
let ret = 1;
if (Is_knox(uz)) {
buf = g.dungeons?.[uz.dnum]?.dname ?? 'Fort Ludios';
addbranch = false;
} else if (In_quest(uz)) {
buf = `Home ${dunlev(uz)}`;
} else if (In_endgame(uz)) {
buf = endgamelevelname(depth(uz));
if (!addbranch)
buf = buf.replace('Plane of ', '');
addbranch = false;
} else {
if (!addbranch) {
const prefix = In_tutorial(uz) ? 'Tutorial' : 'Dlvl';
buf = `${prefix}:${depth(uz)}`;
} else {
buf = `level ${depth(uz)}`;
}
ret = 0;
}
if (addbranch) {
let dname = g.dungeons?.[uz.dnum]?.dname ?? '';
dname = dname.replace(/^The /, 'the ');
buf += `, ${dname}`;
}
if (addspace)
buf += ' ';
return buf;
}
// ── depth (C: dungeon.c) ── local helper
// dunlev: imported from dungeon.js
// ── Dungeon helpers (stubs for special levels) ──
export function Is_knox(uz) {
const g = game;
return Number.isInteger(g.knox_level?.dnum) && uz.dnum === g.knox_level.dnum
&& uz.dlevel === g.knox_level.dlevel;
}
function In_tutorial(uz) {
const g = game;
return Number.isInteger(g.tutorial_dnum) && uz.dnum === g.tutorial_dnum;
}
function endgamelevelname(dep) {
// C ref: dungeon.c endgamelevelname()
switch (dep) {
case -5:
return 'Astral Plane';
case -4:
return 'Plane of Water';
case -3:
return 'Plane of Fire';
case -2:
return 'Plane of Air';
case -1:
return 'Plane of Earth';
default:
return `unknown plane #${dep}`;
}
}
function suppress_map_output() {
const g = game;
return !!(g.program_state?.restoring);
}
// Role_switch: imported from macros.js
// Ugender imported from macros.js
// ── status_initialize (C: botl.c:1437) ──
// C ref: botl.c status_initialize() — init status window + force full redraw.
// In JS, emit ^botlx[status_initialize] to match the C event sequence (C
// sets disp.botlx TRUE at the end of the init so the next bot() writes a
// full fresh line instead of a delta).
export function status_initialize(reassessment) {
const g = game;
g.blinit = true;
g.update_all = true;
setBotlx('status_initialize');
}
// ── status_finish (C: botl.c:1473) ──
export function status_finish() {
// Cleanup -- nothing to free in JS
}
// ── stat_cap_indx (C: botl.c:1877) ──
export function stat_cap_indx() {
return near_capacity();
}
// ── stat_hunger_indx (C: botl.c:1892) ──
export function stat_hunger_indx() {
return game.u?.uhs ?? NOT_HUNGRY;
}
// ── cond_menu (C: botl.c:1132) ──
export async function cond_menu() {
// Condition toggle menu -- requires full menu system
// Stub: return false (no changes)
return false;
}
// ── status_hilite_menu (C: botl.c:4244) ──
export async function status_hilite_menu() {
// Status hilite configuration menu -- requires full menu system
// Stub: return true
return true;
}
// ── condopt (C: botl.c:1059) ──
export function condopt(idx, addr, negated) {
// Condition option processing -- no-op until full condition system
return 0;
}
// ── status_update (C: via windowport) ──
export function status_update(fldidx, ptr, chg, percent, color, colormasks) {
// Windowport status update callback -- handled by display layer
}
// ── bot_via_windowport (C: botl.c:748) ──
// Not exported; called internally by bot() when VIA_WINDOWPORT is true.
// In JS tty port we use do_statusline1/do_statusline2 directly.
// ── exp_percentage (C: botl.c:1798) ──
function exp_percentage() {
const u = game.u;
if (!u || u.ulevel >= 30) return 0;
const curlvlstart = newuexp(u.ulevel - 1);
const exp_val = u.uexp - curlvlstart;
const nxt_exp_val = newuexp(u.ulevel) - curlvlstart;
if (exp_val === nxt_exp_val - 1)
return 100;
if (nxt_exp_val <= 0) return 0;
let res = Math.trunc((100 * exp_val) / nxt_exp_val);
if (res === 0 && exp_val !== 0) res = 1;
return res;
}
// ── exp_percent_changing (C: botl.c:1836) ──
export function exp_percent_changing() {
// Without full hilite infrastructure, always return false
return false;
}
// ── status_eval_next_unhilite (C: botl.c:2025) ──
export function status_eval_next_unhilite() {
// Hilite timeout processing -- no-op without STATUS_HILITES
}
// ── reset_status_hilites (C: botl.c:2067) ──
export function reset_status_hilites() {
const g = game;
g.update_all = true;
g.disp = g.disp || {};
g.disp.botlx = 1;
}
// ── clear_status_hilites (C: botl.c:3097) ──
export function clear_status_hilites() {
// No-op without STATUS_HILITES infrastructure
}
// ── parse_status_hl1 (C: botl.c:2339) ──
export function parse_status_hl1(op, from_configfile) {
// Hilite option parsing -- stub
return true;
}
// ── count_status_hilites (C: botl.c:3223) ──
export function count_status_hilites() {
return 0;
}
// ── opt_next_cond (C: botl.c:1213) ──
export function opt_next_cond(indx, outbuf) {
return false;
}
// ── parse_cond_option (C: botl.c:1110) ──
export function parse_cond_option(negated, opts) {
return 1; // error
}
// ── bl_idx_to_fldname (C: botl.c:1906) ──
const initblstats_fldnames = [
'title', 'strength', 'dexterity', 'constitution', 'intelligence',
'wisdom', 'charisma', 'alignment', 'score', 'carrying-capacity',
'gold', 'power', 'power-max', 'experience-level', 'armor-class',
'HD', 'time', 'hunger', 'hitpoints', 'hitpoints-max',
'dungeon-level', 'experience', 'condition', 'version',
];
export function bl_idx_to_fldname(idx) {
if (idx >= 0 && idx < MAXBLSTATS)
return initblstats_fldnames[idx];
return null;
}
// ── repad_with_dashes (C: botl.c:1917) ──
export function repad_with_dashes(buf) {
// Replace pairs of trailing spaces with space+dash
let arr = buf.split('');
let p = arr.length;
while (p >= 2 && arr[p - 1] === ' ' && arr[p - 2] === ' ') {
arr[p - 1] = '-';
p -= 2;
}
return arr.join('');
}
// ── all_options_statushilites (C: botl.c:4223) ──
export function all_options_statushilites(sbuf) {
// No-op without STATUS_HILITES
}
// ── bot_set_handler (C: unused in tty) ──
export function bot_set_handler(handler) {
// No-op for tty interface
}
|