All files / js/levels tower2.js

100% Statements 75/75
100% Branches 4/4
100% Functions 3/3
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  
/**
 * tower2 - NetHack special level
 * Converted from: tower2.lua
 */
 
import * as des from '../sp_lev.js';
import { selection, shuffle } from '../sp_lev.js';
 
export async function generate() {
    // NetHack tower tower2.lua	$NHDT-Date: 1652196037 2022/5/10 15:20:37 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.2 $
    // 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 = [ [3,1],[7,1],[11,1],[1,3],[13,3],
    	   [1,7],[13,7],[3,9],[7,9],[11,9] ]
    shuffle(place)
 
    des.ladder("up", 11,5);
    des.ladder("down", 3,7);
    des.door("locked",10,4);
    des.door("locked",9,7);
    await des.monster("&",place[9]);
    await des.monster("&",place[0]);
    await des.monster("hell hound pup",place[1]);
    await des.monster("hell hound pup",place[2]);
    await des.monster("winter wolf",place[3]);
    await des.object({ id: "chest", coord: place[4],
                 contents: async function() {
                    await des.object("amulet of life saving");
                 }
    });
    await des.object({ id: "chest", coord: place[5],
                 contents: async function() {
                    await des.object("amulet of strangulation");
                 }
    });
    await des.object("water walking boots",place[6]);
    await des.object("crystal plate mail",place[7]);
 
    let spbooks = [
       "spellbook of invisibility",
       "spellbook of cone of cold",
       "spellbook of create familiar",
       "spellbook of clairvoyance",
       "spellbook of charm monster",
       "spellbook of stone to flesh",
       "spellbook of polymorph"
    ]
    shuffle(spbooks);
    await des.object(spbooks[0],place[8]);
 
    // Walls in the tower are non diggable
    des.non_diggable(selection.area(0,0,14,10));
 
 
 
    return des.finalize_level();
}