All files / js/levels medusa-1.js

100% Statements 136/136
100% Branches 7/7
100% Functions 2/2
100% Lines 136/136

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 1372x 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 1x 1x 2x 1x 1x 2x 1x 1x 2x 1x 1x 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  
/**
 * medusa-1 - NetHack special level
 * Converted from: medusa-1.lua
 */
 
import * as des from '../sp_lev.js';
import { selection, percent } from '../sp_lev.js';
 
export async function generate() {
    // NetHack medusa medusa-1.lua	$NHDT-Date: 1652196027 2022/5/10 15:20:27 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.4 $
    // Copyright (c) 1989 by Jean-Christophe Collet
    // Copyright (c) 1990, 1991 by M. Stephenson
    // NetHack may be freely redistributed.  See license for details.
    // 
    // 
    // These are the Medusa's levels :
    // 
 
    des.level_init({ style: "solidfill", fg: " " });
 
    des.level_flags("mazelevel", "noteleport");
 
    await des.map(`\
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}.}}}}}..}}}}}......}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}....}}}...}}}}}
}...}}.....}}}}}....}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}...............}
}....}}}}}}}}}}....}}}..}}}}}}}}}}}.......}}}}}}}}}}}}}}}}..}}.....}}}...}}
}....}}}}}}}}.....}}}}..}}}}}}.................}}}}}}}}}}}.}}}}.....}}...}}
}....}}}}}}}}}}}}.}}}}.}}}}}}.-----------------.}}}}}}}}}}}}}}}}}.........}
}....}}}}}}}}}}}}}}}}}}.}}}...|...............S...}}}}}}}}}}}}}}}}}}}....}}
}.....}.}}....}}}}}}}}}.}}....--------+--------....}}}}}}..}}}}}}}}}}}...}}
}......}}}}..}}}}}}}}}}}}}........|.......|........}}}}}....}}}}}}}}}}}}}}}
}.....}}}}}}}}}}}}}}}}}}}}........|.......|........}}}}}...}}}}}}}}}.}}}}}}
}.....}}}}}}}}}}}}}}}}}}}}....--------+--------....}}}}}}.}.}}}}}}}}}}}}}}}
}......}}}}}}}}}}}}}}}}}}}}...S...............|...}}}}}}}}}}}}}}}}}.}}}}}}}
}.......}}}}}}}..}}}}}}}}}}}}.-----------------.}}}}}}}}}}}}}}}}}....}}}}}}
}........}}.}}....}}}}}}}}}}}}.................}}}}}..}}}}}}}}}.......}}}}}
}.......}}}}}}}......}}}}}}}}}}}}}}.......}}}}}}}}}.....}}}}}}...}}..}}}}}}
}.....}}}}}}}}}}}.....}}}}}}}}}}}}}}}}}}}}}}.}}}}}}}..}}}}}}}}}}....}}}}}}}
}}..}}}}}}}}}}}}}....}}}}}}}}}}}}}}}}}}}}}}...}}..}}}}}}}.}}.}}}}..}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
`);
    // Dungeon Description
    await des.region(selection.area(0,0,74,19),"lit");
    await des.region(selection.area(31,7,45,7),"unlit");
    // make the downstairs room a real room to control arriving monsters, 
    // and also as a fixup_special hack; the first room defined on Medusa's level
    // receives some statues
    await des.region({ region: [35,9, 41,10], lit: 0, type: "ordinary", arrival_room: true });
    await des.region(selection.area(31,12,45,12),"unlit");
    // Teleport: down to up stairs island, up to Medusa's island
    des.teleport_region({ region: [1,1,5,17], dir: "down" });
    des.teleport_region({ region: [26,4,50,15], dir: "up" });
    // Stairs
    des.stair("up", 5,14);
    des.stair("down", 36,10);
    // Doors
    des.door("closed",46,7);
    des.door("locked",38,8);
    des.door("locked",38,11);
    des.door("closed",30,12);
    // Branch, not allowed inside Medusa's building.
    des.levregion({ region: [1,0,79,20], exclude: [30,6,46,13], type: "branch" });
    // Non diggable walls
    des.non_diggable(selection.area(30,6,46,13));
    // Objects
    await des.object({ id: "statue", x: 36,y: 10, 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");
                    }
                 }
    });
 
    // Specifying explicit contents forces them to be empty.
    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 });
    await des.object({ id: "statue", contents: 0 });
    await des.object();
    await des.object();
    await des.object();
    await des.object();
    await des.object();
    await des.object();
    await des.object();
    await des.object();
    // Random traps
    await des.trap();
    await des.trap();
    await des.trap();
    await des.trap();
    await des.trap();
    await des.trap("board",38,7);
    await des.trap("board",38,12);
    // Random monsters
    await des.monster({ id: "Medusa", x: 36,y: 10, asleep: 1 });
    await des.monster("giant eel",11,6);
    await des.monster("giant eel",23,13);
    await des.monster("giant eel",29,2);
    await des.monster("jellyfish",2,2);
    await des.monster("jellyfish",0,8);
    await des.monster("jellyfish",4,18);
    await des.monster("water troll",51,3);
    await des.monster("water troll",64,11);
    await des.monster({ class: 'S', x: 38, y: 7 });
    await des.monster({ class: 'S', x: 38, y: 12 });
    await des.monster();
    await des.monster();
    await des.monster();
    await des.monster();
    await des.monster();
    await des.monster();
    await des.monster();
    await des.monster();
    await des.monster();
    await des.monster();
 
 
    return des.finalize_level();
}