This commit is contained in:
ntr 2018-10-25 13:22:36 +11:00
parent e192edfc26
commit 17a1132700

View File

@ -1,6 +1,8 @@
const preact = require('preact');
const key = require('keymaster');
const SKILL_HOT_KEYS = ['Q', 'W', 'E', 'R'];
function GamePanel(props) {
const {
game,
@ -36,8 +38,23 @@ function GamePanel(props) {
});
function PlayerCrypCard(cryp) {
key.unbind('q');
key('q', () => setActiveSkill(cryp.id, 'Attack'));
const skills = cryp.skills.map((skill, i) => {
const hotkey = SKILL_HOT_KEYS[i];
key.unbind(hotkey);
key(hotkey, () => setActiveSkill(cryp.id, skill.skill));
return (
<button
key={i}
className="button is-dark"
type="submit"
onClick={() => setActiveSkill(cryp.id, skill.skill)}
>
({hotkey}) {skill.skill} {skill.cd && `(${skill.cd}T)`}
</button>
);
});
if (activeIncoming) console.log('should be a pointer');
return (
<div
@ -64,13 +81,7 @@ function GamePanel(props) {
<div className="has-text-centered">{cryp.xp} / {Math.pow(2,cryp.lvl+1)} XP </div>
<progress className="progress is-dark" value={cryp.xp} max={Math.pow(2,cryp.lvl+1)}></progress>
</div>
<button
className="button is-dark is-fullwidth"
type="submit"
onClick={() => setActiveSkill(cryp.id, 'Attack')}
>
(Q) Attack
</button>
{skills}
</div>
);
}