text back
This commit is contained in:
@@ -140,6 +140,26 @@ class ConstructAvatar extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const addStateText = connect(
|
||||
function receiveState(state) {
|
||||
const { animText } = state;
|
||||
return { animText };
|
||||
}
|
||||
);
|
||||
|
||||
function constructText(props) {
|
||||
const { construct, animText } = props;
|
||||
if (!construct || !animText) return false;
|
||||
|
||||
const text = animText.constructId === construct.id
|
||||
? animText.text
|
||||
: null;
|
||||
|
||||
return <div class={'combat-text'}>{text}</div>;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ConstructAvatar: addState(ConstructAvatar),
|
||||
ConstructText: addStateText(constructText),
|
||||
};
|
||||
|
||||
@@ -3,8 +3,8 @@ const { Component } = require('preact');
|
||||
const preact = require('preact');
|
||||
const range = require('lodash/range');
|
||||
|
||||
const { STATS, eventClasses, getCombatText } = require('../utils');
|
||||
const { ConstructAvatar } = require('./construct');
|
||||
const { STATS, eventClasses } = require('../utils');
|
||||
const { ConstructAvatar, ConstructText } = require('./construct');
|
||||
const { ConstructAnimation } = require('./animations');
|
||||
const shapes = require('./shapes');
|
||||
|
||||
@@ -20,9 +20,10 @@ const addState = connect(
|
||||
ws,
|
||||
game,
|
||||
account,
|
||||
resolution,
|
||||
activeSkill,
|
||||
avatarAnimation,
|
||||
resolution,
|
||||
|
||||
animText,
|
||||
} = state;
|
||||
|
||||
function selectSkillTarget(targetConstructId) {
|
||||
@@ -40,22 +41,11 @@ const addState = connect(
|
||||
game,
|
||||
account,
|
||||
resolution,
|
||||
animText,
|
||||
activeSkill,
|
||||
avatarAnimation,
|
||||
selectSkillTarget,
|
||||
};
|
||||
},
|
||||
|
||||
function receiveDispatch(dispatch) {
|
||||
function setAvatarAnimation(source, target, id, animTargetId, type, params) {
|
||||
return dispatch(actions.setAvatarAnimation({ source, target, id, animTargetId, type, params }));
|
||||
}
|
||||
|
||||
return {
|
||||
setAvatarAnimation,
|
||||
};
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
|
||||
@@ -72,9 +62,13 @@ class GameConstruct extends Component {
|
||||
account,
|
||||
construct,
|
||||
player,
|
||||
resolution,
|
||||
activeSkill,
|
||||
selectSkillTarget,
|
||||
|
||||
// todo remove dep
|
||||
resolution,
|
||||
|
||||
animText,
|
||||
} = this.props;
|
||||
|
||||
const ko = construct.green_life.value === 0 ? 'ko' : '';
|
||||
@@ -97,7 +91,7 @@ class GameConstruct extends Component {
|
||||
const effects = construct.effects.length
|
||||
? construct.effects.map(c => <div key={c.effect}>{c.effect} - {c.duration}T</div>)
|
||||
: <div> </div>;
|
||||
const combatText = getCombatText(resolution, construct);
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={() => selectSkillTarget(construct.id)}
|
||||
@@ -108,7 +102,7 @@ class GameConstruct extends Component {
|
||||
<div class="stats"> {stats} </div>
|
||||
<ConstructAvatar construct={construct} />
|
||||
<ConstructAnimation construct={construct} />
|
||||
<div class={'combat-text'}> {combatText} </div>
|
||||
<ConstructText construct={construct} />
|
||||
<div class="effects"> {effects} </div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user