message: refactor assignRoad
diff: @@ -11,31 +11,34 @@ import { Road, roads } from './roads'
  */
  export function assignRoad (town: Town, building?: Building): Road {
  console.groupCollapsed('Assigning a road...')
  - let road: Road
  + const road = getRoad(town)
  +
  + if (building) {
  + roads.addBuilding(town, road, building)
  + }
  +
  + town.roads[road.key] = road
  +
  + console.log(road)
  + console.groupEnd()
  + return road
  +}
  +
  +function getRoad (town: Town): Road {
  if (lib.random(100) < townData.type[town.type].roadDuplication) {
  const tempRoad = findExistingRoad(town)
  - if (tempRoad) road = tempRoad
  +
  // if it doesn't find a suitable road, make a new one.
  - // @ts-expect-error Road might be defined if it's selected above.
  - if (!road) {
  - road = createRoad(town, {
  + if (tempRoad) {
  + return createRoad(town, {
  type: lib.random(roads.width.largeRoads),
  rolls: {
  width: lib.random(80, 100),
  wealth: lib.random(1, 100)
  }
  })
  - town.roads[road.key] = road
  }
  - } else {
  - road = createRoad(town)
  - town.roads[road.key] = road
  }
  - if (road && building) {
  - roads.addBuilding(town, road, building)
  - }
  - console.log(road)
  - console.groupEnd()
  - return road
  + return createRoad(town)
  }
  