server/engine/gameLogic/Building.js
/**
 * TODO: improvement: make updateInfo universal for vertex unit and edge unit
 * private helper method for vertex unit
 * @param map {Map}
 * @param building {Building}
 */
make updateInfo universal for vertex unit and edge unit
private helper method for vertex unit
@param map {Map}
@param building {Building}
make updateInfo universal for vertex unit and edge unit private helper method for vertex unit @param map { Map } @param building { Building }
function updateInfo(map, building) {
    Map.setVertexInfo(map, building, building.position);
    building.owner.buildings[building.position] = building;
    Player.updateVP(building.owner, VP.buildSettlement);
    building.owner.settlementCnt++;
    for (let edgeKey in map.harbors) {
        if (map.harbors.hasOwnProperty(edgeKey)) {
            let harbor = map.harbors[edgeKey];
            if (((harbor.position[0] == building.position) || (harbor.position[1] == building.position)) && !harbor.owner) {
                Harbor.acquireBy(harbor, building.owner);
            }
        }
    }
}
function updateInfo ( map , building ) { Map . setVertexInfo ( map , building , building . position ) ; building . owner . buildings [ building . position ] = building ; Player . updateVP ( building . owner , VP . buildSettlement ) ; building . owner . settlementCnt ++ ; for ( let edgeKey in map . harbors ) { if ( map . harbors . hasOwnProperty ( edgeKey ) ) { let harbor = map . harbors [ edgeKey ] ; if ( ( ( harbor . position [ 0 ] == building . position ) || ( harbor . position [ 1 ] == building . position ) ) && ! harbor . owner ) { Harbor . acquireBy ( harbor , building . owner ) ; } } } }
TODO: improvement: make updateInfo universal for vertex unit and edge unit
 private helper method for vertex unit
 @param map {Map}
 @param building {Building}
TODO : improvement : make updateInfo universal for vertex unit and edge unit private helper method for vertex unit @param map { Map } @param building { Building }
//update hexTile info
 /**
     let neighborHexTiles = map.getHexTileByVertex(building.position);
     for (let i = 0; i<neighborHexTiles.length; i++){
        let [hexTileId, positionInHex] = neighborHexTiles[i];
        let hexTile = map.getHexTileById(hexTileId);
        if (hexTile.verticesInfo[positionInHex]) throw "You can only build settlement/city on empty vertex";
        hexTile.verticesInfo[positionInHex] = building;
    }**/ //update player info
 //check if the the vertex can acquire unoccupied harbor
 // check for fish tile
