All files / js/levels medusa-2.js

98.59% Statements 140/142
83.33% Branches 5/6
100% Functions 2/2
98.59% Lines 140/142

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 1434x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x     4x 4x 4x 4x 3x 3x 4x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x  
/**
 * medusa-2 - NetHack special level
 * Converted from: medusa-2.lua
 */
 
import * as des from '../sp_lev.js';
import { selection, percent } from '../sp_lev.js';
 
export async function generate() {
    // NetHack medusa medusa-2.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.
    // 
    des.level_init({ style: "solidfill", fg: " " });
 
    des.level_flags("mazelevel", "noteleport");
 
    await des.map(`\
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}------}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}-------}}}}}}}}--------------}
}|....|}}}}}}}}}..}.}}..}}}}}}}}}}}}}..}}}}}}-.....--}}}}}}}|............|}
}|....|.}}}}}}}}}}}.}...}}..}}}}}}}}}}}}}}}}}---......}}}}}.|............|}
}S....|.}}}}}}---}}}}}}}}}}}}}}}}}}}}}}}}}}---...|..-}}}}}}.S..----------|}
}|....|.}}}}}}-...}}}}}}}}}.}}...}.}}}}.}}}......----}}}}}}.|............|}
}|....|.}}}}}}-....--}}}}}}}}}}}}}}}}}}}}}}----...--}}}}}}}.|..--------+-|}
}|....|.}}}}}}}......}}}}...}}}}}}.}}}}}}}}}}}---..---}}}}}.|..|..S...|..|}
}|....|.}}}}}}-....-}}}}}}}------}}}}}}}}}}}}}}-...|.-}}}}}.|..|..|...|..|}
}|....|.}}}}}}}}}---}}}}}}}........}}}}}}}}}}---.|....}}}}}.|..|..|...|..|}
}|....|.}}}}}}}}}}}}}}}}}}-....|...-}}}}}}}}--...----.}}}}}.|..|..|...|..|}
}|....|.}}}}}}..}}}}}}}}}}---..--------}}}}}-..---}}}}}}}}}.|..|..-------|}
}|...}|...}}}.}}}}}}...}}}}}--..........}}}}..--}}}}}}}}}}}.|..|.........|}
}|...}S...}}.}}}}}}}}}}}}}}}-..--------}}}}}}}}}}}}}}...}}}.|..--------..S}
}|...}|...}}}}}}}..}}}}}}----..|....-}}}}}}}}}}}}}}}}}..}}}.|............|}
}|....|}}}}}....}}}}..}}.-.......----}}......}}}}}}.......}}|............|}
}------}}}}}}}}}}}}}}}}}}---------}}}}}}}}}}}}}}}}}}}}}}}}}}--------------}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
`);
    // Dungeon Description
    await des.region(selection.area(0,0,74,19),"lit");
    await des.region(selection.area(2,3,5,16),"unlit");
    // fixup_special hack: the first room defined on a Medusa level gets some
    // leaderboard statues; setting the region as irregular makes it a room
    await des.region({ region: [61,3, 72,16], lit: 0, type: "ordinary",irregular: 1 });
    await des.region(selection.area(71,8,72,11),"unlit");
    // make the downstairs area a real room to control arriving monsters
    await des.region({ region: [67,8,69,11], lit: 1, type: "ordinary", arrival_room: true });
    // Teleport: down to up stairs island, up to Medusa's island
    des.teleport_region({ region: [2,3,5,16], dir: "down" });
    des.teleport_region({ region: [61,3,72,16], dir: "up" });
    // Stairs
    des.stair("up", 4,9);
    des.stair("down", 68,10);
    // Doors
    des.door("locked", 71,7);
    // Branch, not allowed on Medusa's island.
    des.levregion({ type: "branch", region: [1,0,79,20], exclude: [59,1,73,17] });
    // Non diggable walls
    des.non_diggable(selection.area(1,2,6,17));
    des.non_diggable(selection.area(60,2,73,17));
    // Objects
    await des.object({ id: "statue", x: 68,y: 10,buc: "uncursed",
                          montype: "knight", historic: 1, male: 1,name: "Perseus",
                          contents: async function() {
                             if (percent(25)) {
                                await des.object({ id: "shield of reflection", buc: "cursed", spe: 0 });
                             }
                             if (percent(75)) {
                                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");
                             }
                          }
    });
    await des.object({ id: "statue", x: 64, y: 8, contents: 0 });
    await des.object({ id: "statue", x: 65, y: 8, contents: 0 });
    await des.object({ id: "statue", x: 64, y: 9, contents: 0 });
    await des.object({ id: "statue", x: 65, y: 9, contents: 0 });
    await des.object({ id: "statue", x: 64, y: 10, contents: 0 });
    await des.object({ id: "statue", x: 65, y: 10, contents: 0 });
    await des.object({ id: "statue", x: 64, y: 11, contents: 0 });
    await des.object({ id: "statue", x: 65, y: 11, contents: 0 });
    await des.object("boulder",4,4);
    await des.object("/",52,9);
    await des.object("boulder",52,9);
    await des.object();
    await des.object();
    await des.object();
    await des.object();
    await des.object();
    await des.object();
    // Traps
    await des.trap("magic",3,12);
    await des.trap();
    await des.trap();
    await des.trap();
    await des.trap();
    // Monsters.
    await des.monster({ id: "Medusa",x: 68,y: 10,asleep: 1 });
    await des.monster("gremlin",2,14);
    await des.monster("titan",2,5);
    await des.monster("electric eel",10,13);
    await des.monster("electric eel",11,13);
    await des.monster("electric eel",10,14);
    await des.monster("electric eel",11,14);
    await des.monster("electric eel",10,15);
    await des.monster("electric eel",11,15);
    await des.monster("jellyfish",1,1);
    await des.monster("jellyfish",0,8);
    await des.monster("jellyfish",4,19);
    await des.monster({ id: "stone golem",x: 64,y: 8,asleep: 1 });
    await des.monster({ id: "stone golem",x: 65,y: 8,asleep: 1 });
    await des.monster({ id: "stone golem",x: 64,y: 9,asleep: 1 });
    await des.monster({ id: "stone golem",x: 65,y: 9,asleep: 1 });
    await des.monster({ id: "cobra",x: 64,y: 10,asleep: 1 });
    await des.monster({ id: "cobra",x: 65,y: 10,asleep: 1 });
    await des.monster("A",72,8);
    await des.monster({ id: "yellow light",x: 72,y: 11,asleep: 1 });
    await des.monster({ x: 17, y: 7 });
    await des.monster({ x: 28, y: 11 });
    await des.monster({ x: 32, y: 13 });
    await des.monster({ x: 49, y: 9 });
    await des.monster({ x: 48, y: 7 });
    await des.monster({ x: 65, y: 3 });
    await des.monster({ x: 70, y: 4 });
    await des.monster({ x: 70, y: 15 });
    await des.monster({ x: 65, y: 16 });
    await des.monster();
    await des.monster();
    await des.monster();
    await des.monster();
 
 
 
    return des.finalize_level();
}