All files / js/levels tower1.js

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

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 892x 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  
/**
 * tower1 - NetHack special level
 * Converted from: tower1.lua
 */
 
import * as des from '../sp_lev.js';
import { selection, shuffle, nh } from '../sp_lev.js';
import { rn2 } from '../rng.js';
 
export async function generate() {
    // NetHack tower tower1.lua	$NHDT-Date: 1717178759 2024/5/31 18:5:59 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.3 $
    // Copyright (c) 1989 by Jean-Christophe Collet
    // NetHack may be freely redistributed.  See license for details.
    // 
    // 
    // Upper stage of Vlad's tower
    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---
  |.| |.| |.|  
  --- --- ---  
` });
 
    let niches = [ [3,1], [3,9], [7,1], [7,9], [11,1], [11,9] ];
    shuffle(niches);
 
    des.ladder("down", 11,5);
    // The lord and his court
    await des.monster("Vlad the Impaler", 6, 5);
    await des.monster("V",niches[0]);
    await des.monster("V",niches[1]);
    await des.monster("V",niches[2]);
    // The brides; they weren't named in Bram Stoker's original _Dracula_
    // and when appearing in umpteen subsequent books and movies there is
    // no consensus for their names.  According to the Wikipedia entry for
    // "Brides of Dracula", the "Czechoslovakian TV film Hrabe Drakula (1971)"
    // gave them titles rather than (or perhaps in addition to) specific names
    // and we use those titles here.  Marking them as 'waiting' forces them to
    // start in vampire form instead of vampshifted into bat/fog/wolf form.
    let Vgenod = nh.is_genocided("vampire");
    let Vnames = [ null, null, null ];
    if ((! Vgenod)) {
       Vnames = [ "Madame", "Marquise", "Countess" ];
    }
    await des.monster({ id: "vampire lady", coord: niches[3], name: Vnames[0], waiting: 1 });
    await des.monster({ id: "vampire lady", coord: niches[4], name: Vnames[1], waiting: 1 });
    await des.monster({ id: "vampire lady", coord: niches[5], name: Vnames[2], waiting: 1 });
    // The doors
    des.door("closed",8,3);
    des.door("closed",10,3);
    des.door("closed",3,4);
    des.door("locked",10,5);
    des.door("locked",8,7);
    des.door("locked",10,7);
    des.door("closed",3,6);
    // treasures
    await des.object("chest", 7,5);
 
    await des.object("chest",niches[5]);
    await des.object("chest",niches[0]);
    await des.object("chest",niches[1]);
    await des.object("chest",niches[2]);
    await des.object({ id: "chest", coord: niches[3],
                 contents: async function() {
                    await des.object({ id: "wax candle", quantity: (rn2((8) - (4) + 1) + (4)) });
                 }
    });
    await des.object({ id: "chest", coord: niches[4],
                 contents: async function() {
                    await des.object({ id: "tallow candle", quantity: (rn2((8) - (4) + 1) + (4)) });
                 }
    });
    // We have to protect the tower against outside attacks
    des.non_diggable(selection.area(0,0,14,10));
 
 
    return des.finalize_level();
}