Skip to content
Permalink
Browse files

feat(api): allow constructing roads and ramparts on terrain walls

  • Loading branch information...
artch committed Aug 21, 2018
1 parent 686281b commit 86c8208374aad0cbcd3973990dda49eaad975fc5
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/game/api/game.js
@@ -68,7 +68,8 @@ function checkConstructionSpot(room, structureType, x, y) {
var result = checkForObjectAbsence({$and: [{room}, {x}, {y}, {type: structureType}]})
.then(() => checkForObjectAbsence({$and: [{room}, {x}, {y}, {type: 'constructionSite'}]}))
.then(() => structureType == 'rampart' ? true : checkForObjectAbsence({$and: [{room}, {x}, {y}, {type: {$in: ['wall','constructedWall','spawn','extension','link','storage','tower','observer','powerSpawn']}}]}))
.then(() => checkForTerrainAbsence(room, x, y, C.TERRAIN_MASK_WALL))
.then(() => structureType == 'road' || structureType == 'rampart' ? true :
checkForTerrainAbsence(room, x, y, C.TERRAIN_MASK_WALL))
.then(() => checkForObjectAbsence({$and: [{room}, {x: {$gt: x-2, $lt: x+2}}, {y: {$gt: y-2, $lt: y+2}}, {type: 'exit'}]}));

if(structureType != 'road' && (x == 1 || x == 48 || y == 1 || y == 48)) {
@@ -501,7 +502,11 @@ router.post('/create-construction', auth.tokenAuth, jsonResponse((request) => {
if (structureType == 'road') {
result = result.then(() => {
return checkForTerrainAbsence(request.body.room, x, y, C.TERRAIN_MASK_SWAMP)
.catch(() => progressTotal *= C.CONSTRUCTION_COST_ROAD_SWAMP_RATIO);
.catch(() => progressTotal *= C.CONSTRUCTION_COST_ROAD_SWAMP_RATIO);
});
result = result.then(() => {
return checkForTerrainAbsence(request.body.room, x, y, C.TERRAIN_MASK_WALL)
.catch(() => progressTotal *= C.CONSTRUCTION_COST_ROAD_WALL_RATIO);
});
}

0 comments on commit 86c8208

Please sign in to comment.
You can’t perform that action at this time.