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 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 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 | 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 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 3139x 3139x 3139x 3139x 73x 73x 13x 13x 13x 73x 73x 2x 73x 73x 73x 73x 69x 73x 73x 73x 73x 12x 12x 12x 12x 12x 12x 12x 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 49x 49x 49x 49x 49x 49x 49x 49x 49x 49x 49x 48x 48x 48x 49x 49x 48x 48x 828x 828x 13x 303x 828x 828x 12x 12x 12x 12x 12x 12x 828x 36x 36x 49x 37x 37x 37x 35x 35x 1x 1x 1x 1x 37x 1x 1x 35x 35x 37x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 95x 95x 95x 95x 3x 95x 92x 92x 11x 11x 92x 95x 11x 11x 11x 11x 11x 95x 73x 11x 11x 11x 11x 60x 60x 60x 60x 46x 46x 46x 60x 14x 14x 60x 60x 60x 60x 73x 3x 3x 3x 3x 3x 3x 3x 3x 3x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 610x 610x 610x 610x 26x 26x 26x 26x 26x 10x 10x 10x 14x 14x 14x 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 73x 73x 73x 503x 503x 503x 503x 503x 73x 427x 427x 427x 427x 427x 427x 427x 427x 427x 427x 427x 427x 427x 427x 427x 73x 1x 1x 1x 1x 1x 1x 1x 73x 73x 92x 92x 92x 92x 92x 92x 2x 2x 92x 92x 92x 73x 92x 92x 92x 92x 92x 73x 1x 1x 1x 1x 73x 24x 24x 7x 7x 24x 24x 24x 24x 24x 12x 12x 12x 12x 12x 12x 24x 24x 73x 73x 73x 73x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 73x 13x 13x 13x 13x 4x 4x 4x 13x 73x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 73x 73x 73x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 73x 816x 816x 816x 816x 816x 816x 816x 816x 816x 816x 816x 816x 816x 816x 816x 816x 73x 73x 73x 73x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 2x 2x 2x 1x 1x 1x 2x 2x 73x 12x 12x 12x 12x 12x 12x 816x 816x 12x 12x 12x 12x 12x 73x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 73x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 73x 73x 85x 85x 85x 85x 85x 85x 85x 85x 69x 69x 85x 16x 16x 16x 85x 73x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 3x 3x 23x 13x 13x 13x 13x 23x 23x 11x 11x 23x 23x 12x 12x 23x 23x 73x 73x 49x 49x 49x 49x 49x 49x 9x 9x 9x 48x 40x 40x 40x 40x 40x 40x 40x 49x 73x 73x 73x 73x 73x 73x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 3x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 3x 73x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 11x 6x 6x 6x 11x 12x 11x 11x 11x 11x 12x 11x 11x 11x 11x 11x 12x 12x 12x 12x 12x 1x 1x 1x 1x 12x 12x 12x 12x 1x 1x 1x 1x 12x 11x 11x 11x 1x 11x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 12x 12x 73x 23x 23x 23x 23x 23x 12x 12x 12x 23x 23x 7x 7x 7x 16x 23x 73x 10x 10x 10x 10x 1x 1x 1x 1x 1x 10x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10x 1x 1x 1x 1x 1x 1x 1x 10x 10x 1x 1x 1x 5x 5x 5x 1x 7x 7x 7x 10x 10x 10x 7x 7x 7x 7x 7x 2x 2x 7x 5x 5x 5x 5x 5x 5x 5x 5x 7x 73x 11x 11x 11x 11x 3x 3x 3x 11x 1x 1x 1x 1x 1x 1x 1x 11x 11x 11x 11x 2x 2x 11x 11x 73x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 73x 6212x 6212x 6212x 6200x 6212x 6212x 6212x 6212x 6060x 6060x 6212x 6212x 6200x 6212x 3066x 3066x 3066x 3066x 3066x 6212x 3134x 3134x 3134x 3134x 3134x 3134x 3134x 327x 327x 327x 327x 327x 327x 3134x 329x 329x 329x 4x 4x 329x 329x 329x 3134x 325x 325x 325x 325x 3134x 314x 314x 314x 4x 4x 314x 314x 314x 3134x 314x 314x 3134x 3134x 3134x 6200x 6212x 73x 73x 15x 15x 15x 73x 92x 92x 92x 92x 92x 92x 92x 3x 3x 3x 3x 3x 3x 3x 3x 3x 92x 92x 92x 73x 6344x 6344x 6344x 6344x 6344x 6104x 86x 6344x 6344x 167x 23x 23x 23x 167x 167x 6344x 6177x 23x 23x 23x 6177x 6344x 6344x 9x 9x 9x 9x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 9x 9x 9x 9x 9x 9x 9x 9x 6344x 73x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 73x 73x 1x 1x 1x 73x 2x 2x 1x 1x 1x 1x 2x 2x 73x 73x 73x 9x 9x 9x 1x 1x 1x 1x 8x 9x 73x 47x 47x 47x 47x 47x 47x 47x 47x 45x 45x 47x 45x 14x 14x 14x 45x 42x 42x 24x 42x 24x 36x 15x 15x 15x 24x 24x 24x 24x 24x 24x 42x 47x 12x 12x 12x 12x 12x 12x 12x 12x 1x 1x 1x 1x 1x 1x 12x 11x 11x 11x 11x 11x 1x 11x 12x 12x 12x 10x 12x 2x 1x 1x 1x 2x 12x 10x 10x 12x 24x 24x 42x 47x 47x 47x 24x 24x 24x 24x 29x 1x 1x 24x 47x 73x 73x 73x 73x 73x 73x 411x 411x 411x 411x 282x 411x 18x 18x 18x 18x 18x 2x 18x 8x 8x 8x 1x 8x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 5x 5x 2x 2x 2x 5x 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 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 72x 72x 72x 72x 72x | // eat.js -- Port of eat.c
// Eating, food effects, hunger management.
import { game } from './gstate.js';
import { rn2, rnd, rn1, c_d } from './rng.js';
import { pline, You, Your, You_feel, You_hear, You_cant, pline_The, verbalize } from './pline.js';
import {
Acid_resistance,
Antimagic,
Blind,
Blindfolded,
Breathless,
Cold_resistance,
Confusion,
Deaf,
Disint_resistance,
Displaced,
Fire_resistance,
Fixed_abil,
Flying,
Fumbling,
Glib,
Hallucination,
Invis,
Invisible,
Levitation,
Is_airlevel,
Is_waterlevel,
Lifesaved,
Poison_resistance,
Punished,
Race_if,
Role_if,
See_invisible,
Shock_resistance,
Sick,
Sick_resistance,
Sleep_resistance,
Slimed,
Slow_digestion,
Stone_resistance,
Stoned,
Strangled,
Stunned,
Unaware,
Unchanging,
Underwater,
Upolyd,
Vomiting,
maybe_polyd,
is_fainted,
U_AP_TYPE
} from './macros.js';
import { levl, m_at } from './map_access.js';
import { ABASE, ACURR, ACURRSTR, AMAX, adjalign, adjattrib, exercise, gainstr } from './attrib.js';
import { bot, canseemon, canspotmon, curs_on_u, display_nhwindow, newsym, set_mimic_blocking, setBotl } from './display.js';
import { AD_ACID, AD_BLND, AD_HALU, AD_STUN, AT_BREA, AT_ENGL, AT_MAGC, M2_UNDEAD, mons, MR_ACID, MR_COLD, MR_DISINT, MR_ELEC, MR_FIRE, MR_POISON, MR_SLEEP, MR_STONE, PM_ACID_BLOB, PM_BAT, PM_BLACK_PUDDING, PM_CAVE_DWELLER, PM_CHAMELEON, PM_CHICKATRICE, PM_CLERIC, PM_COCKATRICE, PM_DEATH, PM_DISENCHANTER, PM_DISPLACER_BEAST, PM_DOG, PM_DOPPELGANGER, PM_DWARF, PM_ELF, PM_FAMINE, PM_FIRE_ELEMENTAL, PM_FLESH_GOLEM, PM_FLOATING_EYE, PM_GELATINOUS_CUBE, PM_GENETIC_ENGINEER, PM_GHOUL, PM_GIANT_BAT, PM_GIANT_MIMIC, PM_GREEN_SLIME, PM_HOUSECAT, PM_HUMAN_WEREJACKAL, PM_HUMAN_WERERAT, PM_HUMAN_WEREWOLF, PM_KILLER_BEE, PM_KITTEN, PM_KNIGHT, PM_LARGE_CAT, PM_LARGE_DOG, PM_LARGE_MIMIC, PM_LEATHER_GOLEM, PM_LICHEN, PM_LITTLE_DOG, PM_LIZARD, PM_MASTER_MIND_FLAYER, PM_MEDUSA, PM_MIND_FLAYER, PM_MONK, PM_NEWT, PM_NURSE, PM_ORC, PM_PESTILENCE, PM_PYROLISK, PM_QUANTUM_MECHANIC, PM_QUEEN_BEE, PM_RAVEN, PM_RUST_MONSTER, PM_SANDESTIN, PM_SCORPION, PM_SMALL_MIMIC, PM_STALKER, PM_STONE_GOLEM, PM_TIGER, PM_VALKYRIE, PM_VIOLET_FUNGUS, PM_VLAD_THE_IMPALER, PM_WEREJACKAL, PM_WERERAT, PM_WEREWOLF, PM_WIZARD, PM_WRAITH, PM_YELLOW_LIGHT, S_BLOB, S_ELEMENTAL, S_FUNGUS, S_GOLEM, S_JELLY, S_LIGHT, S_MIMIC, S_PUDDING, S_VORTEX } from './monsters.js';
import { A_CHA, A_CON, A_DEX, A_INT, A_LAWFUL, A_MAX, A_STR, A_WIS, ACID_RES, EDOG, M_ATTK_AGR_DIED, M_ATTK_HIT, M_ATTK_MISS, AGGRAVATE_MONSTER, BLINDED, BY_COOKIE, CHOKING, COLD_RES, CONFLICT, CONFUSION, COST_BITE, COST_DSTROY, COST_OPEN, DEAF, DIED, DISINT_RES, DISPLACED, ECMD_CANCEL, ECMD_OK, ECMD_TIME, FAINTED, FAINTING, FAST, FIRE_RES, FROMFORM, FROMOUTSIDE, GETOBJ_EXCLUDE, GETOBJ_EXCLUDE_NONINVENT, GETOBJ_EXCLUDE_SELECTABLE, GETOBJ_NOFLAGS, GETOBJ_SUGGEST, GLIB, HALLUC, Has_contents, HEALTHY_TIN, HOMEMADE_TIN, HUNGER, HUNGRY, INTRINSIC, INVIS, ismnum, KILLED_BY, KILLED_BY_AN, LAST_PROP, LEVITATION, LL_CONDUCT, M_AP_NOTHING, M_AP_OBJECT, NO_KILLER_PREFIX, NON_PM, NOT_HUNGRY, POISON_RES, POISONING, PROTECTION, RANDOM_TIN, REGENERATION, ROTTEN_TIN, SATIATED, SEE_INVIS, SHOCK_RES, SICK, SICK_ALL, SICK_VOMITABLE, SLEEP_RES, SLEEPY, SLIMED, SPINACH_TIN, STARVED, STARVING, STEALTH, STONE_RES, STONING, STUNNED, TELEPAT, TELEPORT, TELEPORT_CONTROL, TIMEOUT, VOMITING, W_AMUL, W_ARMOR, W_ARTI, W_RING, W_RINGL, W_RINGR, W_SADDLE, W_TOOL, W_WEP, WEAK } from './const.js';
import { AMULET_CLASS, AMULET_OF_CHANGE, AMULET_OF_FLYING, AMULET_OF_GUARDING, AMULET_OF_LIFE_SAVING, AMULET_OF_REFLECTION, AMULET_OF_RESTFUL_SLEEP, AMULET_OF_STRANGULATION, AMULET_OF_UNCHANGING, AMULET_OF_YENDOR, APPLE, ATHAME, AXE, BALL_CLASS, BEARTRAP, BONE, C_RATION, CANDY_BAR, CARROT, CHAIN_CLASS, CLOTH, CLOVE_OF_GARLIC, COIN_CLASS, COPPER, CORPSE, CRAM_RATION, CREAM_PIE, CRYSKNIFE, DAGGER, DRAGON_HIDE, EGG, ELVEN_DAGGER, ENORMOUS_MEATBALL, EUCALYPTUS_LEAF, FAKE_AMULET_OF_YENDOR, FLESH, FLINT, FOOD_CLASS, FOOD_RATION, FORTUNE_COOKIE, GEM_CLASS, GLASS, GLOB_OF_GREEN_SLIME, GOLD, GOLD_PIECE, IRON, is_flammable, is_metallic, is_organic, is_rottable, is_rustprone, K_RATION, KNIFE, LEATHER, LEMBAS_WAFER, LUMP_OF_ROYAL_JELLY, MEAT_RING, MEAT_STICK, MEATBALL, METAL, MITHRIL, ORANGE, ORCISH_DAGGER, PANCAKE, PAPER, PEAR, PICK_AXE, PLASTIC, PLATINUM, POTION_CLASS, RIN_ADORNMENT, RIN_FREE_ACTION, RIN_GAIN_CONSTITUTION, RIN_GAIN_STRENGTH, RIN_INCREASE_ACCURACY, RIN_INCREASE_DAMAGE, RIN_INVISIBILITY, RIN_LEVITATION, RIN_PROTECTION, RIN_PROTECTION_FROM_SHAPE_CHAN, RIN_SEE_INVISIBLE, RIN_SLOW_DIGESTION, RIN_SUSTAIN_ABILITY, RING_CLASS, SCROLL_CLASS, SILVER, SILVER_DAGGER, SLIME_MOLD, SPBOOK_CLASS, SPRIG_OF_WOLFSBANE, STILETTO, TIN, TIN_OPENER, TRIDENT, TRIPE_RATION, VEGGY, WAX, WEAPON_CLASS, WOOD } from './objects.js';
import { pluslvl, more_experienced, newexplevel } from './exper.js';
import { an, corpse_xname, doname, makeplural, singular, the, the_unique_pm, xname } from './objnam.js';
import { pmname, rndmonnam, hcolor, type_is_pname } from './do_name.js';
import { distu, s_suffix, sgn, surface } from './hacklib.js';
import { nomul, set_occupation } from './cmd.js';
import { bcsign, eaten_stat, melt_ice, obj_nutrition, splitobj, weight } from './mkobj.js';
import { paranoid_query, ynFunction } from './input.js';
import { encumber_msg, near_capacity } from './pickup.js';
import { addinv_nomerge, carried, delobj, dropx, freeinv, getobj, makeknown, stackobj, useup, useupall, observe_object } from './invent.js';
import { b_trapped, float_up } from './trap.js';
import { acidic, attacktype, attacktype_fordmg, can_teleport, cantvomit, carnivorous, control_teleport, dmgtype, flesh_petrifies, herbivorous, humanoid, is_dwarf, is_elf, is_giant, is_orc, is_rider, is_undead, is_were, noncorporeal, olfaction, poisonous, poly_when_stoned, same_race, slimeproof, telepathic, touch_petrifies, vegan, vegetarian, your_race } from './mondata.js';
import { DEADMONSTER, Monnam, mon_nam, mondied, see_monsters, stop_occupation } from './mon.js';
import { is_mindless as mindless, monsndx } from './mondata.js';
import { Mgender } from './hacklib.js';
import { costly_alteration, costly_spot, sellobj_state } from './shk.js';
import { fall_asleep, incr_itimeout, set_itimeout } from './timeout.js';
import { selftouch, make_blinded, make_sick, make_glib } from './mhitu.js';
import { is_ice } from './dbridge.js';
import { remove_worn_item } from './steal.js';
import { trycall, revive_corpse, dropy, heal_legs } from './do.js';
import { set_ulycn, were_beastie, you_unwere } from './were.js';
import { attrcurse } from './sit.js';
import { Ring_gone, fingers_or_gloves, toggle_displacement } from './do_wear.js';
import { can_reach_floor, change_luck, check_capacity, done, end_running, inv_cnt, livelog_printf, losehp, rounddiv } from './hack.js';
import { welded, uwepgone, uqwepgone, uswapwepgone } from './wield.js';
import { make_slimed, dopotion, make_vomiting, make_stunned, make_confused, make_deaf, make_stoned, make_hallucinated, self_invis_message } from './potion.js';
import { body_part, change_sex, polymon, polyself, rehumanize, setuhpmax } from './polyself.js';
import { Soundeffect } from './sounds.js';
import { unpunish } from './read.js';
import { getrumor, outrumor } from './rumors.js';
import { o_unleash } from './apply.js';
import { delayed_killer } from './end.js';
import { dismount_steed } from './steed.js';
import { vault_gd_watching } from './vault.js';
import { retouch_equipment } from './artifact.js';
// ── Aliases ──
const g = game;
// ── Non-RNG stubs for functions not yet ported ──
// These stubs NEVER call rn2/rnd/rn1/d to avoid RNG desync.
// Now imported from macros.js: Breathless, Strangled, Unchanging,
// Sick_resistance, Sick, Stoned, Slimed, Vomiting, Glib,
// Slow_digestion, Lifesaved, Punished, Displaced
function Hunger() {
const p = game.u?.uprops?.[HUNGER];
return !!((p?.intrinsic || 0) || (p?.extrinsic || 0));
}
// C: u_safe_from_fatal_corpse(obj, flags) — check if player is safe from fatal effects of corpse
export function u_safe_from_fatal_corpse(obj, flags) {
// TODO: port from eat.c
return true;
}
// Fixed_abil: imported from macros.js
// U_AP_TYPE imported from macros.js
function ATEMP(ndx) { return game.u?.atemp?.a?.[ndx] ?? 0; }
function setATEMP(ndx, val) {
if (!game.u.atemp) game.u.atemp = { a: [0,0,0,0,0,0] };
game.u.atemp.a[ndx] = val;
}
function ATTRMIN(_ndx) { return 3; } // C minimum attribute value
function ATTRMAX(_ndx) { return 25; } // C maximum attribute value
// exercise imported from attrib.js
// losehp imported from hack.js
function obj_here(obj, x, y) { return obj && obj.ox === x && obj.oy === y; }
// splitobj imported from mkobj.js
// freeinv imported from invent.js
// useup imported from invent.js
export function useupf(obj, qty) {
// C: useupf removes floor objects by quantity
if (!obj) return;
if (obj.quan > qty) {
obj.quan -= qty;
obj.owt = weight(obj);
} else {
delobj(obj);
}
}
// useupall imported from invent.js
// addinv_nomerge imported from invent.js
// costly_alteration imported from shk.js
// inv_cnt imported // TODO
// dropy imported
// dropx imported from invent.js
// stackobj imported from invent.js
// stop_occupation imported from mon.js
// set_occupation imported from cmd.js (emits midlog events)
// delobj imported from invent.js
// make_vomiting imported
// make_sick imported from mhitu.js
// make_stunned imported
// make_confused imported
// make_blinded imported from mhitu.js
// make_deaf imported
// make_stoned imported
// make_slimed imported from potion.js
// make_hallucinated imported
// make_glib imported from mhitu.js
// incr_itimeout imported from timeout.js
export async function fix_petrification() {
let buf;
if (Hallucination())
buf = 'What a pity--you just ruined a future piece of ' +
(ACURR(A_CHA) > 15 ? 'fine ' : '') + 'art!';
else
buf = 'You feel limber!';
await make_stoned(0, buf, 0, null);
}
// done imported from hack.js
// bot imported
// end_running imported
// trycall imported from do.js
// selftouch imported from mhitu.js
// rehumanize imported from polyself.js
// polyself imported from polyself.js
// polymon imported from polyself.js
// dismount_steed imported from steed.js
// curs_on_u imported
// toggle_displacement imported
// attrcurse imported // TODO
// set_ulycn imported
// retouch_equipment: imported from artifact.js
function rescham() { /* stub - not yet ported */ }
// Ring_gone imported
// see_monsters imported from mon.js
// set_mimic_blocking imported from display.js
// livelog_printf imported from hack.js
// b_trapped imported from trap.js
async function floorfood(verb, corpsecheck) {
let otmp;
let c;
const uptr = game.player?.data;
const feeding = (verb === 'eat'); /* corpsecheck==0 */
const offering = (verb === 'sacrifice'); /* corpsecheck==1 */
game.getobj_else = 0;
/* if we can't touch floor objects then use invent food only */
if (!can_reach_floor(true) || (feeding && game.u?.usteed))
/* goto skipfloor */
return await floorfood_skipfloor(verb, corpsecheck, feeding, offering);
/* Is there some food (probably a heavy corpse) here on the ground? */
/* C ref: eat.c floorfood — iterates level.objects[u.ux][u.uy] via nexthere.
* JS stores floor objects in a flat array; iterate newest-first matching C. */
const level_objects = game.level?.objects;
if (level_objects) {
const ux = game.u.ux, uy = game.u.uy;
for (let _fi = level_objects.length - 1; _fi >= 0; _fi--) {
otmp = level_objects[_fi];
if (!otmp || otmp.ox !== ux || otmp.oy !== uy) continue;
if (corpsecheck
? (otmp.otyp === CORPSE
&& (corpsecheck === 1 || true /* tinnable */))
: feeding ? (otmp.oclass !== COIN_CLASS && is_edible(otmp))
: otmp.oclass === FOOD_CLASS) {
const one = (otmp.quan === 1 || !otmp.quan);
/* "There is/are <object> here; eat it/one?" */
const qbuf = 'There ' + (one ? 'is ' : 'are ') +
doname(otmp) + ' here; ' + verb + ' ' + (one ? 'it' : 'one') + '?';
c = await ynFunction(qbuf, 'ynq', 'n'.charCodeAt(0));
if (c === 'y'.charCodeAt(0)) return otmp;
else if (c === 'q'.charCodeAt(0)) return null;
++game.getobj_else;
}
}
}
return await floorfood_skipfloor(verb, corpsecheck, feeding, offering);
}
async function floorfood_skipfloor(verb, corpsecheck, feeding, offering) {
let otmp;
if (feeding) {
otmp = await getobj('eat', eat_ok, GETOBJ_NOFLAGS);
} else if (offering) {
otmp = await getobj('sacrifice', offer_ok, GETOBJ_NOFLAGS);
} else if (corpsecheck === 2) {
otmp = await getobj(verb, tin_ok, GETOBJ_NOFLAGS);
} else {
otmp = null;
}
if (otmp && corpsecheck && !(offering && otmp.oclass === AMULET_CLASS)) {
if (otmp.otyp !== CORPSE) {
await You_cant(verb + ' that!');
otmp = null;
}
}
game.getobj_else = 0;
return otmp;
}
// check_capacity imported // TODO
// getobj imported from invent.js
// C ref: rumors.c:529 outrumor — read a fortune cookie or paper fortune
// Consumes rn2(2) for truth + rn2(range) for line selection (matching getrumor)
// NOTE: differs from canonical timeout.js — empty stub; canonical has nomul/usleep logic
// more_experienced imported
// newexplevel imported
// vault_gd_watching imported from vault.js
// dopotion imported // TODO
// o_unleash imported from apply.js
// uwepgone imported
// uqwepgone imported
// uswapwepgone imported
// unpunish imported from ball.js
// remove_worn_item imported from steal.js
// heal_legs imported from hack.js
// setuhpmax: imported from polyself.js
// delayed_killer imported from end.js
// revive_corpse imported // TODO
function consume_oeaten(obj, amt) {
// Port of consume_oeaten from eat.c
if (!obj_nutrition(obj)) return;
if (amt > 0) {
obj.oeaten >>= amt;
} else {
if (obj.oeaten > -amt)
obj.oeaten += amt;
else
obj.oeaten = 0;
}
if (obj.oeaten === 0) {
const vc = game.context?.victual;
if (vc && obj === vc.piece)
vc.reqtime = vc.usedtime;
obj.oeaten = 1;
}
}
// NOTE: differs from canonical hack.js — different rounding algorithm; canonical uses truncation with sign handling
function peek_at_iced_corpse_age(obj) {
// C: adjusts age if corpse is on ice; simplified - just return age
return obj.age || 0;
}
function food_xname(food, the_pfx) {
// C: food_xname from eat.c
let result;
if (food.otyp === CORPSE) {
result = corpse_xname(food, null, 1 | (the_pfx ? 4 : 0)); // CXN_SINGULAR | CXN_PFX_THE
if (type_is_pname(mons[food.corpsenm]))
the_pfx = false;
} else {
result = singular(food, xname);
}
if (the_pfx)
result = the(result);
return result;
}
// NOTE: differs from canonical polyself.js — simplified lookup table; canonical calls mbodypart(game.player, part)
function foodword(otmp) {
if (otmp.oclass === FOOD_CLASS) return 'food';
const material = game.objects[otmp.otyp]?.oc_material;
if (otmp.oclass === GEM_CLASS && material === GLASS
&& otmp.dknown)
makeknown(otmp.otyp);
if (material !== undefined && material >= 0 && material < foodwords_arr.length)
return foodwords_arr[material];
return 'meal';
}
// NOTE: differs from canonical do_wear.js — simplified; canonical checks uarmg and uses gloves_simple_name
// bcsign imported from mkobj.js
// maybe_polyd imported from weapon.js
// your_race imported from mondata.js
// NOTE: differs from canonical mondata.js — simplified mlet check; canonical has full race-by-race comparison
// NOTE: differs from canonical were.js — always returns NON_PM; canonical has full PM_WERE* switch
// is_rider imported from mondata.js
// NOTE: differs from canonical mondata.js — doesn't include Medusa
// touch_petrifies imported from mondata.js
// NOTE: differs from canonical mondata.js — checks mresists & MR_ACID; canonical checks mflags1 & M1_ACID
// NOTE: differs from canonical mondata.js — checks mresists & MR_POISON; canonical checks mflags1 & M1_POIS
// is_undead imported from mondata.js
// carnivorous imported // TODO: check MR2_CARNIVORE
// herbivorous imported // TODO
// humanoid imported from mondata.js
function metallivorous(ptr) {
// C: metallivore() from mondata.h — M1_METALLIVORE flag
return !!(ptr?.mflags1 & 0x80000000); // M1_METALLIVORE
}
function nonrotting_corpse(mnum) {
return mnum === PM_LIZARD || mnum === PM_LICHEN
|| is_rider(mons[mnum])
|| mnum === PM_ACID_BLOB;
}
function nonrotting_food(otyp) {
return otyp === LEMBAS_WAFER || otyp === CRAM_RATION;
}
function CANNIBAL_ALLOWED() {
return Role_if(PM_CAVE_DWELLER) || Race_if(PM_ORC);
}
function stale_egg(otmp) {
// C: stale_egg() - egg goes bad after 150 turns (or 200 if blessed)
if (!otmp || otmp.otyp !== EGG) return false;
const age = game.moves - (otmp.age || 0);
return age > (otmp.blessed ? 200 : 150);
}
// slimeproof imported from mondata.js
// can_teleport imported from mondata.js
// control_teleport imported // TODO
// telepathic: imported from mondata.js
// NOTE: differs from canonical mondata.js — direct .some() check; canonical delegates to attacktype_fordmg
// NOTE: differs from canonical mondata.js — doesn't handle AD_ANY=0 as wildcard for dtyp
// is_giant imported // TODO: check mflags for giant
// type_is_pname imported // TODO
// the_unique_pm: imported from objnam.js
// NOTE: differs from canonical mondata.js — always returns false; canonical checks monster type
// is_were imported from mondata.js
// welded imported from wield.js
// NOTE: differs from canonical mondata.js — always returns false; canonical checks rodents/horses
// (is_edible_stub removed; is_edible below implements the full C logic)
// paranoid_query: imported from input.js
// is_ice imported from dbridge.js
// melt_ice: imported from mkobj.js
// is_elf imported // TODO
// is_dwarf imported // TODO
// NOTE: differs from canonical mondata.js — no null check or ptr.mndx fallback
// ── Constants ──
const TTSZ = 16; // number of tin types including empty sentinel
const tintxts = [
{ txt: 'rotten', nut: -50, fodder: 0, greasy: 0 }, // ROTTEN_TIN = 0
{ txt: 'homemade', nut: 50, fodder: 1, greasy: 0 }, // HOMEMADE_TIN = 1
{ txt: 'soup made from', nut: 20, fodder: 1, greasy: 0 },
{ txt: 'french fried', nut: 40, fodder: 0, greasy: 1 },
{ txt: 'pickled', nut: 40, fodder: 1, greasy: 0 },
{ txt: 'boiled', nut: 50, fodder: 1, greasy: 0 },
{ txt: 'smoked', nut: 50, fodder: 1, greasy: 0 },
{ txt: 'dried', nut: 55, fodder: 1, greasy: 0 },
{ txt: 'deep fried', nut: 60, fodder: 0, greasy: 1 },
{ txt: 'szechuan', nut: 70, fodder: 1, greasy: 0 },
{ txt: 'broiled', nut: 80, fodder: 0, greasy: 0 },
{ txt: 'stir fried', nut: 80, fodder: 0, greasy: 1 },
{ txt: 'sauteed', nut: 95, fodder: 0, greasy: 0 },
{ txt: 'candied', nut: 100, fodder: 1, greasy: 0 },
{ txt: 'pureed', nut: 500, fodder: 1, greasy: 0 },
{ txt: '', nut: 0, fodder: 0, greasy: 0 },
];
const hu_stat = [
'Satiated', ' ', 'Hungry ', 'Weak ',
'Fainting', 'Fainted ', 'Starved '
];
const zero_victual = {
piece: null, o_id: 0, usedtime: 0, reqtime: 0,
nmod: 0, canchoke: 0, fullwarn: 0, eating: 0, doreset: 0,
};
const foodwords_arr = [
'meal', 'liquid', 'wax', 'food', 'meat', 'paper',
'cloth', 'leather', 'wood', 'bone', 'scale', 'metal',
'metal', 'metal', 'silver', 'gold', 'platinum', 'mithril',
'plastic', 'glass', 'rich food', 'stone'
];
// Ensure victual context exists
function vc() {
if (!game.context) game.context = {};
if (!game.context.victual) game.context.victual = { ...zero_victual };
return game.context.victual;
}
function tc() {
if (!game.context) game.context = {};
if (!game.context.tin) game.context.tin = { tin: null, o_id: 0, usedtime: 0, reqtime: 0 };
return game.context.tin;
}
// ── is_edible ──
function is_edible(obj) {
// C: is_edible from eat.c
if (game.objects[obj.otyp]?.oc_unique) return false;
if (game.youmonst?.data === mons[PM_FIRE_ELEMENTAL] && is_flammable(obj))
return true;
if (metallivorous(game.youmonst?.data) && is_metallic(obj)
&& (game.youmonst?.data !== mons[PM_RUST_MONSTER] || is_rustprone(obj)))
return true;
if (game.u?.umonnum === PM_GHOUL)
return (obj.otyp === CORPSE && !vegan(mons[obj.corpsenm]))
|| obj.otyp === EGG;
if (game.u?.umonnum === PM_GELATINOUS_CUBE && is_organic(obj)
&& !Has_contents(obj))
return true;
return obj.oclass === FOOD_CLASS;
}
// ── init_uhunger ──
async function init_uhunger() {
game.disp = game.disp || {};
game.disp.botl = (game.u.uhs !== NOT_HUNGRY || ATEMP(A_STR) < 0);
game.u.uhunger = 900;
game.u.uhs = NOT_HUNGRY;
if (ATEMP(A_STR) < 0) {
setATEMP(A_STR, 0);
await encumber_msg();
}
}
// ── obj_nutrition ──
// obj_nutrition: imported from mkobj.js
function adj_victual_nutrition() {
const v = vc();
const otyp = v.piece.otyp;
let nut = -v.nmod; // convert nmod (negative) to positive
if (nut <= 0) nut = 1;
if (otyp === LEMBAS_WAFER) {
if (maybe_polyd(is_elf(game.player?.data), Race_if(PM_ELF)))
nut += Math.trunc((nut + 2) / 4);
else if (maybe_polyd(is_orc(game.player?.data), Race_if(PM_ORC)))
nut -= Math.trunc((nut + 2) / 4);
} else if (otyp === CRAM_RATION) {
if (maybe_polyd(is_dwarf(game.player?.data), Race_if(PM_DWARF)))
nut += Math.trunc((nut + 3) / 6);
}
return Math.max(nut, 1);
}
// ── recalc_wt ──
function recalc_wt() {
const piece = vc().piece;
if (!piece) return;
piece.owt = weight(piece);
}
// ── reset_eat ──
function reset_eat() {
const v = vc();
if (v.eating && !v.doreset) {
v.doreset = 1;
}
}
// ── touchfood ──
async function touchfood(otmp) {
if (otmp.quan > 1) {
otmp = splitobj(otmp, 1);
}
if (!otmp.oeaten) {
costly_alteration(otmp, COST_BITE);
otmp.oeaten = obj_nutrition(otmp);
}
if (carried(otmp)) {
freeinv(otmp);
if (inv_cnt(false) >= 52) { // invlet_basic
sellobj_state(1); // SELL_DONTSELL
await dropy(otmp);
sellobj_state(0);
if (otmp.where === 5) otmp = null; // OBJ_DELETED
} else {
otmp = addinv_nomerge(otmp);
}
}
return otmp;
}
// ── food_disappears ──
function food_disappears(obj) {
const v = vc();
if (obj === v.piece) {
Object.assign(v, zero_victual);
}
}
// ── food_substitution ──
function food_substitution(old_obj, new_obj) {
const v = vc();
if (old_obj === v.piece) {
v.piece = new_obj;
v.o_id = new_obj.o_id;
}
const t = tc();
if (old_obj === t.tin) {
t.tin = new_obj;
t.o_id = new_obj.o_id;
}
}
// ── do_reset_eat ──
async function do_reset_eat() {
const v = vc();
if (v.piece) {
v.o_id = 0;
let otmp = await touchfood(v.piece);
v.piece = otmp;
if (otmp) {
v.o_id = otmp.o_id;
recalc_wt();
}
}
v.fullwarn = v.eating = v.doreset = 0;
await stop_occupation();
await newuhs(false);
}
// ── eating_conducts ──
async function eating_conducts(pd) {
if (!game.u.uconduct) game.u.uconduct = {};
let ll_conduct = 0;
if (!game.u.uconduct.food++) {
livelog_printf(LL_CONDUCT, 'ate for the first time - ' + (pd.pmnames?.[0] || 'something'));
ll_conduct++;
}
if (!vegan(pd)) {
if (!game.u.uconduct.unvegan++ && !ll_conduct) {
livelog_printf(LL_CONDUCT, 'consumed animal products (' + (pd.pmnames?.[0] || 'something') + ') for the first time');
ll_conduct++;
}
}
if (!vegetarian(pd)) {
if (!game.u.uconduct.unvegetarian && !ll_conduct)
livelog_printf(LL_CONDUCT, 'tasted meat (' + (pd.pmnames?.[0] || 'something') + ') for the first time');
await violated_vegetarian();
}
}
// ── violated_vegetarian ──
async function violated_vegetarian() {
if (!game.u.uconduct) game.u.uconduct = {};
game.u.uconduct.unvegetarian = (game.u.uconduct.unvegetarian || 0) + 1;
if (Role_if(PM_MONK)) {
await You_feel('guilty.');
adjalign(-1);
}
}
// ── maybe_cannibal ──
async function maybe_cannibal(pm, allowmsg) {
const fptr = mons[pm];
if (game.moves === game.ate_brains_turn) return false;
game.ate_brains_turn = game.moves;
if (!CANNIBAL_ALLOWED()
&& (your_race(fptr)
|| (Upolyd() && same_race(game.player?.data, fptr))
|| (ismnum(game.u?.ulycn) && were_beastie(pm) === game.u.ulycn))) {
if (allowmsg) {
if (Upolyd() && your_race(fptr))
await You('have a bad feeling deep inside.');
await You('cannibal! You will regret this!');
}
// HAggravate_monster |= FROMOUTSIDE
if (!game.u.uprops) game.u.uprops = {};
if (!game.u.uprops[AGGRAVATE_MONSTER])
game.u.uprops[AGGRAVATE_MONSTER] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
game.u.uprops[AGGRAVATE_MONSTER].intrinsic |= FROMOUTSIDE;
change_luck(-rn1(4, 2)); // -5..-2
return true;
}
return false;
}
// ── eat_brains ──
// C ref: eat.c:601 — mind flayer tentacle attack side-effects
export async function eat_brains(magr, mdef, visflag, dmg_p) {
const pd = mdef.data;
let give_nutrit = false;
let result = M_ATTK_HIT;
const xtra_dmg = rnd(10);
// previous tentacle attack might have triggered fatal passive counterattack
if (magr !== game.youmonst && DEADMONSTER(magr))
return M_ATTK_AGR_DIED;
if (noncorporeal(pd)) {
if (visflag)
await pline('%s brain is unharmed.',
(mdef === game.youmonst) ? 'Your' : s_suffix(Monnam(mdef)));
return M_ATTK_MISS;
} else if (magr === game.youmonst) {
await You('eat %s brain!', s_suffix(mon_nam(mdef)));
} else if (mdef === game.youmonst) {
await Your('brain is eaten!');
} else {
if (visflag && canspotmon(mdef))
await pline('%s brain is eaten!', s_suffix(Monnam(mdef)));
}
if (flesh_petrifies(pd)) {
if (magr === game.youmonst) {
if (!Stone_resistance() && !Stoned())
await make_stoned(5, null, KILLED_BY_AN,
pmname(pd, Mgender(mdef)));
} else {
if (visflag && canseemon(magr))
await pline('%s turns to stone!', Monnam(magr));
// monstone(magr); // TODO: port monstone
if (!DEADMONSTER(magr)) {
return M_ATTK_MISS;
} else {
if (magr.mtame && !visflag)
await You('have a sad thought for a moment, then it passes.');
return M_ATTK_AGR_DIED;
}
}
}
if (magr === game.youmonst) {
// player mind flayer eating monster's brain
await eating_conducts(pd);
if (mindless(pd)) {
await pline("%s doesn't notice.", Monnam(mdef));
return M_ATTK_MISS;
} else if (is_rider(pd)) {
await pline('Ingesting that is fatal.');
game.killer = { format: NO_KILLER_PREFIX,
name: `unwisely ate the brain of ${pmname(pd, Mgender(mdef))}` };
await done(DIED);
exercise(A_WIS, false);
if (dmg_p) dmg_p.value += xtra_dmg;
} else {
await morehungry(-rnd(30));
if (ABASE(A_INT) < AMAX(A_INT)) {
let newint = ABASE(A_INT) + rnd(4);
if (newint > AMAX(A_INT)) newint = AMAX(A_INT);
game.u.acurr.a[A_INT] = newint;
setBotl('eat_brains');
}
exercise(A_WIS, true);
if (dmg_p) dmg_p.value += xtra_dmg;
}
await maybe_cannibal(monsndx(pd), true);
} else if (mdef === game.youmonst) {
// monster eating hero's brain
if (ABASE(A_INT) <= ATTRMIN(A_INT)) {
if (Lifesaved()) {
game.killer = { format: KILLED_BY, name: 'brainlessness' };
await done(DIED);
await pline('Unfortunately your brain is still gone.');
} else {
await Your('last thought fades away.');
}
game.killer = { format: KILLED_BY, name: 'brainlessness' };
await done(DIED);
game.u.acurr.a[A_INT] = ATTRMIN(A_INT) + 2;
await You_feel('like a scarecrow.');
}
give_nutrit = true;
exercise(A_WIS, false);
} else {
// monster vs monster brain eating
if (mindless(pd)) {
if (visflag && canspotmon(mdef))
await pline("%s doesn't notice.", Monnam(mdef));
return M_ATTK_MISS;
} else if (is_rider(pd)) {
await mondied(magr);
if (DEADMONSTER(magr))
result = M_ATTK_AGR_DIED;
if (dmg_p) dmg_p.value += xtra_dmg;
} else {
if (dmg_p) dmg_p.value += xtra_dmg;
give_nutrit = true;
if (dmg_p && dmg_p.value >= mdef.mhp && visflag && canspotmon(mdef))
await pline('%s last thought fades away...', s_suffix(Monnam(mdef)));
}
}
if (give_nutrit && magr.mtame && !magr.isminion) {
EDOG(magr).hungrytime += rnd(60);
magr.mconf = 0;
}
return result;
}
// ── intrinsic_possible ──
function intrinsic_possible(type, ptr) {
switch (type) {
case FIRE_RES: return (ptr.mconveys & MR_FIRE) !== 0;
case SLEEP_RES: return (ptr.mconveys & MR_SLEEP) !== 0;
case COLD_RES: return (ptr.mconveys & MR_COLD) !== 0;
case DISINT_RES: return (ptr.mconveys & MR_DISINT) !== 0;
case SHOCK_RES: return (ptr.mconveys & MR_ELEC) !== 0;
case POISON_RES: return (ptr.mconveys & MR_POISON) !== 0;
case ACID_RES: return (ptr.mconveys & MR_ACID) !== 0;
case STONE_RES: return (ptr.mconveys & MR_STONE) !== 0;
case TELEPORT: return can_teleport(ptr);
case TELEPORT_CONTROL: return control_teleport(ptr);
case TELEPAT: return telepathic(ptr);
default: return false;
}
}
// ── should_givit ──
function should_givit(type, ptr) {
let chance;
switch (type) {
case POISON_RES:
if ((ptr === mons[PM_KILLER_BEE] || ptr === mons[PM_SCORPION]) && !rn2(4))
chance = 1;
else
chance = 15;
break;
case TELEPORT: chance = 10; break;
case TELEPORT_CONTROL: chance = 12; break;
case TELEPAT: chance = 1; break;
default: chance = 15; break;
}
return ptr.mlevel > rn2(chance);
}
// ── temp_givit ──
function temp_givit(type, ptr) {
const chance = (type === STONE_RES) ? 6 : (type === ACID_RES) ? 3 : 0;
return chance ? (ptr.mlevel > rn2(chance)) : false;
}
// ── givit ── (async because of You_feel messages)
async function givit(type, ptr) {
if (!should_givit(type, ptr) && !temp_givit(type, ptr))
return;
const u = game.u;
if (!u.uprops) u.uprops = {};
switch (type) {
case FIRE_RES:
if (!(((u.uprops[FIRE_RES]?.intrinsic || 0) & FROMOUTSIDE))) {
await You(Hallucination() ? "be chillin'." : 'feel a momentary chill.');
if (!u.uprops[FIRE_RES]) u.uprops[FIRE_RES] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[FIRE_RES].intrinsic |= FROMOUTSIDE;
}
break;
case SLEEP_RES:
if (!(((u.uprops[SLEEP_RES]?.intrinsic || 0) & FROMOUTSIDE))) {
await You_feel('wide awake.');
if (!u.uprops[SLEEP_RES]) u.uprops[SLEEP_RES] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[SLEEP_RES].intrinsic |= FROMOUTSIDE;
}
break;
case COLD_RES:
if (!(((u.uprops[COLD_RES]?.intrinsic || 0) & FROMOUTSIDE))) {
await You_feel('full of hot air.');
if (!u.uprops[COLD_RES]) u.uprops[COLD_RES] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[COLD_RES].intrinsic |= FROMOUTSIDE;
}
break;
case DISINT_RES:
if (!(((u.uprops[DISINT_RES]?.intrinsic || 0) & FROMOUTSIDE))) {
await You_feel(Hallucination() ? 'totally together, man.' : 'very firm.');
if (!u.uprops[DISINT_RES]) u.uprops[DISINT_RES] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[DISINT_RES].intrinsic |= FROMOUTSIDE;
}
break;
case SHOCK_RES:
if (!(((u.uprops[SHOCK_RES]?.intrinsic || 0) & FROMOUTSIDE))) {
if (Hallucination())
await You_feel('grounded in reality.');
else
await Your('health currently feels amplified!');
if (!u.uprops[SHOCK_RES]) u.uprops[SHOCK_RES] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[SHOCK_RES].intrinsic |= FROMOUTSIDE;
}
break;
case POISON_RES:
if (!(((u.uprops[POISON_RES]?.intrinsic || 0) & FROMOUTSIDE))) {
await You_feel(Poison_resistance() ? 'especially healthy.' : 'healthy.');
if (!u.uprops[POISON_RES]) u.uprops[POISON_RES] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[POISON_RES].intrinsic |= FROMOUTSIDE;
}
break;
case TELEPORT:
if (!(((u.uprops[TELEPORT]?.intrinsic || 0) & FROMOUTSIDE))) {
await You_feel(Hallucination() ? 'diffuse.' : 'very jumpy.');
if (!u.uprops[TELEPORT]) u.uprops[TELEPORT] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[TELEPORT].intrinsic |= FROMOUTSIDE;
}
break;
case TELEPORT_CONTROL:
if (!(((u.uprops[TELEPORT_CONTROL]?.intrinsic || 0) & FROMOUTSIDE))) {
await You_feel(Hallucination() ? 'centered in your personal space.'
: 'in control of yourself.');
if (!u.uprops[TELEPORT_CONTROL]) u.uprops[TELEPORT_CONTROL] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[TELEPORT_CONTROL].intrinsic |= FROMOUTSIDE;
}
break;
case TELEPAT:
if (!(((u.uprops[TELEPAT]?.intrinsic || 0) & FROMOUTSIDE))) {
await You_feel(Hallucination() ? 'in touch with the cosmos.'
: 'a strange mental acuity.');
if (!u.uprops[TELEPAT]) u.uprops[TELEPAT] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[TELEPAT].intrinsic |= FROMOUTSIDE;
if (Blind()) see_monsters();
}
break;
case ACID_RES:
if (!Acid_resistance())
await You_feel(Hallucination() ? 'secure from flashbacks.'
: 'less concerned about being harmed by acid.');
incr_itimeout(ACID_RES, c_d(3, 6));
break;
case STONE_RES:
if (!Stone_resistance())
await You_feel(Hallucination() ? 'unusually limber.'
: 'less concerned about becoming petrified.');
incr_itimeout(STONE_RES, c_d(3, 6));
break;
default:
break;
}
}
// ── eye_of_newt_buzz ──
async function eye_of_newt_buzz() {
const u = game.u;
if (rn2(3) || 3 * u.uen <= 2 * u.uenmax) {
const old_uen = u.uen;
u.uen += rnd(3);
if (u.uen > u.uenmax) {
if (!rn2(3)) {
u.uenmax++;
if (u.uenmax > (u.uenpeak || 0))
u.uenpeak = u.uenmax;
}
u.uen = u.uenmax;
}
if (old_uen !== u.uen) {
await You_feel('a mild buzz.');
setBotl('eye_of_newt_buzz');
}
}
}
// ── corpse_intrinsic ──
function corpse_intrinsic(ptr) {
const conveys_STR = is_giant(ptr);
let count = 0;
let prop = 0;
if (conveys_STR) {
count = 1;
prop = -1;
}
for (let i = 1; i <= LAST_PROP; i++) {
if (!intrinsic_possible(i, ptr)) continue;
++count;
if (!rn2(count)) {
prop = i;
}
}
// if strength is the only candidate, give it 50% chance
if (conveys_STR && count === 1 && !rn2(2))
prop = 0;
return prop;
}
// ── cprefx ── (async for pline messages)
async function cprefx(pm) {
await maybe_cannibal(pm, true);
if (flesh_petrifies(mons[pm])) {
if (!Stone_resistance()
&& !(poly_when_stoned(game.player?.data) && await polymon(PM_STONE_GOLEM))) {
const t = tc();
if (t.tin) use_up_tin(t.tin);
await You('turn to stone.');
await done(STONING);
const v = vc();
if (v.piece) v.eating = 0;
return;
}
}
switch (pm) {
case PM_LITTLE_DOG: case PM_DOG: case PM_LARGE_DOG:
case PM_KITTEN: case PM_HOUSECAT: case PM_LARGE_CAT:
if (!CANNIBAL_ALLOWED()) {
await You_feel('that eating the ' + (mons[pm].pmnames?.[0] || 'pet') + ' was a bad idea.');
if (!game.u.uprops) game.u.uprops = {};
if (!game.u.uprops[AGGRAVATE_MONSTER])
game.u.uprops[AGGRAVATE_MONSTER] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
game.u.uprops[AGGRAVATE_MONSTER].intrinsic |= FROMOUTSIDE;
}
break;
case PM_LIZARD:
if (Stoned()) await fix_petrification();
break;
case PM_DEATH: case PM_PESTILENCE: case PM_FAMINE:
await pline('Eating that is instantly fatal.');
await done(DIED);
exercise(A_WIS, false);
{
const v = vc();
if (v.piece && v.piece.otyp === CORPSE && await revive_corpse(v.piece))
Object.assign(v, zero_victual);
}
return;
case PM_GREEN_SLIME:
if (!Slimed() && !Unchanging() && !slimeproof(game.player?.data)) {
await You("don't feel very well.");
await make_slimed(10, null);
delayed_killer(SLIMED, KILLED_BY_AN, '');
}
// FALLTHROUGH
if (acidic(mons[pm]) && Stoned()) await fix_petrification();
break;
default:
if (acidic(mons[pm]) && Stoned()) await fix_petrification();
break;
}
}
// ── cpostfx ── (async for messages)
async function cpostfx(pm) {
let tmp = 0;
let catch_lycanthropy = NON_PM;
let check_intrinsics = false;
// C: clean up eatmbuf if needed
if (game.eatmbuf)
eatmdone();
switch (pm) {
case PM_WRAITH:
await pluslvl(false);
break;
case PM_HUMAN_WERERAT:
catch_lycanthropy = PM_WERERAT;
break;
case PM_HUMAN_WEREJACKAL:
catch_lycanthropy = PM_WEREJACKAL;
break;
case PM_HUMAN_WEREWOLF:
catch_lycanthropy = PM_WEREWOLF;
break;
case PM_NURSE:
if (Upolyd())
game.u.mh = game.u.mhmax;
else
game.u.uhp = game.u.uhpmax;
await make_blinded(0, !game.u.ucreamed);
setBotl('cpostfx');
check_intrinsics = true;
break;
case PM_STALKER:
if (!Invis()) {
set_itimeout({ ref: game.u.uprops, key: INVIS }, rn1(100, 50));
if (!Blind()) await self_invis_message();
} else {
if (!((game.u.uprops?.[INVIS]?.intrinsic || 0) & INTRINSIC))
await You_feel('hidden!');
if (!game.u.uprops) game.u.uprops = {};
if (!game.u.uprops[INVIS]) game.u.uprops[INVIS] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
game.u.uprops[INVIS].intrinsic |= FROMOUTSIDE;
if (!game.u.uprops[SEE_INVIS]) game.u.uprops[SEE_INVIS] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
game.u.uprops[SEE_INVIS].intrinsic |= FROMOUTSIDE;
}
newsym(game.u.ux, game.u.uy);
// FALLTHROUGH to YELLOW_LIGHT/GIANT_BAT
case PM_YELLOW_LIGHT:
case PM_GIANT_BAT:
await make_stunned(((game.u.uprops?.[STUNNED]?.intrinsic || 0) & TIMEOUT) + 30, false);
// FALLTHROUGH to BAT
case PM_BAT:
await make_stunned(((game.u.uprops?.[STUNNED]?.intrinsic || 0) & TIMEOUT) + 30, false);
break;
case PM_GIANT_MIMIC:
tmp += 10;
// FALLTHROUGH
case PM_LARGE_MIMIC:
tmp += 20;
// FALLTHROUGH
case PM_SMALL_MIMIC:
tmp += 20;
if (game.youmonst?.data?.mlet !== S_MIMIC && !Unchanging()) {
const tempshape = !Hallucination() ? 'a pile of gold' : 'an orange';
await You_cant('resist the temptation to mimic ' + tempshape + '.');
if (game.u.usteed) await dismount_steed(1); // DISMOUNT_FELL
nomul(-tmp);
game.youmonst.m_ap_type = M_AP_OBJECT;
game.youmonst.mappearance = Hallucination() ? ORANGE : GOLD_PIECE;
newsym(game.u.ux, game.u.uy);
await curs_on_u();
await display_nhwindow(1, true); // WIN_MAP
}
break;
case PM_QUANTUM_MECHANIC:
await Your('velocity suddenly seems very uncertain!');
{
const u = game.u;
const hfast = u.uprops?.[FAST]?.intrinsic || 0;
if (hfast & INTRINSIC) {
if (u.uprops[FAST]) u.uprops[FAST].intrinsic &= ~INTRINSIC;
await You('seem slower.');
} else {
if (!u.uprops) u.uprops = {};
if (!u.uprops[FAST]) u.uprops[FAST] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[FAST].intrinsic |= FROMOUTSIDE;
await You('seem faster.');
}
}
break;
case PM_LIZARD:
if (((game.u.uprops?.[STUNNED]?.intrinsic || 0) & TIMEOUT) > 2)
await make_stunned(2, false);
if (((game.u.uprops?.[CONFUSION]?.intrinsic || 0) & TIMEOUT) > 2)
await make_confused(2, false);
check_intrinsics = true;
break;
case PM_CHAMELEON:
case PM_DOPPELGANGER:
case PM_SANDESTIN:
case PM_GENETIC_ENGINEER:
if (Unchanging()) {
await You_feel('momentarily different.');
} else {
// polyself() is potentially fatal; if food is a tin, use it up
if (tc().tin) {
use_up_tin(tc().tin);
await lesshungry(200 + (metallivorous(game.youmonst?.data) ? 5 : 0));
}
await You((pm === PM_GENETIC_ENGINEER)
? 'undergo a freakish metamorphosis.'
: 'feel a change coming over you.');
await polyself(0);
}
break;
case PM_DISPLACER_BEAST:
if (!Displaced()) await toggle_displacement(null, 0, true);
incr_itimeout(DISPLACED, c_d(6, 6));
break;
case PM_DISENCHANTER:
await attrcurse();
break;
case PM_DEATH: case PM_PESTILENCE: case PM_FAMINE:
// life-saved; no intrinsics
break;
case PM_MIND_FLAYER:
case PM_MASTER_MIND_FLAYER:
if (ABASE(A_INT) < ATTRMAX(A_INT)) {
if (!rn2(2)) {
await pline('Yum! That was real brain food!');
await adjattrib(A_INT, 1, false);
break;
}
} else {
await pline('For some reason, that tasted bland.');
}
// FALLTHROUGH
default:
check_intrinsics = true;
break;
}
// possibly convey an intrinsic
if (check_intrinsics) {
const ptr = mons[pm];
if (dmgtype(ptr, AD_STUN) || dmgtype(ptr, AD_HALU)
|| pm === PM_VIOLET_FUNGUS) {
await pline('Oh wow! Great stuff!');
await make_hallucinated(((game.u.uprops?.[HALLUC]?.intrinsic || 0) & TIMEOUT) + 200, false, 0);
}
if (attacktype(ptr, AT_MAGC) || pm === PM_NEWT)
await eye_of_newt_buzz();
tmp = corpse_intrinsic(ptr);
if (tmp === -1)
await gainstr(null, 0, true);
else if (tmp > 0)
await givit(tmp, ptr);
}
if (ismnum(catch_lycanthropy)) {
set_ulycn(catch_lycanthropy);
await retouch_equipment(2);
}
}
// ── choke ──
async function choke(food) {
if (game.u.uhs !== SATIATED) {
if (!food || food.otyp !== AMULET_OF_STRANGULATION)
return;
} else if (Role_if(PM_KNIGHT) && game.u.ualign?.type === A_LAWFUL) {
adjalign(-1);
await You_feel('like a glutton!');
}
exercise(A_CON, false);
if (Breathless() || Hunger() || (!Strangled() && !rn2(20))) {
if (food && food.otyp === AMULET_OF_STRANGULATION) {
await You('choke, but recover your composure.');
return;
}
await You('stuff yourself and then vomit voluminously.');
await morehungry(Hunger() ? (game.u.uhunger - 60) : 1000);
await vomit_fn();
} else {
if (food) {
await You('choke over your ' + foodword(food) + '.');
} else {
await You('choke over it.');
}
await You('die...');
await done(CHOKING);
}
}
// ── eatfood ── (occupation callback)
async function eatfood() {
const v = vc();
let food = v.piece;
if (food && !carried(food) && !obj_here(food, game.u.ux, game.u.uy))
food = null;
if (!food) {
await do_reset_eat();
return 0;
}
if (!v.eating) return 0;
if (++v.usedtime <= v.reqtime) {
if (await bite()) return 0;
return 1; // still busy
} else {
await done_eating(true);
return 0;
}
}
// ── done_eating ──
async function done_eating(message) {
const v = vc();
const piece = v.piece;
if (!piece) return;
piece.in_use = true;
// C ref: eat.c:549 — clear occupation directly (NOT stop_occupation)
// "do this early, so newuhs() knows we're done"
game.occupation = null;
await newuhs(false);
if (game.nomovemsg) {
if (message) await pline(game.nomovemsg);
game.nomovemsg = null;
} else if (message) {
const verb = (game.youmonst?.data === mons[PM_FIRE_ELEMENTAL])
? 'consuming' : 'eating';
await You('finish ' + verb + ' ' + food_xname(piece, true) + '.');
}
if (piece.otyp === CORPSE || piece.globby)
await cpostfx(piece.corpsenm);
else
await fpostfx(piece);
if (carried(piece))
useup(piece);
else
useupf(piece, 1);
Object.assign(v, zero_victual);
}
// ── tin_variety ──
function tin_variety(obj, displ) {
let r;
const mnum = obj.corpsenm;
if (obj.spe === 1) {
r = SPINACH_TIN;
} else if (obj.cursed) {
r = ROTTEN_TIN;
} else if (obj.spe < 0) {
r = -(obj.spe);
--r;
} else {
r = rn2(TTSZ - 1);
}
if (!displ && r === HOMEMADE_TIN && !obj.blessed && !rn2(7))
r = ROTTEN_TIN;
if (r === ROTTEN_TIN && (ismnum(mnum) && nonrotting_corpse(mnum)))
r = HOMEMADE_TIN;
return r;
}
// ── set_tin_variety ──
function set_tin_variety(obj, forcetype) {
let r;
const mnum = obj.corpsenm;
if (forcetype === SPINACH_TIN
|| (forcetype === HEALTHY_TIN
&& (mnum === NON_PM || !vegetarian(mons[mnum])))) {
obj.corpsenm = NON_PM;
obj.spe = 1;
return;
} else if (forcetype === HEALTHY_TIN) {
r = tin_variety(obj, false);
if (r < 0 || r >= TTSZ) r = ROTTEN_TIN;
while ((r === ROTTEN_TIN && !obj.cursed) || !tintxts[r].fodder)
r = rn2(TTSZ - 1);
} else if (forcetype >= 0 && forcetype < TTSZ - 1) {
r = forcetype;
} else {
r = rn2(TTSZ - 1);
if (r === ROTTEN_TIN && (ismnum(mnum) && nonrotting_corpse(mnum)))
r = HOMEMADE_TIN;
}
obj.spe = -(r + 1);
}
// ── use_up_tin ──
function use_up_tin(tin) {
if (carried(tin))
useup(tin);
else
useupf(tin, 1);
const t = tc();
t.tin = null;
t.o_id = 0;
}
// ── costly_tin ──
function costly_tin(alter_type) {
const t = tc();
let tin = t.tin;
if (!tin) return tin;
if (carried(tin) ? tin.unpaid
: (costly_spot(tin.ox, tin.oy) && !tin.no_charge)) {
if (tin.quan > 1) {
tin = t.tin = splitobj(tin, 1);
t.o_id = tin.o_id;
}
costly_alteration(tin, alter_type);
}
return tin;
}
// ── consume_tin ──
async function consume_tin(mesg) {
const t = tc();
let tin = t.tin;
if (!tin) return;
const always_eat = metallivorous(game.youmonst?.data);
const r = tin_variety(tin, false);
if (tin.otrapped || (tin.cursed && r !== HOMEMADE_TIN && !rn2(8))) {
await b_trapped('tin', -1);
tin = costly_tin(COST_DSTROY);
use_up_tin(tin);
return;
}
await pline(mesg);
if (r !== SPINACH_TIN) {
const mnum = tin.corpsenm;
if (mnum === NON_PM) {
if (Hallucination())
await pline("It's full of " +
(rn2(2) ? 'air elemental souffle' : 'dehydrated water') + '.');
else
await pline('It turns out to be empty.');
observe_object(tin);
tin.known = 1;
tin = costly_tin(COST_OPEN);
use_up_tin(tin);
if (always_eat) await lesshungry(5);
return;
}
let which = 0; // 0=plural, 1=as-is, 2="the" prefix
let what;
if ((mnum === PM_COCKATRICE || mnum === PM_CHICKATRICE)
&& (Stone_resistance() || Hallucination())) {
what = 'chicken';
which = 1;
} else if (Hallucination()) {
what = rndmonnam(null);
} else {
what = mons[mnum]?.pmnames?.[0] || 'monster';
if (the_unique_pm(mons[mnum]))
which = 2;
else if (type_is_pname(mons[mnum]))
which = 1;
}
if (which === 0) what = makeplural(what);
else if (which === 2) what = 'the ' + what;
if (!always_eat) {
await pline('It smells like ' + what + '.');
const answer = await ynFunction('Eat it?', 'yn', 'n'.charCodeAt(0));
if (answer === 'n'.charCodeAt(0)) {
if (game.flags?.verbose)
await You('discard the open tin.');
if (!Hallucination()) {
observe_object(tin);
tin.known = 1;
}
tin = costly_tin(COST_OPEN);
use_up_tin(tin);
return;
}
}
Object.assign(vc(), zero_victual);
await You('consume ' + tintxts[r].txt + ' ' + (mons[mnum]?.pmnames?.[0] || 'monster') + '.');
await eating_conducts(mons[mnum]);
observe_object(tin);
tin.known = 1;
tin = t.tin = costly_tin(COST_OPEN);
await cprefx(mnum);
if (t.tin) await cpostfx(mnum);
if (!t.tin) return;
if (tintxts[r].nut < 0) {
await make_vomiting(rn1(15, 10), false);
} else {
let nutamt = tintxts[r].nut;
if (r === HOMEMADE_TIN && nutamt > (mons[mnum]?.cnutrit || 0))
nutamt = mons[mnum].cnutrit || 0;
if (always_eat) nutamt += 5;
use_up_tin(tin);
tin = null;
await lesshungry(nutamt);
}
if (tin && tintxts[r].greasy) {
const alreadyglib = (Glib() ? ((game.u.uprops?.[GLIB]?.intrinsic || 0) & TIMEOUT) : 0);
make_glib(alreadyglib + rn1(11, 5));
await pline('Eating ' + tintxts[r].txt + ' food made your ' +
fingers_or_gloves(true) + ' ' +
(alreadyglib ? 'even more' : 'very') + ' slippery.');
}
} else {
// spinach
if (tin.cursed) {
await pline('It contains some decaying' +
(Blind() ? '' : ' ') + (Blind() ? '' : hcolor('green')) + ' substance.');
} else {
await pline('It contains spinach.');
observe_object(tin);
tin.known = 1;
}
if (!always_eat) {
const answer = await ynFunction('Eat it?', 'yn', 'n'.charCodeAt(0));
if (answer === 'n'.charCodeAt(0)) {
if (game.flags?.verbose) await You('discard the open tin.');
tin = costly_tin(COST_OPEN);
use_up_tin(tin);
return;
}
}
if (!game.u.uconduct) game.u.uconduct = {};
if (!game.u.uconduct.food++) {
livelog_printf(LL_CONDUCT, 'ate for the first time (spinach)');
}
if (!tin.cursed) {
await pline('This makes you feel like ' +
(Hallucination() ? "Swee'pea"
: !Fixed_abil() ? 'Popeye'
: (game.flags?.female ? 'Olive Oyl' : 'Bluto')) + '!');
}
await gainstr(tin, 0, false);
tin = t.tin = costly_tin(COST_OPEN);
let nutamt = tin.blessed ? 600
: !tin.cursed ? (400 + rnd(200))
: (200 + rnd(400));
if (always_eat) nutamt += 5;
use_up_tin(tin);
tin = null;
await lesshungry(nutamt);
}
if (tin) use_up_tin(tin);
}
// ── opentin ── (occupation callback)
async function opentin() {
const t = tc();
if (!t.tin) return 0;
if (!carried(t.tin) && (!obj_here(t.tin, game.u.ux, game.u.uy) || !can_reach_floor(true)))
return 0;
if (t.usedtime++ >= 50) {
await You('give up your attempt to open the tin.');
return 0;
}
if (t.usedtime < t.reqtime)
return 1;
await consume_tin('You succeed in opening the tin.');
return 0;
}
// ── start_tin ──
async function start_tin(otmp) {
let mesg = null;
let tmp;
if (metallivorous(game.player?.data)) {
mesg = 'You bite right into the metal tin...';
tmp = 0;
} else if (otmp.blessed) {
tmp = rn2(2);
if (!tmp)
mesg = 'The tin opens like magic!';
else
await pline_The('tin seems easy to open.');
} else if (game.u.uwep) {
const uwep = game.u.uwep;
switch (uwep.otyp) {
case TIN_OPENER:
mesg = 'You easily open the tin.';
tmp = rn2(uwep.cursed ? 3 : !uwep.blessed ? 2 : 1);
break;
case DAGGER: case SILVER_DAGGER: case ELVEN_DAGGER:
case ORCISH_DAGGER: case ATHAME: case KNIFE: case STILETTO: case CRYSKNIFE:
tmp = 3;
break;
case PICK_AXE: case AXE:
tmp = 6;
break;
default:
// C ref: eat.c:1784 — uses ACURRSTR (condensed 3-25), not raw ACURR(A_STR)
tmp = rn1(1 + Math.trunc(500 / (ACURR(A_DEX) + ACURRSTR())), 10);
await pline('It is not so easy to open this tin.');
break;
}
if (tmp !== undefined && uwep.otyp !== TIN_OPENER &&
uwep.otyp !== DAGGER && uwep.otyp !== SILVER_DAGGER &&
uwep.otyp !== ELVEN_DAGGER && uwep.otyp !== ORCISH_DAGGER &&
uwep.otyp !== ATHAME && uwep.otyp !== KNIFE &&
uwep.otyp !== STILETTO && uwep.otyp !== CRYSKNIFE &&
uwep.otyp !== PICK_AXE && uwep.otyp !== AXE) {
// already handled in default case
} else if (mesg !== 'You easily open the tin.') {
// pline using uwep
}
} else {
await pline('It is not so easy to open this tin.');
if (Glib()) {
await pline_The('tin slips from your ' + fingers_or_gloves(false) + '.');
return;
}
// C ref: eat.c:1784 — uses ACURRSTR (condensed), not raw ACURR(A_STR)
tmp = rn1(1 + Math.trunc(500 / (ACURR(A_DEX) + ACURRSTR())), 10);
}
const t = tc();
t.tin = otmp;
t.o_id = otmp.o_id || 0;
if (!tmp) {
await consume_tin(mesg);
} else {
t.reqtime = tmp;
t.usedtime = 0;
set_occupation(opentin, 'opening the tin', 0);
}
}
// ── rottenfood ──
async function rottenfood(obj) {
await pline('Blecch! ' +
(is_rottable(obj) ? 'Rotten' : 'Awful') + ' ' + foodword(obj) + '!');
if (!rn2(4)) {
if (Hallucination())
await You_feel('rather trippy.');
else
await You_feel('rather light-headed.');
// C: HConfusion + d(2,4)
await make_confused(((game.u.uprops?.[CONFUSION]?.intrinsic || 0) & TIMEOUT) + c_d(2, 4), false);
} else if (!rn2(4) && !Blind()) {
await pline('Everything suddenly goes dark.');
// C: Blinded timer + d(2,10)
const blindedTimeout = (game.u.uprops?.[BLINDED]?.intrinsic || 0) & TIMEOUT;
await make_blinded(blindedTimeout + c_d(2, 10), false);
if (!Blind()) await Your('vision clears.');
} else if (!rn2(3)) {
const duration = rnd(10);
// C ref: eat.c:1833-1844
if (!Blind())
await pline_The('world spins and goes dark.');
else if (Levitation() || Is_airlevel() || Is_waterlevel())
await pline_The('world spins and you lose control of yourself.');
else
await pline_The(`world spins and you slap against the ${game.u?.usteed ? 'saddle' : surface(game.u.ux, game.u.uy)}.`);
incr_itimeout(DEAF, duration);
setBotl('rottenfood');
nomul(-duration);
game.multi_reason = 'unconscious from rotten food';
game.nomovemsg = 'You are conscious again.';
game.afternmv = Hear_again;
return 1;
}
return 0;
}
// ── eatcorpse ──
async function eatcorpse(otmp) {
let retcode = 0, tp = 0;
const mnum = otmp.corpsenm;
let rotted = 0;
const slimeable = (mnum === PM_GREEN_SLIME && !Slimed() && !Unchanging()
&& !slimeproof(game.player?.data));
const glob = !!otmp.globby;
const stoneable = (flesh_petrifies(mons[mnum]) && !Stone_resistance()
&& !poly_when_stoned(game.player?.data));
// conduct tracking
if (!game.u.uconduct) game.u.uconduct = {};
let ll_conduct = 0;
if (!vegan(mons[mnum])) {
if (!game.u.uconduct.unvegan++) {
livelog_printf(LL_CONDUCT, 'consumed animal products for the first time, by eating ' + an(food_xname(otmp, false)));
ll_conduct++;
}
}
if (!vegetarian(mons[mnum])) {
if (!game.u.uconduct.unvegetarian && !ll_conduct)
livelog_printf(LL_CONDUCT, 'tasted meat for the first time, by eating ' + an(food_xname(otmp, false)));
await violated_vegetarian();
}
if (!nonrotting_corpse(mnum)) {
const age = peek_at_iced_corpse_age(otmp);
rotted = Math.trunc((game.moves - age) / (10 + rn2(20)));
if (otmp.cursed) rotted += 2;
else if (otmp.blessed) rotted -= 2;
}
// tainted
if (!glob && !stoneable && !slimeable && rotted > 5) {
const cannibal = await maybe_cannibal(mnum, false);
await pline('Ulch - that ' +
((mons[mnum]?.mlet === S_FUNGUS) ? 'fungoid vegetation'
: vegetarian(mons[mnum]) ? 'protoplasm' : 'meat') +
' was tainted' + (cannibal ? ', you cannibal' : '') + '!');
if (Sick_resistance()) {
await pline("It doesn't seem at all sickening, though...");
} else {
let sick_time = rn1(10, 10);
// C: make sure new ill doesn't result in improvement
// C: if (Sick && (sick_time > Sick)) - Sick is the timeout value
const curSickTimeout = (game.u.uprops?.[SICK]?.intrinsic || 0) & TIMEOUT;
if (curSickTimeout && sick_time > curSickTimeout) {
sick_time = curSickTimeout > 1 ? curSickTimeout - 1 : 1;
}
await make_sick(sick_time, corpse_xname(otmp, 'rotted', 0), true, SICK_VOMITABLE);
await pline('(It must have died too long ago to be safe to eat.)');
}
if (carried(otmp)) useup(otmp);
else useupf(otmp, 1);
return 2;
} else if (acidic(mons[mnum]) && !Acid_resistance()) {
tp++;
await You('have a very bad case of stomach acid.');
await losehp(rnd(15), !glob ? 'acidic corpse' : 'acidic glob', KILLED_BY_AN);
} else if (poisonous(mons[mnum]) && rn2(5)) {
tp++;
await pline('Ecch - that must have been poisonous!');
if (!Poison_resistance()) {
// C: poison_strdmg(rnd(4), rnd(15), ...) - str loss + hp damage
const str_dmg = rnd(4);
const hp_dmg = rnd(15);
// losestr(str_dmg) equivalent - decrease str temporarily
await losehp(hp_dmg, !glob ? 'poisonous corpse' : 'poisonous glob', KILLED_BY_AN);
} else {
await You('seem unaffected by the poison.');
}
} else if ((rotted > 5 || (rotted > 3 && rn2(5))) && !Sick_resistance()) {
tp++;
await You_feel((Sick() ? 'very ' : '') + 'sick.');
await losehp(rnd(8), !glob ? 'cadaver' : 'rotted glob', KILLED_BY_AN);
}
// delay is weight dependent
const v = vc();
v.reqtime = 3 + ((!glob ? (mons[mnum]?.cwt || 0) : (otmp.owt || 0)) >> 6);
if (!tp && !nonrotting_corpse(mnum) && (otmp.orotten || !rn2(7))) {
if (await rottenfood(otmp)) {
otmp.orotten = true;
otmp = await touchfood(otmp);
if (!otmp) return 1;
retcode = 1;
}
if (otmp && !(mons[otmp.corpsenm]?.cnutrit)) {
if (!retcode)
await pline_The('corpse rots away completely.');
if (carried(otmp)) useup(otmp);
else useupf(otmp, 1);
retcode = 2;
}
if (!retcode)
consume_oeaten(otmp, 2);
} else if ((mnum === PM_COCKATRICE || mnum === PM_CHICKATRICE)
&& (Stone_resistance() || Hallucination())) {
await pline('This tastes just like chicken!');
} else if (mnum === PM_FLOATING_EYE && game.u.umonnum === PM_RAVEN) {
await You('peck the eyeball with delight.');
} else if (tp) {
// already delivered a message
} else {
const yummy = (vegan(mons[mnum])
? (!carnivorous(game.player?.data) && herbivorous(game.player?.data))
: (carnivorous(game.player?.data) && !herbivorous(game.player?.data)));
const palatable = ((vegetarian(mons[mnum])
? herbivorous(game.player?.data)
: carnivorous(game.player?.data))
&& rn2(10)
&& (rotted < 1 || !rn2(rotted + 1)));
const palatable_msgs = ['Tokay', 'Istringy', 'Igamey', 'Ifatty', 'Itough'];
const idx = vegetarian(mons[mnum]) ? 0 : rn2(palatable_msgs.length);
const palat_msg = palatable_msgs[idx];
const use_is = (Hallucination() || (palatable && palat_msg[0] === 'I'));
const pmxnam = food_xname(otmp, false);
await pline(
(type_is_pname(mons[mnum]) ? '' : the_unique_pm(mons[mnum]) ? 'The ' : 'This ') +
pmxnam + ' ' +
(use_is ? 'is' : 'tastes') + ' ' +
(Hallucination()
? (yummy ? ((game.u.umonnum === PM_TIGER) ? 'gr-r-reat' : 'gnarly')
: palatable ? 'copacetic' : 'grody')
: (yummy ? 'delicious' : palatable ? palat_msg.slice(1) : 'terrible')) +
((yummy || !palatable) ? '!' : '.'));
}
return retcode;
}
// ── start_eating ──
async function start_eating(otmp, already_partly_eaten) {
const v = vc();
v.fullwarn = v.doreset = 0;
v.eating = 1;
if (otmp.otyp === CORPSE || otmp.globby) {
await cprefx(v.piece.corpsenm);
if (!v.piece || !v.eating) return;
}
if (await bite()) {
if (++v.usedtime >= v.reqtime) {
await done_eating(false);
}
return;
}
if (++v.usedtime >= v.reqtime) {
await done_eating((v.reqtime > 1 || already_partly_eaten) ? true : false);
return;
}
set_occupation(eatfood, 'eating ' + food_xname(otmp, true), 0);
}
// ── fprefx ──
async function fprefx(otmp) {
switch (otmp.otyp) {
case EGG:
if (otmp.corpsenm === PM_PYROLISK) {
if (carried(otmp)) useup(otmp);
else useupf(otmp, 1);
// explode() - TODO
return false;
} else if (stale_egg(otmp)) {
await pline('Ugh. Rotten egg.');
// C: (Vomiting & TIMEOUT) + d(10,4)
const vomitTimeout = (game.u.uprops?.[VOMITING]?.intrinsic || 0) & TIMEOUT;
await make_vomiting(vomitTimeout + c_d(10, 4), true);
} else {
// give_feedback
await pline('This ' + singular(otmp, xname) + ' is ' +
(otmp.cursed
? (Hallucination() ? 'grody!' : 'terrible!')
: Hallucination() ? 'gnarly!' : 'delicious!'));
}
break;
case FOOD_RATION:
if (game.u.uhunger <= 200)
await pline(Hallucination() ? 'Oh wow, like, superior, man!'
: 'This food really hits the spot!');
else if (game.u.uhunger < 700)
await pline('This satiates your stomach!');
break;
case TRIPE_RATION:
if (carnivorous(game.youmonst?.data) && !humanoid(game.youmonst?.data)) {
await pline('This tripe ration is surprisingly good!');
} else if (maybe_polyd(is_orc(game.youmonst?.data), Race_if(PM_ORC))) {
await pline(Hallucination() ? 'Tastes great! Less filling!'
: 'Mmm, tripe... not bad!');
} else {
await pline('Yak - dog food!');
more_experienced(1, 0);
await newexplevel();
if (rn2(2) && !CANNIBAL_ALLOWED()) {
await make_vomiting(rn1(vc().reqtime, 14), false);
}
}
break;
case LEMBAS_WAFER:
if (maybe_polyd(is_orc(game.youmonst?.data), Race_if(PM_ORC))) {
await pline('!#?&* elf kibble!');
break;
} else if (maybe_polyd(is_elf(game.youmonst?.data), Race_if(PM_ELF))) {
await pline('A little goes a long way.');
break;
}
// give_feedback
await pline('This ' + singular(otmp, xname) + ' is ' +
(otmp.cursed ? (Hallucination() ? 'grody!' : 'terrible!')
: (otmp.otyp === CRAM_RATION || otmp.otyp === K_RATION || otmp.otyp === C_RATION)
? 'bland.'
: Hallucination() ? 'gnarly!' : 'delicious!'));
break;
case MEATBALL: case MEAT_STICK: case ENORMOUS_MEATBALL: case MEAT_RING:
// give_feedback
await pline('This ' + singular(otmp, xname) + ' is ' +
(otmp.cursed ? (Hallucination() ? 'grody!' : 'terrible!')
: Hallucination() ? 'gnarly!' : 'delicious!'));
break;
case CLOVE_OF_GARLIC:
if (is_undead(game.youmonst?.data)) {
await make_vomiting(rn1(vc().reqtime, 5), false);
break;
}
// iter_mons(garlic_breath)
for (let mtmp = game.fmon; mtmp; mtmp = mtmp.nmon) {
if (mtmp.dead) continue;
garlic_breath(mtmp);
}
// FALLTHROUGH to default
default:
await give_default_food_msg(otmp);
break;
}
return true;
}
async function give_default_food_msg(otmp) {
if (otmp.otyp === SLIME_MOLD && !otmp.cursed
&& otmp.spe === game.context?.current_fruit) {
await pline('My, this is a ' +
(Hallucination() ? 'primo' : 'yummy') + ' ' +
singular(otmp, xname) + '!');
} else if (otmp.otyp === APPLE && otmp.cursed && !Sleep_resistance()) {
// skip core joke; feedback deferred til fpostfx()
} else if (otmp.otyp === APPLE) {
// C ref: eat.c — on macOS builds, apple gets Mac-specific message
await pline('Delicious! Must be a Macintosh!');
} else if (otmp.otyp === PEAR) {
if (!Hallucination()) {
await pline('Core dumped.');
} else {
const x = rnd(100);
await pline(
(x <= 75) ? 'Segmentation fault -- core dumped.'
: (x <= 99) ? 'Bus error -- core dumped.'
: "Yo' mama -- core dumped.");
}
} else {
await pline('This ' + singular(otmp, xname) + ' is ' +
(otmp.cursed
? (Hallucination() ? 'grody!' : 'terrible!')
: (otmp.otyp === CRAM_RATION || otmp.otyp === K_RATION || otmp.otyp === C_RATION)
? 'bland.'
: Hallucination() ? 'gnarly!' : 'delicious!'));
}
}
// ── fpostfx ──
async function fpostfx(otmp) {
switch (otmp.otyp) {
case SPRIG_OF_WOLFSBANE:
if (ismnum(game.u?.ulycn) || is_were(game.youmonst?.data))
await you_unwere(true);
break;
case CARROT:
if (!game.u?.uswallow)
await make_blinded(game.u?.ucreamed || 0, true);
break;
case FORTUNE_COOKIE:
await outrumor(bcsign(otmp), BY_COOKIE);
if (!Blind()) {
if (!game.u.uconduct) game.u.uconduct = {};
if (!game.u.uconduct.literate++)
livelog_printf(LL_CONDUCT, 'became literate by reading the fortune inside a cookie');
}
break;
case LUMP_OF_ROYAL_JELLY:
if (game.youmonst?.data === mons[PM_KILLER_BEE] && !Unchanging()
&& await polymon(PM_QUEEN_BEE))
break;
await gainstr(otmp, 1, true);
if (Upolyd()) {
game.u.mh += otmp.cursed ? -rnd(20) : rnd(20);
game.disp = game.disp || {};
setBotl('fpostfx');
if (game.u.mh > game.u.mhmax) {
if (!rn2(17)) setuhpmax(game.u.mhmax + 1, false);
game.u.mh = game.u.mhmax;
} else if (game.u.mh <= 0) {
await rehumanize();
}
} else {
game.u.uhp += otmp.cursed ? -rnd(20) : rnd(20);
game.disp = game.disp || {};
setBotl('eat');
if (game.u.uhp > game.u.uhpmax) {
if (!rn2(17)) setuhpmax(game.u.uhpmax + 1, false);
game.u.uhp = game.u.uhpmax;
} else if (game.u.uhp <= 0) {
await done(POISONING);
}
}
if (!otmp.cursed) await heal_legs(0);
break;
case EGG:
if (ismnum(otmp.corpsenm) && flesh_petrifies(mons[otmp.corpsenm])) {
if (!Stone_resistance()
&& !(poly_when_stoned(game.player?.data) && await polymon(PM_STONE_GOLEM))) {
if (!Stoned()) {
await make_stoned(5, null, KILLED_BY_AN, (mons[otmp.corpsenm]?.pmnames?.[0] || 'monster') + ' egg');
}
}
}
break;
case EUCALYPTUS_LEAF:
if (Sick() && !otmp.cursed) await make_sick(0, null, true, SICK_ALL);
if (Vomiting() && !otmp.cursed) await make_vomiting(0, true);
break;
case APPLE:
if (otmp.cursed && !Sleep_resistance()) {
if (Race_if(PM_DWARF) && Hallucination()) {
await verbalize("Heigh-ho, ho-hum, I think I'll skip work today.");
} else if (Deaf() || !(game.flags?.acoustics ?? true)) {
await You('fall asleep.');
} else {
await You_hear('sinister laughter as you fall asleep...');
}
await fall_asleep(-rn1(11, 20), true);
}
break;
}
}
// ── bite ──
async function bite() {
const v = vc();
if (v.canchoke && game.u.uhunger >= 2000) {
await choke(v.piece);
return 1;
}
if (v.doreset) {
await do_reset_eat();
return 0;
}
game.force_save_hs = true;
if (v.nmod < 0) {
await lesshungry(adj_victual_nutrition());
consume_oeaten(v.piece, v.nmod);
} else if (v.nmod > 0 && (v.usedtime % v.nmod)) {
await lesshungry(1);
consume_oeaten(v.piece, -1);
}
game.force_save_hs = false;
recalc_wt();
return 0;
}
// ── gethungry ──
async function gethungry() {
const u = game.u;
if (u.uinvulnerable) return;
// C: gy.youmonst.data — hero's current form
const youdata = game.youmonst?.data || game.player?.data
|| { mflags1: 0x20000000 | 0x40000000 }; // M1_CARNIVORE | M1_HERBIVORE
if ((!Unaware() || !rn2(10))
&& (carnivorous(youdata)
|| herbivorous(youdata)
|| metallivorous(youdata))
&& !Slow_digestion())
u.uhunger--;
const accessorytime = rn2(20);
if (accessorytime % 2) {
// Regeneration uses up food, unless due to an artifact
const hregen = (game.u.uprops?.[REGENERATION]?.intrinsic || 0) & ~FROMFORM;
const eregen = (game.u.uprops?.[REGENERATION]?.extrinsic || 0) & ~(W_ARTI | W_WEP);
if (hregen || eregen) u.uhunger--;
if (near_capacity() > 1) u.uhunger--; // SLT_ENCUMBER = 1
} else {
if (Hunger()) u.uhunger--;
// Conflict uses up food too
const hconflict = game.u.uprops?.[CONFLICT]?.intrinsic || 0;
const econflict = (game.u.uprops?.[CONFLICT]?.extrinsic || 0) & ~W_ARTI;
if (hconflict || econflict) u.uhunger--;
switch (accessorytime) {
case 0:
// Slow digestion from non-ring source (e.g., dragon armor)
if (Slow_digestion()
&& (!game.u.uright || game.u.uright?.otyp !== RIN_SLOW_DIGESTION)
&& (!game.u.uleft || game.u.uleft?.otyp !== RIN_SLOW_DIGESTION))
u.uhunger--;
break;
case 4:
// left ring hunger
if (game.u.uleft && game.u.uleft.otyp !== MEAT_RING
&& (game.u.uleft.spe
|| !game.objects[game.u.uleft.otyp]?.oc_charged
|| (game.u.uleft.otyp === RIN_PROTECTION
&& ((game.u.uprops?.[PROTECTION]?.extrinsic || 0) & ~W_RINGL) === 0)))
u.uhunger--;
break;
case 8:
// amulet hunger
if (game.u.uamul && game.u.uamul.otyp !== FAKE_AMULET_OF_YENDOR)
u.uhunger--;
break;
case 12:
// right ring hunger
if (game.u.uright && game.u.uright.otyp !== MEAT_RING
&& (game.u.uright.spe
|| !game.objects[game.u.uright.otyp]?.oc_charged
|| (game.u.uright.otyp === RIN_PROTECTION
&& ((game.u.uprops?.[PROTECTION]?.extrinsic || 0) & ~W_RINGR) === 0)))
u.uhunger--;
break;
case 16:
if (u.uhave?.amulet) u.uhunger--;
break;
default: break;
}
}
await newuhs(true);
}
// ── morehungry ──
export async function morehungry(num) {
game.u.uhunger -= num;
await newuhs(true);
}
// ── lesshungry ──
async function lesshungry(num) {
const iseating = (game.occupation === eatfood) || game.force_save_hs;
game.u.uhunger += num;
if (game.u.uhunger >= 2000) {
if (!iseating || vc().canchoke) {
if (iseating) {
await choke(vc().piece);
reset_eat();
} else {
await choke((game.occupation === opentin) ? tc().tin : null);
}
}
} else {
if (game.u.uhunger >= 1500 && !Hunger()
&& (!vc().eating || (vc().eating && !vc().fullwarn))) {
await pline("You're having a hard time getting all of it down.");
// C ref: eat.c:3315 — nomovemsg set for both eating and non-eating cases
game.nomovemsg = "You're finally finished.";
if (!vc().eating) {
// C ref: eat.c:3316-3318 — multi = -2 (not used in JS occupation system)
} else {
vc().fullwarn = 1;
if (vc().canchoke && (vc().reqtime - vc().usedtime) > 1) {
if (!await paranoid_query(0, 'Continue eating?')) {
reset_eat();
// C ref: eat.c:3327 — clear nomovemsg if player stops eating
game.nomovemsg = null;
}
}
}
}
}
await newuhs(false);
}
// ── newuhs ──
async function newuhs(incr) {
const u = game.u;
const h = u.uhunger;
let newhs = (h > 1000) ? SATIATED
: (h > 150) ? NOT_HUNGRY
: (h > 50) ? HUNGRY
: (h > 0) ? WEAK
: FAINTING;
if (game.occupation === eatfood || game.force_save_hs) {
if (!game.saved_hs) {
game.save_hs = u.uhs;
game.saved_hs = true;
}
u.uhs = newhs;
return;
} else {
if (game.saved_hs) {
u.uhs = game.save_hs;
game.saved_hs = false;
}
}
if (newhs === FAINTING) {
const uhunger_div_by_10 = sgn(u.uhunger) * Math.trunc((Math.abs(u.uhunger) + 5) / 10);
if (is_fainted()) newhs = FAINTED;
if (u.uhs <= WEAK || rn2(20 - uhunger_div_by_10) >= 19) {
if (!is_fainted() && (game.multi || 0) >= 0) {
const duration = 10 - uhunger_div_by_10;
await stop_occupation();
await You('faint from lack of food.');
incr_itimeout(DEAF, duration);
setBotl('newuhs');
nomul(-duration);
game.multi_reason = 'fainted from lack of food';
game.nomovemsg = 'You regain consciousness.';
game.afternmv = unfaint;
newhs = FAINTED;
if (!Levitation()) await selftouch('Falling, you');
}
} else if (u.uhunger < -(100 + 10 * ACURR(A_CON))) {
u.uhs = STARVED;
game.disp = game.disp || {};
setBotl('newuhs');
await bot();
await You('die from starvation.');
await done(STARVING);
return;
}
}
if (newhs !== u.uhs) {
if (newhs >= WEAK && u.uhs < WEAK) {
setATEMP(A_STR, -1);
} else if (newhs < WEAK && u.uhs >= WEAK) {
setATEMP(A_STR, 0);
}
switch (newhs) {
case HUNGRY:
if (Hallucination()) {
await You(!incr ? 'now have a lesser case of the munchies.'
: 'are getting the munchies.');
} else {
await You(!incr ? 'only feel hungry now.'
: (u.uhunger < 145) ? 'feel hungry.'
: 'are beginning to feel hungry.');
}
if (incr && game.occupation
&& (game.occupation !== eatfood && game.occupation !== opentin))
await stop_occupation();
end_running(true);
break;
case WEAK:
if (Hallucination()) {
await pline(!incr ? 'You still have the munchies.'
: 'The munchies are interfering with your motor capabilities.');
} else if (incr && (Role_if(PM_WIZARD) || Race_if(PM_ELF)
|| Role_if(PM_VALKYRIE))) {
await pline(
((Role_if(PM_WIZARD) || Role_if(PM_VALKYRIE))
? (game.u.urole?.name?.m || 'Hero')
: 'Elf')
+ ' needs food, badly!');
} else {
await You(!incr ? 'are still weak.'
: (u.uhunger < 45) ? 'feel weak.'
: 'are beginning to feel weak.');
}
if (incr && game.occupation
&& (game.occupation !== eatfood && game.occupation !== opentin))
await stop_occupation();
end_running(true);
break;
}
u.uhs = newhs;
game.disp = game.disp || {};
setBotl('newuhs');
await bot();
if ((Upolyd() ? u.mh : u.uhp) < 1) {
await You('die from hunger and exhaustion.');
await done(STARVING);
return;
}
}
}
// ── vomit ── (port of vomit() from eat.c)
async function vomit_fn() {
let spewed = false;
if (cantvomit(game.player?.data)) {
await Your(body_part(4 /*STOMACH*/) + ' gapes convulsively.');
} else {
if (Sick() && ((game.u?.usick_type || 0) & SICK_VOMITABLE) !== 0)
await make_sick(0, null, true, SICK_VOMITABLE);
if (game.u.uhs >= FAINTING)
await Your(body_part(4 /*STOMACH*/) + ' heaves convulsively!');
else
spewed = true;
}
if ((game.multi || 0) >= -2) {
nomul(-2);
}
if (spewed) {
const mattk = attacktype_fordmg(game.player?.data, AT_BREA, AD_ACID);
if (mattk) {
/* yellow dragon acid breath on self -- TODO: ubreatheu */
}
/* vomiting on altar -- TODO: altar_wrath */
if (acidic(game.player?.data)) {
if (is_ice(game.u.ux, game.u.uy))
melt_ice(game.u.ux, game.u.uy,
'Your stomach acid melts straight through the ice!');
}
}
}
// is_fainted: imported from macros.js
// ── reset_faint ──
function reset_faint() {
// if (ga.afternmv === unfaint) unmul("You revive.");
}
// ── Hear_again ──
async function Hear_again() {
if (!rn2(2)) {
await make_deaf(0, false);
game.disp = game.disp || {};
setBotl('Hear_again');
}
return 0;
}
// ── unfaint ──
async function unfaint() {
await Hear_again();
if (game.u.uhs > FAINTING) game.u.uhs = FAINTING;
await stop_occupation();
game.disp = game.disp || {};
setBotl('unfaint');
return 0;
}
// ── eaten_stat ──
// eaten_stat: imported from mkobj.js
async function maybe_finished_meal(stopping) {
const v = vc();
if (game.occupation === eatfood && v.usedtime >= v.reqtime) {
if (stopping) game.occupation = null;
await eatfood();
return true;
}
return false;
}
// ── doeat ──
async function doeat() {
const v = vc();
let otmp;
let basenutrit;
let dont_start = false;
let already_partly_eaten;
if (Strangled()) {
await pline("If you can't breathe air, how can you consume solids?");
return ECMD_OK;
}
otmp = await floorfood('eat', 0);
if (!otmp) return ECMD_OK;
if (check_capacity(null)) return ECMD_OK;
if (game.u?.uedibility) {
const res = await edibility_prompts(otmp);
if (res) {
await Your(body_part(11 /*NOSE*/) + ' stops tingling and your sense of smell returns to normal.');
game.u.uedibility = 0;
if (res === 1)
return ECMD_OK;
}
}
if (!is_edible(otmp)) {
await You('cannot eat that!');
return ECMD_OK;
}
if (otmp.oclass !== FOOD_CLASS) {
return await doeat_nonfood(otmp);
}
if (otmp === v.piece) {
const one_bite_left = (v.usedtime + 1 >= v.reqtime);
if (game.u.uhs !== SATIATED) v.canchoke = 0;
v.o_id = 0;
otmp = await touchfood(otmp);
if (otmp) {
v.piece = otmp;
v.o_id = otmp.o_id || 0;
} else {
await do_reset_eat();
}
await You(!one_bite_left ? 'resume your meal.' : 'consume the last bite of your meal.');
if (otmp) await start_eating(otmp, false);
return ECMD_TIME;
}
if (otmp.otyp === TIN) {
await start_tin(otmp);
return ECMD_TIME;
}
// conduct
if (!game.u.uconduct) game.u.uconduct = {};
let ll_conduct = 0;
if (!game.u.uconduct.food++) {
livelog_printf(LL_CONDUCT, 'ate for the first time - ' + food_xname(otmp, false));
ll_conduct++;
}
already_partly_eaten = !!otmp.oeaten;
otmp = await touchfood(otmp);
if (otmp) {
v.piece = otmp;
v.o_id = otmp.o_id || 0;
v.usedtime = 0;
} else {
await do_reset_eat();
return ECMD_TIME;
}
if (otmp.otyp === CORPSE || otmp.globby) {
const tmp = await eatcorpse(otmp);
if (tmp === 2) {
Object.assign(v, zero_victual);
return ECMD_TIME;
} else if (tmp)
dont_start = true;
} else {
// material-based conduct
const material = game.objects[otmp.otyp]?.oc_material;
if (material === FLESH) {
if (!game.u.uconduct.unvegan++ && !ll_conduct) {
livelog_printf(LL_CONDUCT, 'consumed animal products for the first time, by eating ' + an(food_xname(otmp, false)));
ll_conduct++;
}
if (otmp.otyp !== EGG) {
if (!game.u.uconduct.unvegetarian && !ll_conduct)
livelog_printf(LL_CONDUCT, 'tasted meat for the first time, by eating ' + an(food_xname(otmp, false)));
await violated_vegetarian();
}
} else {
// C: check for egg-containing foods (pancake, fortune cookie, cream pie, candy bar, royal jelly)
if (otmp.otyp === PANCAKE || otmp.otyp === FORTUNE_COOKIE
|| otmp.otyp === CREAM_PIE || otmp.otyp === CANDY_BAR
|| otmp.otyp === LUMP_OF_ROYAL_JELLY)
if (!game.u.uconduct.unvegan++ && !ll_conduct)
livelog_printf(LL_CONDUCT, 'consumed animal products (' + food_xname(otmp, false) + ') for the first time');
}
v.reqtime = game.objects[otmp.otyp]?.oc_delay || 1;
if (otmp.otyp !== FORTUNE_COOKIE
&& (otmp.cursed || (!nonrotting_food(otmp.otyp)
&& (game.moves - (otmp.age || 0)) > (otmp.blessed ? 50 : 30)
&& (otmp.orotten || !rn2(7))))) {
if (await rottenfood(otmp)) {
otmp.orotten = true;
dont_start = true;
}
consume_oeaten(otmp, 1);
} else if (!already_partly_eaten) {
if (!(await fprefx(otmp))) {
await do_reset_eat();
return ECMD_TIME;
}
} else {
await You((v.reqtime === 1) ? 'eat ' + doname(otmp) + '.'
: 'begin eating ' + doname(otmp) + '.');
}
}
// re-calc nutrition
basenutrit = obj_nutrition(otmp);
v.reqtime = (basenutrit === 0) ? 0
: rounddiv(v.reqtime * (otmp.oeaten || 0), basenutrit);
if (v.reqtime === 0 || (otmp.oeaten || 0) === 0)
v.nmod = 0;
else if (otmp.oeaten >= v.reqtime)
v.nmod = -Math.trunc(otmp.oeaten / v.reqtime);
else
v.nmod = v.reqtime % otmp.oeaten;
v.canchoke = (game.u.uhs === SATIATED);
if (!dont_start)
await start_eating(otmp, already_partly_eaten);
else if (otmp)
otmp.owt = weight(otmp);
return ECMD_TIME;
}
// ── doeat_nonfood ──
async function doeat_nonfood(otmp) {
const v = vc();
let basenutrit;
v.reqtime = 1;
v.piece = otmp;
v.o_id = otmp.o_id || 0;
v.usedtime = 0;
v.canchoke = (game.u.uhs === SATIATED);
if (otmp.oclass === COIN_CLASS)
basenutrit = ((otmp.quan > 200000) ? 2000 : Math.trunc((otmp.quan || 0) / 100));
else if (otmp.oclass === BALL_CLASS || otmp.oclass === CHAIN_CLASS)
basenutrit = weight(otmp);
else
basenutrit = game.objects[otmp.otyp]?.oc_nutrition || 0;
v.nmod = basenutrit;
v.eating = 1;
if (!game.u.uconduct) game.u.uconduct = {};
let ll_conduct = 0;
if (!game.u.uconduct.food++) {
ll_conduct++;
livelog_printf(LL_CONDUCT, 'ate for the first time (' + food_xname(otmp, false) + ')');
}
const material = game.objects[otmp.otyp]?.oc_material;
if (material === LEATHER || material === BONE
|| material === DRAGON_HIDE || material === WAX) {
if (!game.u.uconduct.unvegan++ && !ll_conduct) {
livelog_printf(LL_CONDUCT, 'consumed animal products for the first time, by eating ' + an(food_xname(otmp, false)));
ll_conduct++;
}
if (material !== WAX) {
if (!game.u.uconduct.unvegetarian && !ll_conduct)
livelog_printf(LL_CONDUCT, 'tasted meat by-products for the first time, by eating ' + an(food_xname(otmp, false)));
await violated_vegetarian();
}
}
let nodelicious = false;
if (otmp.cursed) {
await rottenfood(otmp);
nodelicious = true;
} else if (game.objects[otmp.otyp]?.oc_material === PAPER)
nodelicious = true;
if (otmp.oclass === WEAPON_CLASS && otmp.opoisoned) {
await pline('Ecch - that must have been poisonous!');
if (!Poison_resistance()) {
const str_dmg = rnd(4);
const hp_dmg = rnd(15);
await losehp(hp_dmg, xname(otmp), KILLED_BY_AN);
} else {
await You('seem unaffected by the poison.');
}
} else if (!nodelicious) {
await pline('This ' +
(otmp.oclass === COIN_CLASS ? foodword(otmp) : singular(otmp, xname)) +
' is delicious!');
}
await eatspecial();
return ECMD_TIME;
}
// ── eatspecial ──
async function eatspecial() {
const v = vc();
const otmp = v.piece;
if (!otmp) return;
set_occupation(eatfood, 'eating non-food', 0);
await lesshungry(v.nmod);
game.occupation = null;
Object.assign(v, zero_victual);
if (otmp.oclass === COIN_CLASS) {
if (carried(otmp)) useupall(otmp);
else useupf(otmp, otmp.quan || 1);
vault_gd_watching(0);
return;
}
const material = game.objects[otmp.otyp]?.oc_material;
if (material === PAPER) {
/* simplified paper messages */
await pline('Needs salt...');
}
if (otmp.oclass === POTION_CLASS) {
otmp.quan = (otmp.quan || 1) + 1;
await dopotion(otmp);
} else if (otmp.oclass === RING_CLASS || otmp.oclass === AMULET_CLASS) {
await eataccessory(otmp);
} else if (otmp.leashmon) {
o_unleash(otmp);
}
if (otmp.otyp === TRIDENT && !otmp.cursed) {
await pline(Hallucination() ? 'Four out of five dentists agree.'
: 'That was pure chewing satisfaction!');
exercise(A_WIS, true);
}
if (otmp.otyp === FLINT && !otmp.cursed) {
await pline('Yabba-dabba delicious!');
exercise(A_CON, true);
}
if (otmp === game.u?.uwep && (otmp.quan || 1) === 1)
await uwepgone();
if (otmp === game.u?.uquiver && (otmp.quan || 1) === 1)
uqwepgone();
if (otmp === game.u?.uswapwep && (otmp.quan || 1) === 1)
uswapwepgone();
if (otmp === game.u?.uball)
unpunish();
if (otmp === game.u?.uchain)
unpunish();
else if (carried(otmp)) useup(otmp);
else useupf(otmp, 1);
}
// ── eataccessory ──
async function eataccessory(otmp) {
const typ = otmp.otyp;
const u = game.u;
// C: save old property value
const oprop = game.objects[typ]?.oc_oprop || 0;
const oldprop = oprop ? (u.uprops?.[oprop]?.intrinsic || 0) : 0;
// C: if wearing the ring, remove it first
if (otmp === u.uleft || otmp === u.uright) {
await Ring_gone(otmp);
if (u.uhp <= 0) return; // died from sink fall
}
observe_object(otmp);
otmp.known = 1;
if (!rn2(otmp.oclass === RING_CLASS ? 3 : 5)) {
switch (otmp.otyp) {
default:
if (!oprop) break;
if (!((u.uprops?.[oprop]?.intrinsic || 0) & FROMOUTSIDE))
await accessory_has_effect(otmp);
if (!u.uprops) u.uprops = {};
if (!u.uprops[oprop]) u.uprops[oprop] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[oprop].intrinsic |= FROMOUTSIDE;
// C: inner switch for special ring types
switch (typ) {
case RIN_SEE_INVISIBLE:
set_mimic_blocking();
see_monsters();
if (Invis() && !oldprop && !(u.uprops?.[SEE_INVIS]?.extrinsic || 0) && !Blind()) {
newsym(u.ux, u.uy);
await pline('Suddenly you can see yourself.');
makeknown(typ);
}
break;
case RIN_INVISIBILITY:
if (!oldprop && !(u.uprops?.[INVIS]?.extrinsic || 0) && !See_invisible() && !Blind()) {
newsym(u.ux, u.uy);
await Your('body takes on a ' +
(Hallucination() ? 'normal' : 'strange') + ' transparency...');
makeknown(typ);
}
break;
case RIN_PROTECTION_FROM_SHAPE_CHAN:
await rescham();
break;
case RIN_LEVITATION:
// undo the FROMOUTSIDE done above
u.uprops[LEVITATION].intrinsic = oldprop;
if (!Levitation()) {
await float_up();
incr_itimeout(LEVITATION, c_d(10, 20));
makeknown(typ);
}
break;
}
break;
case RIN_ADORNMENT:
await accessory_has_effect(otmp);
if (await adjattrib(A_CHA, otmp.spe || 0, -1))
makeknown(typ);
break;
case RIN_GAIN_STRENGTH:
await accessory_has_effect(otmp);
if (await adjattrib(A_STR, otmp.spe || 0, -1))
makeknown(typ);
break;
case RIN_GAIN_CONSTITUTION:
await accessory_has_effect(otmp);
if (await adjattrib(A_CON, otmp.spe || 0, -1))
makeknown(typ);
break;
case RIN_INCREASE_ACCURACY:
await accessory_has_effect(otmp);
u.uhitinc = bounded_increase(u.uhitinc || 0, otmp.spe || 0, RIN_INCREASE_ACCURACY);
break;
case RIN_INCREASE_DAMAGE:
await accessory_has_effect(otmp);
u.udaminc = bounded_increase(u.udaminc || 0, otmp.spe || 0, RIN_INCREASE_DAMAGE);
break;
case RIN_PROTECTION:
case AMULET_OF_GUARDING:
await accessory_has_effect(otmp);
if (!u.uprops) u.uprops = {};
if (!u.uprops[PROTECTION]) u.uprops[PROTECTION] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[PROTECTION].intrinsic |= FROMOUTSIDE;
u.ublessed = bounded_increase(u.ublessed || 0,
(typ === RIN_PROTECTION) ? (otmp.spe || 0) : 2, typ);
setBotl('eat');
break;
case RIN_FREE_ACTION:
if (!((u.uprops?.[SLEEP_RES]?.intrinsic || 0) & FROMOUTSIDE))
await accessory_has_effect(otmp);
if (!Sleep_resistance()) await You_feel('wide awake.');
if (!u.uprops) u.uprops = {};
if (!u.uprops[SLEEP_RES]) u.uprops[SLEEP_RES] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[SLEEP_RES].intrinsic |= FROMOUTSIDE;
break;
case AMULET_OF_CHANGE:
await accessory_has_effect(otmp);
makeknown(typ);
change_sex();
await You('are suddenly very ' + (game.flags?.female ? 'feminine' : 'masculine') + '!');
setBotl('eat');
break;
case AMULET_OF_UNCHANGING:
if (!Unchanging() && Upolyd()) {
await accessory_has_effect(otmp);
makeknown(typ);
await rehumanize();
}
break;
case AMULET_OF_STRANGULATION:
await choke(otmp);
break;
case AMULET_OF_RESTFUL_SLEEP: {
const newnap = rnd(100);
const oldnap = (u.uprops?.[SLEEPY]?.intrinsic || 0) & TIMEOUT;
if (!((u.uprops?.[SLEEPY]?.intrinsic || 0) & FROMOUTSIDE))
await accessory_has_effect(otmp);
if (!u.uprops) u.uprops = {};
if (!u.uprops[SLEEPY]) u.uprops[SLEEPY] = { intrinsic: 0, extrinsic: 0, blocked: 0 };
u.uprops[SLEEPY].intrinsic |= FROMOUTSIDE;
if (newnap < oldnap || oldnap === 0)
u.uprops[SLEEPY].intrinsic = (u.uprops[SLEEPY].intrinsic & ~TIMEOUT) | newnap;
break;
}
case RIN_SUSTAIN_ABILITY:
case AMULET_OF_LIFE_SAVING:
case AMULET_OF_FLYING:
case AMULET_OF_REFLECTION:
break;
}
}
}
// ── accessory_has_effect ──
async function accessory_has_effect(otmp) {
await pline('Magic spreads through your body as you digest the ' +
(otmp.oclass === RING_CLASS ? 'ring' : 'amulet') + '.');
}
// ── bounded_increase ──
function bounded_increase(old, inc, typ) {
const absold = Math.abs(old), absinc_orig = Math.abs(inc);
const sgnold = sgn(old), sgninc = sgn(inc);
let absinc = absinc_orig;
if (absinc === 0 || sgnold !== sgninc || absold + absinc < 10) {
// use inc as-is
} else if (absold + absinc < 20) {
absinc = rnd(absinc);
if (absold + absinc < 10) absinc = 10 - absold;
inc = sgninc * absinc;
} else if (absold + absinc < 40) {
absinc = rn2(absinc) ? 1 : 0;
if (absold + absinc < 20) absinc = rnd(20 - absold);
inc = sgninc * absinc;
} else {
inc = 0;
}
return old + inc;
}
// ── eat_ok / offer_ok / tin_ok ── (getobj callbacks)
function eat_ok(obj) {
if (!obj) return game.getobj_else ? GETOBJ_EXCLUDE_NONINVENT : GETOBJ_EXCLUDE;
if (is_edible(obj)) return GETOBJ_SUGGEST;
if (obj.oclass === COIN_CLASS) return GETOBJ_EXCLUDE;
return GETOBJ_EXCLUDE_SELECTABLE;
}
function offer_ok(obj) {
if (!obj) return game.getobj_else ? GETOBJ_EXCLUDE_NONINVENT : GETOBJ_EXCLUDE;
if (obj.oclass !== FOOD_CLASS && obj.oclass !== AMULET_CLASS) return GETOBJ_EXCLUDE;
if (obj.otyp !== CORPSE && obj.otyp !== AMULET_OF_YENDOR && obj.otyp !== FAKE_AMULET_OF_YENDOR)
return GETOBJ_EXCLUDE_SELECTABLE;
return GETOBJ_SUGGEST;
}
function tin_ok(obj) {
if (!obj) return game.getobj_else ? GETOBJ_EXCLUDE_NONINVENT : GETOBJ_EXCLUDE;
if (obj.oclass !== FOOD_CLASS) return GETOBJ_EXCLUDE;
if (obj.otyp !== CORPSE) return GETOBJ_EXCLUDE_SELECTABLE;
return GETOBJ_SUGGEST;
}
// ── eatmdone ── (port of eatmdone from eat.c)
// called after mimicking is over
function eatmdone() {
if (game.eatmbuf) {
if (game.nomovemsg === game.eatmbuf)
game.nomovemsg = null;
game.eatmbuf = null;
}
if (U_AP_TYPE()) {
game.player.m_ap_type = M_AP_NOTHING;
newsym(game.u.ux, game.u.uy);
}
return 0;
}
// ── eatmupdate ── (port of eatmupdate from eat.c)
// called when hallucination is toggled
function eatmupdate() {
if (!game.eatmbuf || game.nomovemsg !== game.eatmbuf)
return;
/* simplified: in practice this is very rare */
}
// ── temp_resist ── (port of temp_resist from eat.c)
function temp_resist(prop) {
const u = game.u;
if (!u.uprops?.[prop]) return 0;
const p = u.uprops[prop];
const timeout = (p.intrinsic || 0) & TIMEOUT;
if (timeout
&& ((p.intrinsic || 0) & ~TIMEOUT) === 0
&& !p.extrinsic
&& !p.blocked) {
return timeout;
}
return 0;
}
// ── eating_dangerous_corpse ── (port from eat.c)
function eating_dangerous_corpse(res) {
let food, mnum;
if (game.occupation === eatfood
&& (food = vc().piece) !== null
&& food.otyp === CORPSE
&& (mnum = food.corpsenm) >= 0
&& (carried(food) || obj_here(food, game.u.ux, game.u.uy))) {
if (res === ACID_RES && acidic(mons[mnum]))
return true;
if (res === STONE_RES && flesh_petrifies(mons[mnum]))
return true;
}
return false;
}
// ── cant_finish_meal ── (port from eat.c)
async function cant_finish_meal(corpse) {
if (game.occupation === eatfood && vc().piece === corpse) {
Object.assign(vc(), zero_victual);
if (!corpse.oeaten)
corpse.oeaten = 1;
game.occupation = function donull() { return 0; };
await stop_occupation();
await newuhs(false);
}
}
// ── eating_glob ── (port from eat.c)
function eating_glob(glob) {
return (game.occupation === eatfood && glob === vc().piece);
}
// ── Popeye ── (port from eat.c)
function Popeye(threat) {
if (game.occupation !== opentin)
return false;
const otin = tc().tin;
if (!otin) return false;
if (!carried(otin)
&& (!obj_here(otin, game.u.ux, game.u.uy) || !can_reach_floor(true)))
return false;
if (!otin.known)
return true;
const mndx = otin.corpsenm;
const HUNGER_THREAT = 0; // placeholder
switch (threat) {
case HUNGER_THREAT:
return (mndx !== NON_PM || otin.spe === 1);
case STONING:
return (ismnum(mndx)
&& (mndx === PM_LIZARD || acidic(mons[mndx])));
default:
break;
}
return false;
}
// ── Finish_digestion ── (port from eat.c)
async function Finish_digestion() {
if (game.corpsenm_digested !== undefined
&& game.corpsenm_digested !== NON_PM) {
await cpostfx(game.corpsenm_digested);
game.corpsenm_digested = NON_PM;
}
return 0;
}
// ── garlic_breath ── (port from eat.c)
function garlic_breath(mtmp) {
if (olfaction(mtmp?.data) && distu(mtmp.mx, mtmp.my) < 7) {
// C: monflee(mtmp, 0, FALSE, FALSE) — not yet fully ported
if (mtmp) mtmp.mflee = 1;
}
}
// NOTE: differs from canonical hacklib.js — 2-arg signature using game.u; canonical is 3-arg distu(player, x, y)
// ── tinopen_ok ── (port from eat.c)
function tinopen_ok(obj) {
if (obj && obj.otyp === TIN)
return GETOBJ_SUGGEST;
return GETOBJ_EXCLUDE;
}
// ── use_tin_opener ── (port from eat.c)
async function use_tin_opener(obj) {
let res = ECMD_OK;
/* simplified: check if carrying a tin */
let has_tin = false;
for (let o = game.invent; o; o = o.nobj) {
if (o.otyp === TIN) { has_tin = true; break; }
}
if (!has_tin) {
await You('have no tin to open.');
return ECMD_OK;
}
const otmp = await getobj('open', tinopen_ok, GETOBJ_NOFLAGS);
if (!otmp)
return (res | ECMD_CANCEL);
await start_tin(otmp);
return ECMD_TIME;
}
// ── edibility_prompts ── (port from eat.c)
async function edibility_prompts(otmp) {
const cadaver = (otmp.otyp === CORPSE);
let stoneorslime = false;
const mnum = otmp.corpsenm;
let rotted = 0;
if (cadaver || otmp.otyp === EGG || otmp.otyp === TIN
|| otmp.otyp === GLOB_OF_GREEN_SLIME) {
stoneorslime = (ismnum(mnum)
&& flesh_petrifies(mons[mnum])
&& !Stone_resistance()
&& !poly_when_stoned(game.player?.data));
if (mnum === PM_GREEN_SLIME || otmp.otyp === GLOB_OF_GREEN_SLIME)
stoneorslime = (!Unchanging() && !slimeproof(game.player?.data));
if (cadaver && !nonrotting_corpse(mnum)) {
const age = peek_at_iced_corpse_age(otmp);
/* worst case rather than random */
rotted = Math.trunc((game.moves - age) / 10);
if (otmp.cursed)
rotted += 2;
else if (otmp.blessed)
rotted -= 2;
}
}
let buf = '';
const foodsmell = 'This ' + singular(otmp, xname) + ' smells';
const it_or_they = ((otmp.quan || 1) === 1) ? 'it' : 'they';
if (cadaver && rotted > 5 && !Sick_resistance()) {
buf = foodsmell + ' like ' + it_or_they + ' could be tainted!';
} else if (stoneorslime) {
buf = foodsmell + ' like ' + it_or_they + ' could be something very dangerous!';
} else if (cadaver && rotted > 5 && Sick_resistance()) {
buf = foodsmell + ' like ' + it_or_they + ' could be tainted.';
} else if (otmp.orotten || (cadaver && rotted > 3)) {
buf = foodsmell + ' like ' + it_or_they + ' could be rotten!';
} else if (cadaver && poisonous(mons[mnum]) && !Poison_resistance()) {
buf = foodsmell + ' like ' + it_or_they + ' might be poisonous!';
} else if (otmp.otyp === APPLE && otmp.cursed && !Sleep_resistance()) {
buf = foodsmell + ' like ' + it_or_they + ' might have been poisoned.';
} else if (cadaver && !vegetarian(mons[mnum])
&& !(game.u?.uconduct?.unvegetarian) && Role_if(PM_MONK)) {
buf = foodsmell + ' unhealthy.';
} else if (cadaver && acidic(mons[mnum]) && !Acid_resistance()) {
buf = foodsmell + ' rather acidic.';
}
if (buf) {
buf += ' Eat ' + ((otmp.quan || 1) === 1 ? 'it' : 'one') + ' anyway?';
const c = await ynFunction(buf, 'yn', 'n'.charCodeAt(0));
return (c === 'n'.charCodeAt(0)) ? 1 : 2;
}
return 0;
}
// ── tin_details ── (port from eat.c)
function tin_details(obj, mnum, buf_ref) {
if (!obj || !buf_ref) return;
const r = tin_variety(obj, true);
if (r === SPINACH_TIN) {
buf_ref.val += ' of spinach';
} else if (mnum === NON_PM) {
buf_ref.val = 'empty tin';
} else {
if ((obj.cknown || false) && obj.spe < 0) {
if (r === ROTTEN_TIN || r === HOMEMADE_TIN) {
buf_ref.val = tintxts[r].txt + ' ' + buf_ref.val + ' of ';
} else {
buf_ref.val += ' of ' + tintxts[r].txt + ' ';
}
} else {
buf_ref.val += ' of ';
}
if (vegetarian(mons[mnum]))
buf_ref.val += (mons[mnum]?.pmnames?.[0] || 'monster');
else
buf_ref.val += (mons[mnum]?.pmnames?.[0] || 'monster') + ' meat';
}
}
// ── Exports ──
export {
// Main functions
doeat,
gethungry,
lesshungry,
newuhs,
init_uhunger,
is_edible,
obj_nutrition,
eaten_stat,
consume_oeaten,
touchfood,
reset_eat,
food_disappears,
food_substitution,
maybe_finished_meal,
is_fainted,
reset_faint,
Hear_again,
violated_vegetarian,
eating_conducts,
maybe_cannibal,
intrinsic_possible,
should_givit,
corpse_intrinsic,
set_tin_variety,
tin_variety_txt,
hu_stat,
vomit_fn as vomit,
eat_ok,
offer_ok,
tin_ok,
// also export for use by other modules
choke,
eatfood,
opentin,
cprefx,
cpostfx,
fprefx,
fpostfx,
start_eating,
eatcorpse,
bite,
// newly ported functions
eatmdone,
eatmupdate,
temp_resist,
eating_dangerous_corpse,
cant_finish_meal,
eating_glob,
Popeye,
Finish_digestion,
floorfood,
garlic_breath,
tinopen_ok,
use_tin_opener,
edibility_prompts,
tin_details,
};
// ── tin_variety_txt ──
function tin_variety_txt(s, tinvariety_ref) {
if (s && tinvariety_ref) {
tinvariety_ref.val = -1;
for (let k = 0; k < TTSZ - 1; ++k) {
const l = tintxts[k].txt.length;
if (s.substring(0, l).toLowerCase() === tintxts[k].txt.toLowerCase()
&& s.length > l && s[l] === ' ') {
tinvariety_ref.val = k;
return l + 1;
}
}
}
return 0;
}
export function init_eat_globals() {
game.getobj_else = 0;
game.ate_brains_turn = 0;
game.save_hs = 0;
game.saved_hs = false;
}
|