All files / js/levels wizard1.js

100% Statements 116/116
100% Branches 4/4
100% Functions 3/3
100% Lines 116/116

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 1172x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x  
/**
 * wizard1 - NetHack special level
 * Converted from: wizard1.lua
 */
 
import * as des from '../sp_lev.js';
import { selection, hell_tweaks } from '../sp_lev.js';
import { rn2 } from '../rng.js';
 
export async function generate() {
    // NetHack yendor wizard1.lua	$NHDT-Date: 1652196039 2022/5/10 15:20:39 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.3 $
    // Copyright (c) 1989 by Jean-Christophe Collet
    // Copyright (c) 1992 by M. Stephenson and Izchak Miller
    // NetHack may be freely redistributed.  See license for details.
    // 
    // 
    // The top (real) wizard level.
    // Keeping the Moat for old-time's sake
    des.level_init({ style: "mazegrid", bg: "-" });
 
    des.level_flags("mazelevel", "noteleport", "hardfloor");
 
    let tmpbounds = selection.match("-");
    let bnds = tmpbounds.bounds();
    let bounds2 = selection.fillrect(bnds.lx, bnds.ly + 1, bnds.hx - 2, bnds.hy - 1);
 
    let wiz1 = await des.map({ halign: "center", valign: "center", map: `\
----------------------------x
|.......|..|.........|.....|x
|.......S..|.}}}}}}}.|.....|x
|..--S--|..|.}}---}}.|---S-|x
|..|....|..|.}--.--}.|..|..|x
|..|....|..|.}|...|}.|..|..|x
|..--------|.}--.--}.|..|..|x
|..|.......|.}}---}}.|..|..|x
|..S.......|.}}}}}}}.|..|..|x
|..|.......|.........|..|..|x
|..|.......|-----------S-S-|x
|..|.......S...............|x
----------------------------x
`, contents: async function(rm) {
       des.levregion({ type: "stair-up", region: [1,0,79,20], region_islev: 1, exclude: [0,0,28,12] });
       des.levregion({ type: "stair-down", region: [1,0,79,20], region_islev: 1, exclude: [0,0,28,12] });
       des.levregion({ type: "branch", region: [1,0,79,20], region_islev: 1, exclude: [0,0,28,12] });
       des.teleport_region({ region: [1,0,79,20], region_islev: 1, exclude: [0,0,27,12] });
       await des.region({ region: [12,1, 20,9], lit: 0, type: "morgue", filled: 2, contents: async function() {
                       let sdwall = [ "south", "west", "east" ];
                       des.door({ wall: sdwall[rn2(sdwall.length)], state: "secret" });
       } })
       // another region to constrain monster arrival
       await des.region({ region: [1,1, 10,11], lit: 0, type: "ordinary", arrival_room: true });
       await des.mazewalk(28,5,"east");
       des.ladder("down", 6,5);
       // Non diggable walls
       // Walls inside the moat stay diggable
       des.non_diggable(selection.area(0,0,11,12));
       des.non_diggable(selection.area(11,0,21,0));
       des.non_diggable(selection.area(11,10,27,12));
       des.non_diggable(selection.area(21,0,27,10));
       // Non passable walls
       des.non_passwall(selection.area(0,0,11,12));
       des.non_passwall(selection.area(11,0,21,0));
       des.non_passwall(selection.area(11,10,27,12));
       des.non_passwall(selection.area(21,0,27,10));
       // The wizard and his guards
       await des.monster({ id: "Wizard of Yendor", x: 16, y: 5, asleep: 1 });
       await des.monster("hell hound", 15, 5);
       await des.monster("vampire lord", 17, 5);
       // The let treasure
       await des.object("Book of the Dead", 16, 5);
       // Surrounding terror
       await des.monster("kraken", 14, 2);
       await des.monster("giant eel", 17, 2);
       await des.monster("kraken", 13, 4);
       await des.monster("giant eel", 13, 6);
       await des.monster("kraken", 19, 4);
       await des.monster("giant eel", 19, 6);
       await des.monster("kraken", 15, 8);
       await des.monster("giant eel", 17, 8);
       await des.monster("piranha", 15, 2);
       await des.monster("piranha", 19, 8);
       // Random monsters
       await des.monster("D");
       await des.monster("H");
       await des.monster("&");
       await des.monster("&");
       await des.monster("&");
       await des.monster("&");
       // And to make things a little harder.
       await des.trap("board",16,4);
       await des.trap("board",16,6);
       await des.trap("board",15,5);
       await des.trap("board",17,5);
       // Random traps.
       await des.trap("spiked pit");
       await des.trap("sleep gas");
       await des.trap("anti magic");
       await des.trap("magic");
       // Some random loot.
       await des.object("ruby");
       await des.object("!");
       await des.object("!");
       await des.object("?");
       await des.object("?");
       await des.object("+");
       await des.object("+");
       await des.object("+");
    }
    });
 
    let protected_region = bounds2.negate().union(wiz1);
    await hell_tweaks(protected_region);
 
 
    return des.finalize_level();
}