All files / js/levels minetn-1.js

100% Statements 164/164
100% Branches 14/14
100% Functions 1/1
100% Lines 164/164

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 1651x 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 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 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 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 18x 16x 16x 18x 18x 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 6x 3x 3x 3x 1x 3x 2x 2x 3x 6x 1x 1x 1x 6x 6x 6x 1x 1x 1x 13x 11x 13x 2x 2x 13x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * minetn-1 - NetHack special level
 * Converted from: minetn-1.lua
 */
 
import * as des from '../sp_lev.js';
import { selection, percent, shuffle } from '../sp_lev.js';
import { rn2 } from '../rng.js';
 
export async function generate() {
    // NetHack 3.7	mines minetn-1.lua	$NHDT-Date: 1652196030 2022/5/10 15:20:30 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.8 $
    // Copyright (c) 1989-95 by Jean-Christophe Collet
    // Copyright (c) 1991-95 by M. Stephenson
    // NetHack may be freely redistributed.  See license for details.
    // 
    // A tragic accident has occurred in Frontier Town...args.
    // 
    // Minetown variant 1
    // Orcish Town - a variant of Frontier Town that has been
    // overrun by orcs.  Note the barricades (iron bars).
 
    des.level_flags("mazelevel");
 
    des.level_init({ style: "mines", fg: ".", bg: " ", smoothed: true, joined: true, walled: true });
 
    await des.map(`\
.....................................
.----------------F------------------.
.|.................................|.
.|.-------------......------------.|.
.|.|...|...|...|......|..|...|...|.|.
.F.|...|...|...|......|..|...|...|.|.
.|.|...|...|...|......|..|...|...|.F.
.|.|...|...|----......------------.|.
.|.---------.......................|.
.|.................................|.
.|.---------.....--...--...........|.
.|.|...|...|----.|.....|.---------.|.
.|.|...|...|...|.|.....|.|..|....|.|.
.|.|...|...|...|.|.....|.|..|....|.|.
.|.|...|...|...|.|.....|.|..|....|.|.
.|.-------------.-------.---------.|.
.|.................................F.
.-----------F------------F----------.
.....................................
`);
 
    // Don't let the player fall into his likely death; used to explicitly exclude
    // the town, but that meant that you couldn't teleport out as well as not in.
    des.teleport_region({ region: [1,1,75,19], exclude: [1,0,35,21], region_islev: 1 });
    await des.region(selection.area(1,1,35,17), "lit");
    des.levregion({ type: "stair-up", region: [1,3,21,19], region_islev: 1,
    		exclude: [0,1,36,17] });
    des.levregion({ type: "stair-down", region: [57,3,75,19], region_islev: 1,
    		exclude: [0,1,36,17] })
 
    // shame we can't make polluted fountains
    des.feature("fountain",16,9);
    des.feature("fountain",25,9);
 
    // the altar's defiled; useful for BUC but never coaligned
    await des.altar({ x: 20,y: 13,align: "noalign", type: "shrine" });
 
    // set up the shop doors; could be broken down
    des.door("random",5,8);
    des.door("random",9,8);
    des.door("random",13,7);
    des.door("random",22,5);
    des.door("random",27,7);
    des.door("random",31,7);
    des.door("random",5,10);
    des.door("random",9,10);
    des.door("random",15,13);
    des.door("random",25,13);
    des.door("random",31,11);
 
    // knock a few holes in the shop interior walls
    des.replace_terrain({ region: [7,4,11,6], fromterrain: "|", toterrain: ".", chance: 18 });
    des.replace_terrain({ region: [25,4,29,6], fromterrain: "|", toterrain: ".", chance: 18 });
    des.replace_terrain({ region: [7,12,11,14], fromterrain: "|", toterrain: ".", chance: 18 });
    des.replace_terrain({ region: [28,12,28,14], fromterrain: "|", toterrain: ".", chance: 33 });
 
    // One spot each in most shops...args
    let place = [ [5,4],[9,5],[13,4],[26,4],[31,5],[30,14],[5,14],[10,13],[26,14],[27,13] ]
    shuffle(place);
 
    // scatter some bodies
    await des.object({ id: "corpse", x: 20,y: 12, montype: "aligned cleric" });
    await des.object({ id: "corpse", coord: place[0], montype: "shopkeeper" });
    await des.object({ id: "corpse", coord: place[1], montype: "shopkeeper" });
    await des.object({ id: "corpse", coord: place[2], montype: "shopkeeper" });
    await des.object({ id: "corpse", coord: place[3], montype: "shopkeeper" });
    await des.object({ id: "corpse", coord: place[4], montype: "shopkeeper" });
    await des.object({ id: "corpse", montype: "watchman" });
    await des.object({ id: "corpse", montype: "watchman" });
    await des.object({ id: "corpse", montype: "watchman" });
    await des.object({ id: "corpse", montype: "watchman" });
    await des.object({ id: "corpse", montype: "watch captain" });
 
    // Rubble!
    for (let i = 1, __end_i = (rn2((19) - (10) + 1) + (10)); i <= __end_i; i++) {
      if (percent(90)) {
        await des.object("boulder");
      }
      await des.object("rock");
    }
 
    // Guarantee 7 candles since we won't have Izchak available
    await des.object({ id: "wax candle", coord: place[3], quantity: (rn2((2) - (1) + 1) + (1)) });
 
    await des.object({ id: "wax candle", coord: place[0], quantity: (rn2((4) - (2) + 1) + (2)) });
    await des.object({ id: "wax candle", coord: place[1], quantity: (rn2((2) - (1) + 1) + (1)) });
    await des.object({ id: "tallow candle", coord: place[2], quantity: (rn2((3) - (1) + 1) + (1)) });
    await des.object({ id: "tallow candle", coord: place[1], quantity: (rn2((2) - (1) + 1) + (1)) });
    await des.object({ id: "tallow candle", coord: place[3], quantity: (rn2((2) - (1) + 1) + (1)) });
 
    // go ahead and leave a lamp next to one corpse to be suggestive
    // and some empty wands...
    await des.object("oil lamp",place[1]);
    await des.object({ id: "wand of striking", coord: place[0], buc: "uncursed", spe: 0 });
    await des.object({ id: "wand of striking", coord: place[2], buc: "uncursed", spe: 0 });
    await des.object({ id: "wand of striking", coord: place[3], buc: "uncursed", spe: 0 });
    await des.object({ id: "wand of magic missile", coord: place[3], buc: "uncursed", spe: 0 });
    await des.object({ id: "wand of magic missile", coord: place[4], buc: "uncursed", spe: 0 });
 
    // the Orcish Army
 
    let inside = selection.floodfill(18,8)
    let near_temple = selection.area(17,8, 23,14).intersect(inside)
 
    for (let i = 1, __end_i = (rn2((15) - (5) + 1) + (5)); i <= __end_i; i++) {
       if (percent(50)) {
          await des.monster({ id: "orc-captain", coord: inside.rndcoord(1), peaceful: 0 });
       } else {
          if (percent(80)) {
             await des.monster({ id: "Uruk-hai", coord: inside.rndcoord(1), peaceful: 0 });
          } else {
             await des.monster({ id: "Mordor orc", coord: inside.rndcoord(1), peaceful: 0 });
          }
       }
    }
    // shamans can be hanging out in/near the temple
    // one of the shamans is higher level
    for (let i = 1, __end_i = (rn2((6) - (1) + 1) + (1)); i <= __end_i; i++) {
       await des.monster({ id: "orc shaman", coord: near_temple.rndcoord(0), peaceful: 0,
                     m_lev_adj: (i == 1) && 3 || 0 });
    }
    // these are not such a big deal
    // to run into outside the bars
    for (let i = 1, __end_i = (rn2((19) - (10) + 1) + (10)); i <= __end_i; i++) {
       if (percent(90)) {
          await des.monster({ id: "hill orc", peaceful: 0 });
       } else {
          await des.monster({ id: "goblin", peaceful: 0 });
       }
    }
 
    // Hack to force full-level wallification
 
    des.wallify();
 
 
    return des.finalize_level();
}