All files / js/levels wizard2.js

100% Statements 75/75
100% Branches 3/3
100% Functions 2/2
100% Lines 75/75

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 761x 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  
/**
 * wizard2 - NetHack special level
 * Converted from: wizard2.lua
 */
 
import * as des from '../sp_lev.js';
import { selection, hell_tweaks } from '../sp_lev.js';
 
export async function generate() {
    // NetHack yendor wizard2.lua	$NHDT-Date: 1652196039 2022/5/10 15:20:39 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.2 $
    // 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.
    // 
    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 wiz2 = await des.map({ halign: "center", valign: "center", map: `\
----------------------------x
|.....|.S....|.............|x
|.....|.-------S--------S--|x
|.....|.|.........|........|x
|..-S--S|.........|........|x
|..|....|.........|------S-|x
|..|....|.........|.....|..|x
|-S-----|.........|.....|..|x
|.......|.........|S--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] });
       // entire tower in a region, constrains monster migration
       await des.region({ region: [1,1, 26,11], lit: 0, type: "ordinary", arrival_room: true });
       await des.region({ region: [9,3, 17,9], lit: 0, type: "zoo", filled: 1 });
       des.door("closed",15,2);
       des.door("closed",11,10);
       await des.mazewalk(28,5,"east");
       des.ladder("up", 12,1);
       des.ladder("down", 14,11);
       // Non diggable walls everywhere
       des.non_diggable(selection.area(0,0,27,12));
       // 
       des.non_passwall(selection.area(0,0,27,12));
       // 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("!");
       await des.object("!");
       await des.object("?");
       await des.object("?");
       await des.object("+");
       // treasures
       await des.object("\"", 4, 6);
    }
    });
 
    let protected_region = bounds2.negate().union(wiz2);
    await hell_tweaks(protected_region);
 
 
    return des.finalize_level();
}