All files / js/levels tower3.js

100% Statements 63/63
100% Branches 2/2
100% Functions 1/1
100% Lines 63/63

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 641x 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  
/**
 * tower3 - NetHack special level
 * Converted from: tower3.lua
 */
 
import * as des from '../sp_lev.js';
import { selection } from '../sp_lev.js';
 
export async function generate() {
    // NetHack tower tower3.lua	$NHDT-Date: 1652196038 2022/5/10 15:20:38 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1 $
    // Copyright (c) 1989 by Jean-Christophe Collet
    // NetHack may be freely redistributed.  See license for details.
    // 
    des.level_init({ style: "solidfill", fg: " " });
 
    des.level_flags("mazelevel", "noteleport", "hardfloor", "solidify");
    await des.map({ halign: "half-left", valign: "center", map: `\
    --- --- ---    
    |.| |.| |.|    
  ---S---S---S---  
  |.S.........S.|  
-----.........-----
|...|.........+...|
|.---.........---.|
|.|.S.........S.|.|
|.---S---S---S---.|
|...|.|.|.|.|.|...|
---.---.---.---.---
  |.............|  
  ---------------  
` });
    // Random places are the 10 niches
    let place = [ [5,1],[9,1],[13,1],[3,3],[15,3],
    	   [3,7],[15,7],[5,9],[9,9],[13,9] ]
 
    des.levregion({ type: "branch", region: [2,5,2,5] });
    des.ladder("up", 5,7);
    // Entry door is, of course, locked
    des.door("locked",14,5);
    // Let's put a dragon behind the door, just for the fun...
    await des.monster("D", 13, 5);
    await des.monster({ x: 12, y: 4 });
    await des.monster({ x: 12, y: 6 });
    await des.monster();
    await des.monster();
    await des.monster();
    await des.monster();
    await des.monster();
    await des.monster();
    await des.object("long sword",place[3]);
    await des.trap({ coord: place[3] });
    await des.object("lock pick",place[0]);
    await des.trap({ coord: place[0] });
    await des.object("elven cloak",place[1]);
    await des.trap({ coord: place[1] });
    await des.object("blindfold",place[2]);
    await des.trap({ coord: place[2] });
    // Walls in the tower are non diggable
    des.non_diggable(selection.area(0,0,18,12));
 
 
    return des.finalize_level();
}