This repository was archived by the owner on Sep 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcore.commands.js
More file actions
80 lines (65 loc) · 1.75 KB
/
core.commands.js
File metadata and controls
80 lines (65 loc) · 1.75 KB
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
/* jshint quotmark: single */
(function () {
'use strict';
questkit.goDirection = function (direction) {
// TODO: Locked exits, exits with scripts
var foundExit;
questkit.scopeExits().forEach(function (exit) {
if (get(exit, 'direction') == direction) {
foundExit = exit;
return;
}
});
if (!foundExit) {
msg(questkit.template('UnresolvedDirection'));
return;
}
questkit.goToExit(foundExit);
};
questkit.goToExit = function (exit) {
// TODO: Locked exits, exits with scripts
questkit.go(get(exit, 'to'));
};
questkit.take = function (objects) {
objects.forEach(function (object) {
take(object, objects.length > 1);
});
};
var take = function (object, showName) {
// TODO: Full conversion
var template;
var it = questkit.objectPronoun(object);
if (get(object, 'parent') == get('pov')) {
template = 'AlreadyTaken';
}
else if (get(object, 'take')) {
set(object, 'parent', get('pov'));
template = 'TakeSuccessful';
}
else {
template = 'TakeUnsuccessful';
}
msg ((showName ? questkit.displayAlias(object) + ': ' : '') + questkit.template(template).format(it));
};
questkit.drop = function (objects) {
objects.forEach(function (object) {
drop(object, objects.length > 1);
});
};
var drop = function (object, showName) {
// TODO: Full conversion
var template;
var it = questkit.objectPronoun(object);
if (questkit.scopeInventory().indexOf(object) == -1) {
template = 'NotCarrying';
}
else if (get(object, 'drop') !== false) {
set(object, 'parent', questkit.povParent());
template = 'DropSuccessful';
}
else {
template = 'DropUnsuccessful';
}
msg ((showName ? questkit.displayAlias(object) + ': ' : '') + questkit.template(template).format(it));
};
})();