const { connect } = require('preact-redux'); const { Component } = require('preact'); const preact = require('preact'); const range = require('lodash/range'); const reactStringReplace = require('react-string-replace'); const { STATS } = require('../utils'); const { ConstructAvatar, ConstructText } = require('./construct'); const shapes = require('./shapes'); const { INFO } = require('./../constants'); const actions = require('../actions'); const SkillBtn = require('./skill.btn'); const addState = connect( function receiveState(state) { const { ws, game, account, activeSkill, animFocus, animating, animText, gameSkillInfo, itemInfo, tutorialGame, } = state; function selectSkillTarget(targetConstructId) { if (activeSkill) { return ws.sendGameSkill(game.id, activeSkill.constructId, targetConstructId, activeSkill.skill); } return false; } return { game, account, animating, animFocus, animText, activeSkill, selectSkillTarget, gameSkillInfo, itemInfo, tutorialGame, }; }, function receiveDispatch(dispatch) { function setGameEffectInfo(info) { dispatch(actions.setGameEffectInfo(info)); } function setTutorialGameClear(activeSkill, tutorialGame) { if (activeSkill && tutorialGame) dispatch(actions.setTutorialGame(null)); } return { setGameEffectInfo, setTutorialGameClear }; } ); const eventClasses = (animating, animFocus, construct, postSkill) => { if (!animating) return ''; if (!postSkill) { if (animFocus.includes(construct.id)) return ''; return 'unfocus'; } if (postSkill.constructId !== construct.id) { if (animFocus.includes(construct.id)) return ''; return 'unfocus'; } if (postSkill.effects) construct.effects = postSkill.effects; construct.green_life.value = postSkill.life.green; construct.red_life.value = postSkill.life.red; construct.blue_life.value = postSkill.life.blue; return postSkill.css; }; class GameConstruct extends Component { constructor() { super(); this.resolvedLength = 0; } render() { const { i, animating, construct, player, activeSkill, selectSkillTarget, animFocus, animText, tutorialGame, setTutorialGameClear, setGameEffectInfo, gameSkillInfo, itemInfo, } = this.props; const ko = construct.green_life.value === 0 ? 'ko' : ''; const classes = eventClasses(animating, animFocus, construct, animText); const stats = ['RedLife', 'GreenLife', 'BlueLife'].map((s, j) => (