-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.js
57 lines (44 loc) · 1.18 KB
/
map.js
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
var setup = require('./map/setup.js'),
utils = require('./utilities/utils.js');
module.exports = utils.mixin({
continents: [],
regions: [],
getSuperRegion: function (name) {
var continents = this.continents,
length = continents.length,
i = 0;
for(; i < length; i++) {
if(continents[i].name === name) {
return continents[i];
}
}
return false;
},
getRegion: function (name) {
var regions = this.regions,
length = regions.length,
i = 0;
for(; i < length; i++) {
if(regions[i].name === name) {
return regions[i];
}
}
return false;
},
getOwnedRegions: function () {
var regions = this.regions;
return regions.filter(function (region) {
return region.owned;
});
},
getHomeRegion: function () {
var regions = this.getOwnedRegions(),
region;
for (region in regions) {
if (regions[region].home) {
return regions[region];
}
}
return false;
}
}, setup);