
// Each key corresponds to the current practical room level and contains a separate objects containing settings enabled
// at that level. Each higher level inherits the settings from the level below it.
let roomLevelOptions = {
  1: {
    'UPGRADERS_QUANTITY': 5,
    'RESERVER_COUNT': 0,
    'SCOUTS': true,
    'SKIP_STRUCTURE_ROAD': true,
    'SKIP_STRUCTURE_CONTAINER': true
  },
  2: {},
  3: {
    'PURE_CARRY_FILLERS': true,
    'ADDITIONAL_FILLERS': true,
    'SELF_SUFFICIENT': true,
    'REMOTE_MINES': 1,
    'SKIP_STRUCTURE_CONTAINER': false
  },
  4: {
    'DEDICATED_MINERS': true,
    'ADDITIONAL_FILLERS': false,
    'RESERVER_COUNT': 3,
    'REMOTE_MINES': 2,
    'EXPAND_FROM': true,
    'ALLOW_MINING_SCALEBACK': true,
    'SKIP_STRUCTURE_ROAD': false
  },
  5: {},
  6: {
    'EXTRACT_MINERALS': true,
    'RESERVER_COUNT': 2,
    'UPGRADERS_QUANTITY': 3,
    'LABS': true
  },
  7: {
    'RESERVER_COUNT': 1,
    'ALLOW_MINING_SCALEBACK': false,
    'ALWAYS_SAFEMODE': true
  },
  8: {
    'UPGRADERS_QUANTITY': 1,
    'REMOTE_MINES': 3,
    'SHARE_ENERGY': true
  }
}

roomLevelOptions[4]['RAMPART_LEVELS'] = {}
roomLevelOptions[4]['RAMPART_LEVELS'][RAMPART_PATHWAY] = 0
roomLevelOptions[4]['RAMPART_LEVELS'][RAMPART_EDGE] = 0
roomLevelOptions[4]['RAMPART_LEVELS'][RAMPART_PRIMARY_STRUCTURES] = 0
roomLevelOptions[4]['RAMPART_LEVELS'][RAMPART_SECONDARY_STRUCTURES] = 0
roomLevelOptions[4]['RAMPART_LEVELS'][RAMPART_CONTROLLER] = 0
roomLevelOptions[4]['RAMPART_LEVELS'][RAMPART_GATEWAY] = 0
roomLevelOptions[4]['RAMPART_LEVELS'][WALL_GATEWAY] = 0

roomLevelOptions[5]['RAMPART_LEVELS'] = {}
roomLevelOptions[5]['RAMPART_LEVELS'][RAMPART_PATHWAY] = 0
roomLevelOptions[5]['RAMPART_LEVELS'][RAMPART_EDGE] = 0
roomLevelOptions[5]['RAMPART_LEVELS'][RAMPART_PRIMARY_STRUCTURES] = 0
roomLevelOptions[5]['RAMPART_LEVELS'][RAMPART_SECONDARY_STRUCTURES] = 0
roomLevelOptions[5]['RAMPART_LEVELS'][RAMPART_CONTROLLER] = 0
roomLevelOptions[5]['RAMPART_LEVELS'][RAMPART_GATEWAY] = 0
roomLevelOptions[5]['RAMPART_LEVELS'][WALL_GATEWAY] = 0

roomLevelOptions[6]['RAMPART_LEVELS'] = {}
roomLevelOptions[6]['RAMPART_LEVELS'][RAMPART_PATHWAY] = 0
roomLevelOptions[6]['RAMPART_LEVELS'][RAMPART_EDGE] = 0
roomLevelOptions[6]['RAMPART_LEVELS'][RAMPART_PRIMARY_STRUCTURES] = 3000000
roomLevelOptions[6]['RAMPART_LEVELS'][RAMPART_SECONDARY_STRUCTURES] = 0
roomLevelOptions[6]['RAMPART_LEVELS'][RAMPART_CONTROLLER] = 0
roomLevelOptions[6]['RAMPART_LEVELS'][RAMPART_GATEWAY] = 0
roomLevelOptions[6]['RAMPART_LEVELS'][WALL_GATEWAY] = 0

roomLevelOptions[7]['RAMPART_LEVELS'] = {}
roomLevelOptions[7]['RAMPART_LEVELS'][RAMPART_PATHWAY] = 0
roomLevelOptions[7]['RAMPART_LEVELS'][RAMPART_EDGE] = 1500000
roomLevelOptions[7]['RAMPART_LEVELS'][RAMPART_PRIMARY_STRUCTURES] = 3000000
roomLevelOptions[7]['RAMPART_LEVELS'][RAMPART_SECONDARY_STRUCTURES] = 0
roomLevelOptions[7]['RAMPART_LEVELS'][RAMPART_CONTROLLER] = 0
roomLevelOptions[7]['RAMPART_LEVELS'][RAMPART_GATEWAY] = 0
roomLevelOptions[7]['RAMPART_LEVELS'][WALL_GATEWAY] = 0

roomLevelOptions[8]['RAMPART_LEVELS'] = {}
roomLevelOptions[8]['RAMPART_LEVELS'][RAMPART_PATHWAY] = 0
roomLevelOptions[8]['RAMPART_LEVELS'][RAMPART_EDGE] = 30000000
roomLevelOptions[8]['RAMPART_LEVELS'][RAMPART_PRIMARY_STRUCTURES] = 3000000
roomLevelOptions[8]['RAMPART_LEVELS'][RAMPART_SECONDARY_STRUCTURES] = 0
roomLevelOptions[8]['RAMPART_LEVELS'][RAMPART_CONTROLLER] = 30000000
roomLevelOptions[8]['RAMPART_LEVELS'][RAMPART_GATEWAY] = 0
roomLevelOptions[8]['RAMPART_LEVELS'][WALL_GATEWAY] = 0

// Have each level inherit the settings from the previous level unless already set.
for (let level = 0; level <= 8; level++) {
  for (let addLevel = level - 1; addLevel > 0; addLevel--) {
    const keys = Object.keys(roomLevelOptions[addLevel])
    for (let key of keys) {
      if (typeof roomLevelOptions[level][key] === 'undefined') {
        roomLevelOptions[level][key] = roomLevelOptions[addLevel][key]
      }
    }
  }
}

Room.prototype.getRoomSetting = function (key) {
  const level = this.getPracticalRoomLevel()
  key = key.toUpperCase()
  return roomLevelOptions[level][key] ? roomLevelOptions[level][key] : false
}

@@ -3614,17 +3614,17 @@
 level = 
-0
+2
 ; level 
@@ -3644,71 +3644,8 @@
 ) %7B%0A
-  for (let addLevel = level - 1; addLevel %3E 0; addLevel--) %7B%0A  
   co
@@ -3688,21 +3688,20 @@
 ons%5B
-addLevel
+level - 1
 %5D)%0A
-  
   fo
@@ -3718,26 +3718,24 @@
  of keys) %7B%0A
-  
     if (type
@@ -3791,18 +3791,16 @@
 %7B%0A      
- 
- 
 roomLeve
@@ -3843,30 +3843,23 @@
 ons%5B
-addLevel%5D%5Bkey%5D%0A      %7D
+level - 1%5D%5Bkey%5D
 %0A   

Improve room control level inheritance algorithm.