All files / js/levels medusa-4.js

98.78% Statements 163/165
93.33% Branches 14/15
100% Functions 2/2
98.78% Lines 163/165

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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 1665x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 4x 4x 5x 2x 2x 5x 1x 1x 5x 2x 2x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 40x 40x 5x 5x 35x 35x 5x 5x 5x 5x 5x 5x 5x 5x 5x 2x 2x 5x 4x 4x 5x 5x 3x 3x 5x     5x 5x 5x 5x 5x 5x 70x 70x 5x 20x 20x 20x 5x 5x 5x 5x 5x 5x  
/**
 * medusa-4 - NetHack special level
 * Converted from: medusa-4.lua
 */
 
import * as des from '../sp_lev.js';
import { selection, percent } from '../sp_lev.js';
 
export async function generate() {
    // NetHack medusa medusa-4.lua	$NHDT-Date: 1716152274 2024/5/19 20:57:54 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.8 $
    // Copyright (c) 1989 by Jean-Christophe Collet
    // Copyright (c) 1990, 1991 by M. Stephenson
    // NetHack may be freely redistributed.  See license for details.
    // 
    des.level_init({ style: "solidfill", fg: " " });
    des.level_flags("noteleport", "mazelevel");
    // 
    // Here the Medusa rules some slithery monsters from her 'palace', with
    // a yellow dragon nesting in the backyard.
    // 
    await des.map(`\
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}........}}}}}}}}}}}}}}}}}}}}}}}..}}}.....}}}}}}}}}}}----|}}}}}
}}}}}}..----------F-.....}}}}}}}}}}}}}}}}..---...}}}}....T.}}}}}}}....|}}}}}
}}}.....|...F......S}}}}....}}}}}}}...}}.....|}}.}}}}}}}......}}}}|......}}}
}}}.....+...|..{...|}}}}}}}}}}}}.....}}}}|...|}}}}}}}}}}}.}}}}}}}}----.}}}}}
}}......|...|......|}}}}}}}}}......}}}}}}|.......}}}}}}}}}}}}}..}}}}}...}}}}
}}|-+--F|-+--....|F|-|}}}}}....}}}....}}}-----}}.....}}}}}}}......}}}}.}}}}}
}}|...}}|...|....|}}}|}}}}}}}..}}}}}}}}}}}}}}}}}}}}....}}}}}}}}....T.}}}}}}}
}}|...}}F...+....F}}}}}}}..}}}}}}}}}}}}}}...}}}}}}}}}}}}}}}}}}}}}}....}}..}}
}}|...}}|...|....|}}}|}....}}}}}}....}}}...}}}}}...}}}}}}}}}}}}}}}}}.....}}}
}}--+--F|-+--....-F|-|....}}}}}}}}}}.T...}}}}....---}}}}}}}}}}}}}}}}}}}}}}}}
}}......|...|......|}}}}}.}}}}}}}}}....}}}}}}}.....|}}}}}}}}}.}}}}}}}}}}}}}}
}}}}....+...|..{...|.}}}}}}}}}}}}}}}}}}}}}}}}}}.|..|}}}}}}}......}}}}...}}}}
}}}}}}..|...F......|...}}}}}}}}}}..---}}}}}}}}}}--.-}}}}}....}}}}}}....}}}}}
}}}}}}}}-----S----F|....}}}}}}}}}|...|}}}}}}}}}}}}...}}}}}}...}}}}}}..}}}}}}
}}}}}}}}}..............T...}}}}}.|.......}}}}}}}}}}}}}}..}...}.}}}}....}}}}}
}}}}}}}}}}....}}}}...}...}}}}}.......|.}}}}}}}}}}}}}}.......}}}}}}}}}...}}}}
}}}}}}}}}}..}}}}}}}}}}.}}}}}}}}}}-..--.}}}}}}}}..}}}}}}..T...}}}..}}}}}}}}}}
}}}}}}}}}...}}}}}}}}}}}}}}}}}}}}}}}...}}}}}}}....}}}}}}}.}}}..}}}...}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}.}}}}}}....}}}}}}}}}}}}}}}}}}}...}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
`);
 
    // 
    // place handling is similar to medusa-3.lua except that there are 4
    // downstairs-eligible rooms rather than 3, and only 2 of them are used
    let place = selection.new();
    // each of these spots are inside a distinct room
    place.set(4,8);
    place.set(10,4);
    place.set(10,8);
    place.set(10,12);
 
    // location of Medusa and downstairs and Perseus's statue
    let medloc = place.rndcoord(1,1);
    // specific location for some other statue in a different downstairs-eligible
    // room, to prevent object detection from becoming a trivial way to pinpoint
    // Medusa's location
    // [usefulness depends on future STATUE->dknown changes in nethack's core]
    let altloc = place.rndcoord(1,1);
 
    // 
    await des.region(selection.area(0,0,74,19),"lit");
    // fixup_special hack: The first "room" region in Medusa levels gets filled
    // with some leaderboard statues, so this needs to be a room; setting
    // irregular=1 will force this
    await des.region({ region: [13,3, 18,13], lit: 1, type: "ordinary", irregular: 1 });
    // 
    des.teleport_region({ region: [64,1,74,17], dir: "down" });
    des.teleport_region({ region: [2,2,18,13], dir: "up" });
    // 
    des.levregion({ region: [67,1,74,20], type: "stair-up" });
 
    // place the downstairs at the same spot where Medusa will be placed
    des.stair("down", medloc);
    // 
    des.door("locked",4,6);
    des.door("locked",4,10);
    des.door("locked",8,4);
    des.door("locked",8,12);
    des.door("locked",10,6);
    des.door("locked",10,10);
    des.door("locked",12,8);
    // 
    des.levregion({ region: [27,0,79,20], type: "branch" });
    // 
    des.non_diggable(selection.area(1,1,22,14));
    // 
    await des.object("crystal ball", 7,8);
    // 
    // same spot as Medusa plus downstairs
    await des.object({ id: "statue", coord: medloc, buc: "uncursed",
                          montype: "knight", historic: 1, male: 1,name: "Perseus",
                          contents: async function() {
                             if (percent(75)) {
                                await des.object({ id: "shield of reflection", buc: "cursed", spe: 0 });
                             }
                             if (percent(25)) {
                                await des.object({ id: "levitation boots", spe: 0 });
                             }
                             if (percent(50)) {
                                await des.object({ id: "scimitar", buc: "blessed", spe: 2 });
                             }
                             if (percent(50)) {
                                await des.object("sack");
                             }
                          }
    });
    // 
    // first random statue is in one of the designated stair rooms but not the
    // one with Medusa plus downstairs
    await des.object({ id: "statue", coord: altloc, contents: 0 });
    await des.object({ id: "statue", contents: 0 });
    await des.object({ id: "statue", contents: 0 });
    await des.object({ id: "statue", contents: 0 });
    await des.object({ id: "statue", contents: 0 });
    await des.object({ id: "statue", contents: 0 });
    await des.object({ id: "statue", contents: 0 });
    for (let i = 1, __end_i = 8; i <= __end_i; i++) {
       await des.object();
    }
    // 
    for (let i = 1, __end_i = 7; i <= __end_i; i++) {
       await des.trap();
    }
    // 
    // place Medusa before placing other monsters so that they won't be able to
    // unintentionally steal her spot on the downstairs
    await des.monster({ id: "Medusa", coord: medloc, asleep: 1 });
    await des.monster("kraken", 7,7);
    // 
    // the nesting dragon
    await des.monster({ id: "yellow dragon", x: 5, y: 4, asleep: 1 });
    if (percent(50)) {
       await des.monster({ id: "baby yellow dragon", x: 4,y: 4, asleep: 1 });
    }
    if (percent(25)) {
       await des.monster({ id: "baby yellow dragon", x: 4, y: 5, asleep: 1 });
    }
    await des.object({ id: "egg", x: 5, y: 4, montype: "yellow dragon" });
    if (percent(50)) {
       await des.object({ id: "egg", x: 5, y: 4, montype: "yellow dragon" });
    }
    if (percent(25)) {
       await des.object({ id: "egg", x: 5, y: 4, montype: "yellow dragon" });
    }
    // 
    await des.monster("giant eel");
    await des.monster("giant eel");
    await des.monster("jellyfish");
    await des.monster("jellyfish");
    for (let i = 1, __end_i = 14; i <= __end_i; i++) {
       await des.monster("S");
    }
    for (let i = 1, __end_i = 4; i <= __end_i; i++) {
       await des.monster("black naga hatchling");
       await des.monster("black naga");
    }
 
    // medusa.length-4.lua
 
 
    return des.finalize_level();
}