message: Improve light calculation code
diff: @@ -26,25 +26,21 @@ export function newLoadout(name: string, items: LoadoutItem[]): Loadout {
  */
  export function getLight(store: DimStore, items: DimItem[]): number {
  // https://www.reddit.com/r/DestinyTheGame/comments/6yg4tw/how_overall_power_level_is_calculated/
  - let itemWeight = {
  + if (store.isDestiny2()) {
  + const exactLight = _.sumBy(items, (i) => i.primStat!.value) / items.length;
  + return Math.floor(exactLight * 10) / 10;
  + } else {
  + const itemWeight = {
  Weapons: 6,
  Armor: 5,
  General: 4
  };
  - // 3 Weapons, 4 Armor, 2 General
  - let itemWeightDenominator = 46;
  - if (store.isDestiny2()) {
  - // 3 Weapons, 4 Armor, 1 General
  - itemWeight = {
  - Weapons: 1,
  - Armor: 1,
  - General: 1
  - };
  - itemWeightDenominator = 8;
  - } else if (store.level === 40) {
  - // 3 Weapons, 4 Armor, 3 General
  - itemWeightDenominator = 50;
  - }
  +
  + const itemWeightDenominator = items.reduce(
  + (memo, item) =>
  + memo + (itemWeight[item.type === 'ClassItem' ? 'General' : item.bucket.sort!] || 0),
  + 0
  + );
  const exactLight =
  items.reduce(
  @@ -57,6 +53,7 @@ export function getLight(store: DimStore, items: DimItem[]): number {
  return Math.floor(exactLight * 10) / 10;
  }
  +}
  // Generate an optimized item set (loadout items) based on a filtered set of items and a value function
  export function optimalItemSet(
  