How to use the dotaconstants.items function in dotaconstants

To help you get started, we’ve selected a few dotaconstants examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github odota / core / util / scenariosUtil.js View on Github external
const constants = require('dotaconstants');
const utility = require('./utility');

const playerWon = utility.playerWon;


// all items that cost at least 2000
const itemCost = 2000;
const dotaItems = Object.keys(constants.items).map(k => [constants.items[k], k]).filter(x => x[0].cost >= itemCost).map(x => x[1]);
const timings = [7.5, 10, 12, 15, 20, 25, 30].map(x => x * 60);
const gameDurationBucket = [15, 30, 45, 60, 90].map(x => x * 60);

const negativeWords = ['ff', 'report', 'gg', 'end', 'noob'];
const positiveWords = ['gl', 'glhf', 'hf', 'good luck', 'have fun'];

const teamScenariosQueryParams = [
  'pos_chat_1min',
  'neg_chat_1min',
  'courier_kill',
  'first_blood',
];

function buildTeamScenario(scenario, isRadiant, match) {
  return [{
    scenario,
github odota / core / util / analysis.js View on Github external
unused_item(m, pm)
        {
      const result = [];
      if (pm.purchase)
            {
        for (const key in pm.purchase)
                {
          if (pm.purchase[key] && getGroupedItemUses(key) < 1 && constants.items[key] && isActiveItem(key))
                    {
                        // if item has cooldown, consider it usable
            result.push(`<img src="${constants.items[key].img}" class="item img-sm" title="${key}">`);
          }
        }
      }

      function getGroupedItemUses(key)
            {
        let total = 0;
        for (const key2 in pm.item_uses)
                {
          if (key === key2 || constants.item_groups.some((g) =&gt; {
            return (key in g) &amp;&amp; (key2 in g);
          }))
                    {
github odota / core / util / analysis.js View on Github external
unused_item(m, pm)
        {
      const result = [];
      if (pm.purchase)
            {
        for (const key in pm.purchase)
                {
          if (pm.purchase[key] &amp;&amp; getGroupedItemUses(key) &lt; 1 &amp;&amp; constants.items[key] &amp;&amp; isActiveItem(key))
                    {
                        // if item has cooldown, consider it usable
            result.push(`<img src="${constants.items[key].img}" class="item img-sm" title="${key}">`);
          }
        }
      }

      function getGroupedItemUses(key)
            {
        let total = 0;
        for (const key2 in pm.item_uses)
                {
          if (key === key2 || constants.item_groups.some((g) =&gt; {
            return (key in g) &amp;&amp; (key2 in g);
          }))
                    {
            total += pm.item_uses[key];
          }
        }
github odota / core / routes / hyperopia.js View on Github external
const Chance = require('chance');
const express = require('express');
const matches = express.Router();
const constants = require('dotaconstants');
const matchPages = constants.match_pages;
const playerSlots = [0, 1, 2, 3, 4, 128, 129, 130, 131, 132];
const item_ids = Object.keys(constants.items);
const hero_ids = Object.keys(constants.heroes);

module.exports = function (db)
{
  matches.get('/:player_id/:match_id/:info?', (req, res, cb) => {
    console.time('hyperopia generate match');
    db.first('personaname')
            .from('players')
            .where({
              account_id: req.params.player_id,
            })
            .asCallback((err, p) => {
              if (err)
                {
                return cb(err);
              }
github odota / core / util / analysis.js View on Github external
function isActiveItem(key)
    {
    const whitelist = {
      branches: 1,
      bloodstone: 1,
      radiance: 1,
    };
    return (constants.items[key].desc.indexOf('Active: ') > -1 && !(key in whitelist));
  }
}
github odota / core / routes / hyperopia.js View on Github external
lastXP = 0;
                  for (var j = 0; j &lt; times.length; j++) {
                    gold.push(lastGold);
                    lh.push(lastLH);
                    xp.push(lastXP);
                    lastGold = mChance.natural({ min: lastGold, max: 100000 });
                    lastLH = mChance.natural({ min: lastLH, max: player.last_hits });
                    lastXP = mChance.natural({ min: lastXP, max: 100000 });
                  }

                  player.gold_t = gold;
                  player.lh_t = lh;
                  player.xp_t = xp;

                  for (j = 0; j &lt; mChance.weighted([0, 1, 2, 3, 4, 5, 6], [0.01, 0.04, 0.5, 0.1, 0.2, 0.3, 0.3]); j++) {
                    player[`item_${j}`] = constants.items[mChance.pickone(item_ids)].id;
                  }

                  player.obs_log = generateWards();
                  player.sen_log = generateWards();
                  player.purchase_log = generateItemTimeline();
                  player.kills_log = [];
                  player.buyback_log = [];
                  player.lane_pos = {};
                  player.obs = {};
                  player.sen = {};
                  player.actions = {};
                  player.pings = mChance.natural({ max: 1000 });
                  player.purchase = {};
                  player.gold_reasons = {};
                  player.xp_reasons = {};
                  player.killed = {};
github odota / core / routes / hyperopia.js View on Github external
function generateItemTimeline()
                {
                const items = [];
                let lastTime = -60;
                for (let j = 0; j &lt; mChance.natural({ max: 40 }); j++) {
                  lastTime = mChance.integer({ min: lastTime, max: match.duration });
                  items.push({
                    time: lastTime,
                    key: mChance.pickone(Object.keys(constants.items)),
                  });
                }
              }