• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript underscore.min函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中underscore.min函数的典型用法代码示例。如果您正苦于以下问题:TypeScript min函数的具体用法?TypeScript min怎么用?TypeScript min使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了min函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1:

 makeRoomTypes.forEach((makeRoomType) => {
   const items = store.buckets[makeRoomType];
   if (items.length > 0 && items.length >= store.capacityForItem(items[0])) {
     // We'll move the lowest-value item to the vault.
     const itemToMove = _.min(items.filter((i) => !i.equipped && !i.notransfer), (i) => {
       let value = {
         Common: 0,
         Uncommon: 1,
         Rare: 2,
         Legendary: 3,
         Exotic: 4
       }[i.tier];
       // And low-stat
       if (i.primStat) {
         value += i.primStat.value / 1000;
       }
       return value;
     });
     if (!_.isNumber(itemToMove)) {
       itemsToMove.push(itemToMove);
     }
   }
 });
开发者ID:bhollis,项目名称:DIM,代码行数:23,代码来源:farming.service.ts


示例2: drawLine

  export function drawLine(scope, d, tipdiv) {
    const data = scope.stdmodel.data;
    const svg = scope.maing;
    const attachments: _.Dictionary<any> = [];

    const x2 = scope.plotRange.data2scrX(d.targetx);
    const y2 = scope.plotRange.data2scrY(d.targety);
    const position = tipdiv.position();

    const left = position.left;
    const top = position.top;
    const height = tipdiv.outerHeight();
    const width = tipdiv.outerWidth();

    addAttachment(left, top + height / 2, x2, y2, attachments);
    addAttachment(left + width, top + height / 2, x2, y2, attachments);
    addAttachment(left + width / 2, top, x2, y2, attachments);
    addAttachment(left + width / 2, top + height, x2, y2, attachments);
    addAttachment(left, top, x2, y2, attachments);
    addAttachment(left + width, top, x2, y2, attachments);
    addAttachment(left + width, top + height, x2, y2, attachments);
    addAttachment(left, top + height, x2, y2, attachments);

    let attachment = _.min(attachments, (item) => item.dist);
    const x1 = attachment.x;
    const y1 = attachment.y;

    svg.append("line")
      .style("stroke", data[d.idx].tip_color)
      .attr("class", "plot-tooltip-line")
      .attr("id", d.id + "_line")
      .attr("x2", x2)
      .attr("y2", y2)
      .attr("x1", x1)
      .attr("y1", y1);
  }
开发者ID:twosigma,项目名称:beaker-notebook,代码行数:36,代码来源:plotTip.ts


示例3: buildTalentGrid

