All files / js/levels soko4-1.js

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

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 1131x 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 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  
/**
 * soko4-1 - NetHack special level
 * Converted from: soko4-1.lua
 */
 
import * as des from '../sp_lev.js';
import { selection } from '../sp_lev.js';
 
export async function generate() {
    // NetHack sokoban soko4-1.lua	$NHDT-Date: 1652196036 2022/5/10 15:20:36 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.2 $
    // Copyright (c) 1998-1999 by Kevin Hugo
    // NetHack may be freely redistributed.  See license for details.
    // 
    // 
    // In case you haven't played the game Sokoban, you'll learn
    // quickly.  This branch isn't particularly difficult, just time
    // consuming.  Some players may wish to skip this branch.
    // 
    // The following actions are currently permitted without penalty:
    // Carrying or throwing a boulder already in inventory
    // (player or nonplayer).
    // Teleporting boulders.
    // Digging in the floor.
    // The following actions are permitted, but with a luck penalty:
    // Breaking boulders.
    // Stone-to-fleshing boulders.
    // Creating new boulders (e.g., with a scroll of earth).
    // Jumping.
    // Being pulled by a thrown iron ball.
    // Hurtling through the air from Newton's 3rd law.
    // Squeezing past boulders when naked or as a giant.
    // These actions are not permitted:
    // Moving diagonally between two boulders and/or walls.
    // Pushing a boulder diagonally.
    // Picking up boulders (player or nonplayer).
    // Digging or walking through walls.
    // Teleporting within levels or between levels of this branch.
    // Using cursed potions of gain level.
    // Escaping a pit/hole (e.g., by flying, levitation, or
    // passing a dexterity check).
    // Bones files are not permitted.
 
 
    // ## Bottom (first) level of Sokoban ###
    des.level_init({ style: "solidfill", fg: " " });
 
    des.level_flags("mazelevel", "noteleport", "hardfloor", "premapped", "sokoban", "solidify");
 
    await des.map(`\
------  ----- 
|....|  |...| 
|....----...| 
|...........| 
|..|-|.|-|..| 
---------|.---
|......|.....|
|..----|.....|
--.|   |.....|
 |.|---|.....|
 |...........|
 |..|---------
 ----         
`);
    des.levregion({ region: [6,4,6,4], type: "branch" });
    des.stair("up", 6,6);
    await des.region(selection.area(0,0,13,12), "lit");
    des.non_diggable(selection.area(0,0,13,12));
    des.non_passwall(selection.area(0,0,13,12));
 
    // Boulders
    await des.object("boulder",2,2);
    await des.object("boulder",2,3);
    // 
    await des.object("boulder",10,2);
    await des.object("boulder",9,3);
    await des.object("boulder",10,4);
    // 
    await des.object("boulder",8,7);
    await des.object("boulder",9,8);
    await des.object("boulder",9,9);
    await des.object("boulder",8,10);
    await des.object("boulder",10,10);
 
    // prevent monster generation over the (filled) pits
    des.exclusion({ type: "monster-generation", region: [ 1,6, 7,11 ] });
    // Traps
    await des.trap("pit",3,6);
    await des.trap("pit",4,6);
    await des.trap("pit",5,6);
    await des.trap("pit",2,8);
    await des.trap("pit",2,9);
    await des.trap("pit",4,10);
    await des.trap("pit",5,10);
    await des.trap("pit",6,10);
    await des.trap("pit",7,10);
 
    // A little help
    await des.object("scroll of earth",2,11);
    await des.object("scroll of earth",3,11);
 
    // 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: "/" });
 
 
 
    return des.finalize_level();
}