-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better match history, added most picked/banned heroes
- Loading branch information
1 parent
42167a0
commit 0c9f45c
Showing
4 changed files
with
132 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
|
||
export const HeroNameMap = { | ||
electrician: 'chatterjee' | ||
}; | ||
|
||
export const CustomHeroImage = { | ||
electrician: "https://raw.githubusercontent.com/OpenAngelArena/oaa/master/content/panorama/images/heroes/npc_dota_hero_electrician.png", | ||
sohei: "https://raw.githubusercontent.com/OpenAngelArena/oaa/master/content/panorama/images/heroes/npc_dota_hero_sohei.png", | ||
}; | ||
|
||
export function imgUrlForHero(hero) { | ||
if (hero.startsWith('npc_dota_hero_')) { | ||
hero = hero.substr(14); | ||
} | ||
|
||
if (CustomHeroImage[hero]) { | ||
return CustomHeroImage[hero]; | ||
} | ||
return `https://cdn.akamai.steamstatic.com/apps/dota2/images/dota_react/heroes/${hero}.png` | ||
} | ||
|
||
export function heroName(hero) { | ||
if (hero.startsWith('npc_dota_hero_')) { | ||
hero = hero.substr(14); | ||
} | ||
|
||
if (HeroNameMap[hero]) { | ||
hero = HeroNameMap[hero]; | ||
} | ||
|
||
return hero | ||
.replace(/_/g, ' ') | ||
.split(' ') | ||
.map((part) => { | ||
if (!part || !part.length) { | ||
return part; | ||
} | ||
return part[0].toUpperCase() + part.substr(1).toLowerCase(); | ||
}) | ||
.join(' '); | ||
} | ||
|
||
export default function HeroIcon(props) { | ||
const { hero, ...otherProps } = props; | ||
let finalHero = hero; | ||
|
||
if (finalHero.startsWith('npc_dota_hero_')) { | ||
finalHero = finalHero.substr(14); | ||
} | ||
|
||
return ( | ||
<img | ||
{...otherProps} | ||
src={imgUrlForHero(finalHero)} | ||
alt={finalHero} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters