How to use the dotaconstants/build/patch.json.forEach 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 / web / src / actions / transformCounts.js View on Github external
import patch from 'dotaconstants/build/patch.json';
import region from 'dotaconstants/build/region.json';
import { getPercentWin } from 'utility';
import strings from 'lang';

const patchLookup = {};
patch.forEach((patchElement, index) => {
  patchLookup[index] = patchElement.name;
});

const countTypes = {
  patch: patchLookup,
  region,
  is_radiant: {
    0: strings.general_dire,
    1: strings.general_radiant,
  },
};

export default function transformCounts(data) {
  const result = {};
  Object.keys(data).forEach((key) => {
    // Translate each ID to a string
github odota / mobile / app / components / Heatmap.js View on Github external
heatmapInstance.setData(scaleAndExtrema(${data},w / 127, null, 25));
        }, 100);
    `;
}

const dotaMaps = [
    { patchName: '7.07', mapImage: 'detailed_707.png' },
    { patchName: '7.00', mapImage: 'detailed_700.png' },
    { patchName: '6.86', mapImage: 'detailed_686.png' },
    { patchName: '6.82', mapImage: 'detailed_682.png' },
    { patchName: '6.70', mapImage: 'detailed_pre682.png' },
];

const patchDate = {};
patch.forEach((patchElement) => {
    patchDate[patchElement.name] = new Date(patchElement.date).getTime() / 1000;
});

class Heatmap extends Component {
    getMap(startTime) {
        if (startTime == null) {
            return dotaMaps[0].mapImage;
        }
        for (let i = 0; i < dotaMaps.length; i += 1) {
            if (startTime >= patchDate[dotaMaps[i].patchName]) {
                return dotaMaps[i].mapImage;
            }
        }
        return dotaMaps[0].mapImage;
    }
github odota / web / src / actions / player / playerCountsActions.js View on Github external
});

export const getPlayerCountsOk = (payload, id) => ({
  type: OK,
  payload,
  id,
});

export const getPlayerCountsError = (payload, id) => ({
  type: ERROR,
  payload,
  id,
});

const patchLookup = {};
patch.forEach((patchElement, index) => {
  patchLookup[index] = patchElement.name;
});

const countTypes = {
  patch: patchLookup,
  region,
  is_radiant: {
    0: strings.general_dire,
    1: strings.general_radiant,
  },
};

export const getPlayerCounts = (playerId, options = {}) => (dispatch, getState) => {
  if (playerCounts.isLoaded(getState(), playerId)) {
    dispatch(getPlayerCountsOk(playerCounts.getCountsList(getState(), playerId), playerId));
  } else {
github odota / web / src / components / DotaMap / index.jsx View on Github external
width,
  height: width,
  maxWidth,
  maxHeight: maxWidth,
});

const dotaMaps = [
  { patchName: '7.07', mapImage: '/assets/images/dota2/map/detailed_707.png' },
  { patchName: '7.00', mapImage: '/assets/images/dota2/map/detailed_700.png' },
  { patchName: '6.86', mapImage: '/assets/images/dota2/map/detailed_686.png' },
  { patchName: '6.82', mapImage: '/assets/images/dota2/map/detailed_682.png' },
  { patchName: '6.70', mapImage: '/assets/images/dota2/map/detailed_pre682.png' },
];

const patchDate = {};
patch.forEach((patchElement) => {
  patchDate[patchElement.name] = new Date(patchElement.date).getTime() / 1000;
});

const getUrl = (startTime) => {
  if (startTime == null) return dotaMaps[0].mapImage;
  for (let i = 0; i < dotaMaps.length; i += 1) {
    if (startTime >= patchDate[dotaMaps[i].patchName]) return dotaMaps[i].mapImage;
  }
  return dotaMaps[0].mapImage;
};

const MapContainer = styled.div`
  position: relative;
  background: url("${props => getUrl(props.startTime)}");
  background-size: contain;
`;