Skip to content

Commit

Permalink
feat(api): allow constructing roads and ramparts on terrain walls
Browse files Browse the repository at this point in the history
  • Loading branch information
artch committed Aug 21, 2018
1 parent 686281b commit 86c8208
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/game/api/game.js
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
});
}

Expand Down

0 comments on commit 86c8208

Please sign in to comment.