function buildTalentGrid(item, talentDefs, progressDefs): D1TalentGrid | null {
  const talentGridDef = talentDefs.get(item.talentGridHash);
  if (
    !item.progression ||
    !talentGridDef ||
    !item.nodes ||
    !item.nodes.length ||
    !progressDefs.get(item.progression.progressionHash)
  ) {
    return null;
  }

  const totalXP = item.progression.currentProgress;
  const totalLevel = item.progression.level; // Can be way over max

  // progressSteps gives the XP needed to reach each level, with
  // the last element repeating infinitely.
  const progressSteps = progressDefs.get(item.progression.progressionHash).steps;
  // Total XP to get to specified level
  function xpToReachLevel(level) {
    if (level === 0) {
      return 0;
    }
    let totalXPRequired = 0;
    for (let step = 1; step <= level; step++) {
      totalXPRequired += progressSteps[Math.min(step, progressSteps.length) - 1].progressTotal;
    }

    return totalXPRequired;
  }

  const possibleNodes = talentGridDef.nodes;

  // var featuredPerkNames = item.perks.map(function(perk) {
  //   var perkDef = perkDefs.get(perk.perkHash);
  //   return perkDef ? perkDef.displayName : 'Unknown';
  // });

  let gridNodes = (item.nodes as any[]).map(
    (node): D1GridNode | undefined => {
      const talentNodeGroup = possibleNodes[node.nodeHash];
      const talentNodeSelected = talentNodeGroup.steps[node.stepIndex];

      if (!talentNodeSelected) {
        return undefined;
      }

      const nodeName = talentNodeSelected.nodeStepName;

      // Filter out some weird bogus nodes
      if (!nodeName || nodeName.length === 0 || talentNodeGroup.column < 0) {
        return undefined;
      }

      // Only one node in this column can be selected (scopes, etc)
      const exclusiveInColumn = Boolean(
        talentNodeGroup.exlusiveWithNodes && talentNodeGroup.exlusiveWithNodes.length > 0
      );

      // Unlocked is whether or not the material cost has been paid
      // for the node
      const unlocked =
        node.isActivated ||
        talentNodeGroup.autoUnlocks ||
        // If only one can be activated, the cost only needs to be
        // paid once per row.
        (exclusiveInColumn &&
          _.any(talentNodeGroup.exlusiveWithNodes, (nodeIndex: number) => {
            return item.nodes[nodeIndex].isActivated;
          }));

      // Calculate relative XP for just this node
      const startProgressionBarAtProgress = talentNodeSelected.startProgressionBarAtProgress;
      const activatedAtGridLevel = talentNodeSelected.activationRequirement.gridLevel;
      const xpRequired = xpToReachLevel(activatedAtGridLevel) - startProgressionBarAtProgress;
      const xp = Math.max(0, Math.min(totalXP - startProgressionBarAtProgress, xpRequired));

      // Build a perk string for the DTR link. See https://github.com/DestinyItemManager/DIM/issues/934
      let dtrHash: string | null = null;
      if (node.isActivated || talentNodeGroup.isRandom) {
        dtrHash = (node.nodeHash as number).toString(16);
        if (dtrHash.length > 1) {
          dtrHash += '.';
        }

        if (talentNodeGroup.isRandom) {
          dtrHash += node.stepIndex.toString(16);
          if (node.isActivated) {
            dtrHash += 'o';
          }
        }
      }

      // Generate a hash that identifies the weapons permutation and selected perks.
      // This is used by the Weapon Reviewing system.
      const generateNodeDtrRoll = (node, talentNodeSelected): string => {
        let dtrRoll = node.nodeHash.toString(16);

        if (dtrRoll.length > 1) {
          dtrRoll += '.';
//.........这里部分代码省略.........
开发者ID:bhollis,项目名称:DIM,代码行数:101,代码来源:d1-item-factory.service.ts


示例4: buildTalentGrid

function buildTalentGrid(
  item: DestinyItemComponent,
  talentsMap: { [key: string]: DestinyItemTalentGridComponent },
  talentDefs: LazyDefinition<DestinyTalentGridDefinition>
): DimTalentGrid | null {
  if (!item.itemInstanceId || !talentsMap[item.itemInstanceId]) {
    return null;
  }
  const talentGrid = talentsMap[item.itemInstanceId];
  if (!talentGrid) {
    return null;
  }

  const talentGridDef = talentDefs.get(talentGrid.talentGridHash);
  if (!talentGridDef || !talentGridDef.nodes || !talentGridDef.nodes.length) {
    return null;
  }

  const gridNodes = _.compact(talentGridDef.nodes.map((node): DimGridNode | undefined => {
    const talentNodeGroup = node;
    const talentNodeSelected = node.steps[0];

    if (!talentNodeSelected) {
      return undefined;
    }

    const nodeName = talentNodeSelected.displayProperties.name;

    // Filter out some weird bogus nodes
    if (!nodeName || nodeName.length === 0 || talentNodeGroup.column < 0) {
      return undefined;
    }

    // Only one node in this column can be selected (scopes, etc)
    const exclusiveInColumn = Boolean(talentNodeGroup.exclusiveWithNodeHashes &&
                              talentNodeGroup.exclusiveWithNodeHashes.length > 0);

    const activatedAtGridLevel = talentNodeSelected.activationRequirement.gridLevel;

    // There's a lot more here, but we're taking just what we need
    return {
      name: nodeName,
      hash: talentNodeSelected.nodeStepHash,
      description: talentNodeSelected.displayProperties.description,
      icon: talentNodeSelected.displayProperties.icon,
      // Position in the grid
      column: talentNodeGroup.column / 8,
      row: talentNodeGroup.row / 8,
      // Is the node selected (lit up in the grid)
      activated: true,
      // The item level at which this node can be unlocked
      activatedAtGridLevel,
      // Only one node in this column can be selected (scopes, etc)
      exclusiveInColumn,
      // Whether or not the material cost has been paid for the node
      unlocked: true,
      // Some nodes don't show up in the grid, like purchased ascend nodes
      hidden: false
    };
  }));

  if (!gridNodes.length) {
    return null;
  }

  // Fix for stuff that has nothing in early columns
  const minByColumn = _.min(gridNodes.filter((n) => !n.hidden), (n) => n.column);
  const minColumn = minByColumn.column;
  if (minColumn > 0) {
    gridNodes.forEach((node) => { node.column -= minColumn; });
  }

  return {
    nodes: _.sortBy(gridNodes, (node) => node.column + (0.1 * node.row)),
    complete: _.all(gridNodes, (n) => n.unlocked)
  };
}
开发者ID:delphiactual,项目名称:DIM,代码行数:77,代码来源:d2-item-factory.service.ts



注:本文中的underscore.min函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript underscore.object函数代码示例发布时间:2022-05-25
下一篇:
TypeScript underscore.method函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap