File size: 1,778 Bytes
87b3b3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#BEGIN_PROPERTIES#
{
    "version": "0.1",
    "commandsIntroduced": []
}
#END_PROPERTIES#
/******************
 *  threeKeys.js  *
 * by paulcdejean *
 ******************
 * Here's the first non trivial level I was able to think of.
 * You can beat this without overwriting functions or any other
 * funny business so try and stay honest!
 */

function startLevel(map) {
#START_OF_START_LEVEL#
    map.placePlayer(7, 5);

    // The basic level layout.
    for (var y = 0; y <= map.getHeight(); y++) {
        map.placeObject(16, y, 'block');
        map.placeObject(32, y, 'block');
    }

    for (var x = 17; x <= 31; x++) {
        map.placeObject(x, 7, 'block');
        map.placeObject(x, 17, 'block');
    }

    map.placeObject(24, 3, 'redKey');
    map.placeObject(24, 12, 'greenKey');
    map.placeObject(24, 21, 'blueKey');

    map.placeObject(map.getWidth()-7, map.getHeight()-5, 'exit');

#BEGIN_EDITABLE#
    // You might find this useful.
    map.placeObject(8, 6, 'phone');
#END_EDITABLE#
#END_OF_START_LEVEL#
}

function validateLevel(map) {
    // No creating exits!
    map.validateExactlyXManyObjects(1, 'exit');

    // No cheating please!
    map.validateExactlyXManyObjects(0, 'theAlgorithm');

    // You need to pick up the keys, not create them.
    map.validateAtMostXObjects(1, 'redKey');
    map.validateAtMostXObjects(1, 'greenKey');
    map.validateAtMostXObjects(1, 'blueKey');

    // This is the puzzle :)
    map.validateAtMostXDynamicObjects(3);
}


function onExit(map) {
    if (!map.getPlayer().hasItem('redKey')
        || !map.getPlayer().hasItem('greenKey')
        || !map.getPlayer().hasItem('blueKey')) {
        map.writeStatus("Collect all 3 keys before exiting!");
        return false;
    } else {
        return true;
    }
}