<commit_before>import BungieImage from 'app/dim-ui/BungieImage';
import { t } from 'app/i18next-t';
import { showItemPicker } from 'app/item-picker/item-picker';
import Sockets from 'app/loadout/loadout-ui/Sockets';
import { useD2Definitions } from 'app/manifest/selectors';
import { AppIcon, faRandom, lockIcon } from 'app/shell/icons';
import { DestinyEnergyType } from 'bungie-api-ts/destiny2';
import clsx from 'clsx';
import { PlugCategoryHashes } from 'data/d2/generated-enums';
import _ from 'lodash';
import React, { Dispatch } from 'react';
import { DimItem, PluggableInventoryItemDefinition } from '../../inventory/item-types';
import { LoadoutBuilderAction } from '../loadout-builder-reducer';
import LoadoutBuilderItem from '../LoadoutBuilderItem';
import styles from './GeneratedSetItem.m.scss';

/**
 * Shows how we recommend the energy of this armor be changed in order to fit its mods.
 */
function EnergySwap({
  item,
  assignedMods,
}: {
  item: DimItem;
  assignedMods?: PluggableInventoryItemDefinition[];
}) {
  const defs = useD2Definitions()!;

  const armorEnergyCapacity = item.energy?.energyCapacity || 0;
  const armorEnergy = defs.EnergyType.get(item.energy!.energyTypeHash);

  const modCost = _.sumBy(assignedMods, (mod) => mod.plug.energyCost?.energyCost || 0);
  const modEnergyHashNotAny = assignedMods?.find(
    (mod) => mod.plug.energyCost && mod.plug.energyCost.energyType !== DestinyEnergyType.Any
  )?.plug.energyCost?.energyTypeHash;
  const modEnergy = (modEnergyHashNotAny && defs.EnergyType.get(modEnergyHashNotAny)) || null;

  // The armor energy type and capacity needed for the mods
  const resultingEnergy = modEnergy ?? armorEnergy;
  let resultingEnergyCapacity = armorEnergyCapacity;<commit_msg>Also check for non zero energy cost.<commit_after>import BungieImage from 'app/dim-ui/BungieImage';
import { t } from 'app/i18next-t';
import { showItemPicker } from 'app/item-picker/item-picker';
import Sockets from 'app/loadout/loadout-ui/Sockets';
import { useD2Definitions } from 'app/manifest/selectors';
import { AppIcon, faRandom, lockIcon } from 'app/shell/icons';
import { DestinyEnergyType } from 'bungie-api-ts/destiny2';
import clsx from 'clsx';
import { PlugCategoryHashes } from 'data/d2/generated-enums';
import _ from 'lodash';
import React, { Dispatch } from 'react';
import { DimItem, PluggableInventoryItemDefinition } from '../../inventory/item-types';
import { LoadoutBuilderAction } from '../loadout-builder-reducer';
import LoadoutBuilderItem from '../LoadoutBuilderItem';
import styles from './GeneratedSetItem.m.scss';

/**
 * Shows how we recommend the energy of this armor be changed in order to fit its mods.
 */
function EnergySwap({
  item,
  assignedMods,
}: {
  item: DimItem;
  assignedMods?: PluggableInventoryItemDefinition[];
}) {
  const defs = useD2Definitions()!;

  const armorEnergyCapacity = item.energy?.energyCapacity || 0;
  const armorEnergy = defs.EnergyType.get(item.energy!.energyTypeHash);

  const modCost = _.sumBy(assignedMods, (mod) => mod.plug.energyCost?.energyCost || 0);
  const modEnergyHashNotAny = assignedMods?.find(
    (mod) =>
      mod.plug.energyCost &&
      mod.plug.energyCost.energyCost > 0 &&
      mod.plug.energyCost.energyType !== DestinyEnergyType.Any
  )?.plug.energyCost?.energyTypeHash;
  const modEnergy = (modEnergyHashNotAny && defs.EnergyType.get(modEnergyHashNotAny)) || null;

  // The armor energy type and capacity needed for the mods
  const resultingEnergy = modEnergy ?? armorEnergy;
  let resultingEnergyCapacity = armorEnergyCapacity;
{'fraction_non_alphanumeric': 0.12510495382031905, 'fraction_numerical': 0.004757906521130702, 'mean_word_length': 4.927031509121061, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6538979', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1093, 'n_words': 275}