const preact = require('preact'); const key = require('keymaster'); const range = require('lodash/range'); const molecule = require('./molecule'); const saw = require('./saw.component'); const SKILL_HOT_KEYS = ['Q', 'W', 'E', 'R']; function GamePanel(props) { const { game, activeSkill, activeIncoming, setActiveSkill, selectSkillTarget, selectIncomingTarget, account, } = props; if (!game) return
...
; const otherTeams = game.teams.filter(t => t.id !== account.id); const playerTeam = game.teams.find(t => t.id === account.id); function Cryp(cryp) { const skills = range(0, 4).map((i) => { const s = cryp.skills[i] ? cryp.skills[i].skill : ( ); return ; }); const stats = [ { stat: 'hp', colour: '#1FF01F' }, { stat: 'red_shield', colour: '#a52a2a' }, { stat: 'blue_shield', colour: '#3498db' }, ].map((s, i) => (
{saw(s.colour)}
{cryp[s.stat].value} / {cryp[s.stat].max}
)); return (
{molecule}
{skills}
{stats}
); } function PlayerCrypCard(cryp) { const skills = cryp.skills.map((skill, i) => { const hotkey = SKILL_HOT_KEYS[i]; key.unbind(hotkey); key(hotkey, () => setActiveSkill(cryp.id, skill)); return ( ); }); const effects = cryp.effects.map((effect, i) => (
{effect} for {effect.turns}T
)); return (
selectIncomingTarget(cryp.id)} className="tile is-vertical"> {Cryp(cryp, setActiveSkill)}
); } function PlayerTeam(team) { const cryps = team.cryps.map(c => PlayerCrypCard(c, setActiveSkill)); return (
{cryps}
); } function OpponentCrypCard(cryp) { const effects = cryp.effects.map((effect, i) => (
{effect.effect} for {effect.turns}T
)); return (
selectSkillTarget(cryp.id)} >

{cryp.name}

{cryp.hp.value} / {cryp.hp.value} HP
{effects}
); } function OpponentTeam(team) { const cryps = team.cryps.map(OpponentCrypCard); return (
{cryps}
); } const logs = game.log.reverse().map((l, i) => (
{l}
)); return (
{playerTeam.id} {PlayerTeam(playerTeam, setActiveSkill)}
Round X
{otherTeams.id} {otherTeams.map(OpponentTeam)}
); } module.exports = GamePanel;