All files / js/levels soko1-2.js

98.4% Statements 123/125
66.66% Branches 2/3
100% Functions 1/1
98.4% Lines 123/125

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 117 118 119 120 121 122 123 124 125 1263x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x     3x 3x 3x 3x 3x 3x 3x 3x 3x 3x  
/**
 * soko1-2 - NetHack special level
 * Converted from: soko1-2.lua
 */
 
import * as des from '../sp_lev.js';
import { selection, percent } from '../sp_lev.js';
 
export async function generate() {
    // NetHack sokoban soko1-2.lua	$NHDT-Date: 1652196034 2022/5/10 15:20:34 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.6 $
    // Copyright (c) 1998-1999 by Kevin Hugo
    // NetHack may be freely redistributed.  See license for details.
    // 
    des.level_init({ style: "solidfill", fg: " " });
 
    des.level_flags("mazelevel", "noteleport", "premapped", "sokoban", "solidify");
 
    await des.map(`\
  ------------------------
  |......................|
  |..-------------------.|
----.|    -----        |.|
|..|.--  --...|        |.|
|.....|--|....|        |.|
|.....|..|....|        |.|
--....|......--        |.|
 |.......|...|   ------|.|
 |....|..|...| --|.....|.|
 |....|--|...| |.+.....|.|
 |.......|..-- |-|.....|.|
 ----....|.--  |.+.....+.|
    ---.--.|   |-|.....|--
     |.....|   |.+.....|  
     |..|..|   --|.....|  
     -------     -------  
`);
 
    let place = selection.new();
    place.set(16,10);
    place.set(16,12);
    place.set(16,14);
 
    des.stair("down", 6,15);
    await des.region(selection.area(0,0,25,16),"lit");
    des.non_diggable(selection.area(0,0,25,16));
    des.non_passwall(selection.area(0,0,25,16));
 
    // Boulders
    await des.object("boulder",4,4);
    await des.object("boulder",2,6);
    await des.object("boulder",3,6);
    await des.object("boulder",4,7);
    await des.object("boulder",5,7);
    await des.object("boulder",2,8);
    await des.object("boulder",5,8);
    await des.object("boulder",3,9);
    await des.object("boulder",4,9);
    await des.object("boulder",3,10);
    await des.object("boulder",5,10);
    await des.object("boulder",6,12);
    // 
    await des.object("boulder",7,14);
    // 
    await des.object("boulder",11,5);
    await des.object("boulder",12,6);
    await des.object("boulder",10,7);
    await des.object("boulder",11,7);
    await des.object("boulder",10,8);
    await des.object("boulder",12,9);
    await des.object("boulder",11,10);
 
    // prevent monster generation over the (filled) holes
    des.exclusion({ type: "monster-generation", region: [ 5,1, 22,1 ] });
    // Traps
    await des.trap("hole",5,1);
    await des.trap("hole",6,1);
    await des.trap("hole",7,1);
    await des.trap("hole",8,1);
    await des.trap("hole",9,1);
    await des.trap("hole",10,1);
    await des.trap("hole",11,1);
    await des.trap("hole",12,1);
    await des.trap("hole",13,1);
    await des.trap("hole",14,1);
    await des.trap("hole",15,1);
    await des.trap("hole",16,1);
    await des.trap("hole",17,1);
    await des.trap("hole",18,1);
    await des.trap("hole",19,1);
    await des.trap("hole",20,1);
    await des.trap("hole",21,1);
    await des.trap("hole",22,1);
 
    await des.monster({ id: "giant mimic", appear_as: "obj:boulder" });
    await des.monster({ id: "giant mimic", appear_as: "obj:boulder" });
 
    // Random objects
    await des.object({ class: "%" });
    await des.object({ class: "%" });
    await des.object({ class: "%" });
    await des.object({ class: "%" });
    await des.object({ class: "=" });
    await des.object({ class: "/" });
 
    // Rewards
    des.door("locked",23,12);
    des.door("closed",17,10);
    des.door("closed",17,12);
    des.door("closed",17,14);
    await des.region({ region: [18,9, 22,15], lit: 1, type: "zoo", filled: 1, irregular: 1 });
 
    let pt = selection.rndcoord(place);
    if (percent(25)) {
       await des.object({ id: "bag of holding", coord: pt,
    		buc: "not-cursed", achievement: 1 });
    } else {
       await des.object({ id: "amulet of reflection", coord: pt,
    		buc: "not-cursed", achievement: 1 });
    }
    des.engraving({ coord: pt, type: "burn", text: "Elbereth" });
    await des.object({ id: "scroll of scare monster", coord: pt, buc: "cursed" });
 
 
    return des.finalize_level();
}