All files / js/levels Bar-strt.js

100% Statements 112/112
100% Branches 4/4
100% Functions 2/2
100% Lines 112/112

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 1131x 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 1x 1x 1x 1x 1x 12x 12x 1x 1x 1x 1x  
/**
 * Bar-strt - NetHack special level
 * Converted from: Bar-strt.lua
 */
 
import * as des from '../sp_lev.js';
import { selection } from '../sp_lev.js';
 
export async function generate() {
    // NetHack Barbarian Bar-strt.lua	$NHDT-Date: 1652196001 2022/5/10 15:20:1 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.4 $
    // Copyright (c) 1989 by Jean-Christophe Collet
    // Copyright (c) 1991 by M. Stephenson
    // NetHack may be freely redistributed.  See license for details.
    // 
    // 
    // The "start" level for the quest.
    // 
    // Here you meet your (besieged) class leader, Pelias,
    // and receive your quest assignment.
    // 
    des.level_init({ style: "solidfill", fg: " " });
 
    des.level_flags("mazelevel", "noteleport", "hardfloor");
 
    await des.map(`\
..................................PP........................................
...................................PP.......................................
...................................PP.......................................
....................................PP......................................
........--------------......-----....PPP....................................
........|...S........|......+...|...PPP.....................................
........|----........|......|...|....PP.....................................
........|.\\..........+......-----...........................................
........|----........|...............PP.....................................
........|...S........|...-----.......PPP....................................
........--------------...+...|......PPPPP...................................
.........................|...|.......PPP....................................
...-----......-----......-----........PP....................................
...|...+......|...+..--+--.............PP...................................
...|...|......|...|..|...|..............PP..................................
...-----......-----..|...|.............PPPP.................................
.....................-----............PP..PP................................
.....................................PP...PP................................
....................................PP...PP.................................
....................................PP....PP................................
`);
 
    // the forest beyond the river
    des.replace_terrain({ region: [37,0, 59,19], fromterrain: ".", toterrain: "T", chance: 5 });
    des.replace_terrain({ region: [60,0, 64,19], fromterrain: ".", toterrain: "T", chance: 10 });
    des.replace_terrain({ region: [65,0, 75,19], fromterrain: ".", toterrain: "T", chance: 20 });
    // guarantee a path and free spot for the portal
    des.terrain(selection.randline(selection.new(), 37,7, 62,2, 7), ".");
    des.terrain([62,2], ".");
 
    // Dungeon Description
    await des.region(selection.area(0,0,75,19), "lit");
    await des.region(selection.area(9,5,11,5), "unlit");
    await des.region(selection.area(9,7,11,7), "lit");
    await des.region(selection.area(9,9,11,9), "unlit");
    await des.region(selection.area(13,5,20,9), "lit");
    await des.region(selection.area(29,5,31,6), "lit");
    await des.region(selection.area(26,10,28,11), "lit");
    await des.region(selection.area(4,13,6,14), "lit");
    await des.region(selection.area(15,13,17,14), "lit");
    await des.region(selection.area(22,14,24,15), "lit");
    // Stairs
    des.stair("down", 9,9);
    // Portal arrival point
    des.levregion({ region: [62,2,62,2], type: "branch" });
    // Doors
    des.door("locked",12,5);
    des.door("locked",12,9);
    des.door("closed",21,7);
    des.door("open",7,13);
    des.door("open",18,13);
    des.door("open",23,13);
    des.door("open",25,10);
    des.door("open",28,5);
    // Elder
    await des.monster({ id: "Pelias", coord: [10, 7], inventory: async function() {
       await des.object({ id: "runesword", spe: 5 });
       await des.object({ id: "chain mail", spe: 5 });
    } })
    // The treasure of Pelias
    await des.object("chest", 9, 5);
    // chieftain guards for the audience chamber
    await des.monster("chieftain", 10, 5);
    await des.monster("chieftain", 10, 9);
    await des.monster("chieftain", 11, 5);
    await des.monster("chieftain", 11, 9);
    await des.monster("chieftain", 14, 5);
    await des.monster("chieftain", 14, 9);
    await des.monster("chieftain", 16, 5);
    await des.monster("chieftain", 16, 9);
    // Non diggable walls
    des.non_diggable(selection.area(0,0,75,19));
    // One trap to keep the ogres at bay.
    await des.trap("spiked pit",37,7);
    // Eels in the river
    await des.monster("giant eel", 36, 1);
    await des.monster("giant eel", 37, 9);
    await des.monster("giant eel", 39, 15);
    // Monsters on siege duty.
    let ogrelocs = selection.floodfill(37,7).intersect(selection.area(40,3, 45,20))
    for (let i = 0, __end_i = 11; i <= __end_i; i++) {
       await des.monster({ id: "ogre", coord: ogrelocs.rndcoord(1), peaceful: 0 });
    }
 
 
    return des.finalize_level();
}