fix targetting arrows

This commit is contained in:
Mashy 2019-12-05 18:00:09 +10:00
parent da9736256e
commit e66a4233e8
4 changed files with 12 additions and 19 deletions

View File

@ -96,16 +96,13 @@ class ConstructAvatar extends Component {
}
}
function ConstructText(props) {
function ConstructName(props) {
const { construct } = props;
if (!construct) return false;
const text = construct.name;
return <h3 class={'name'}><span>{text}</span></h3>;
return <h3 class={'name'}><span>{construct.name}</span></h3>;
}
module.exports = {
ConstructAvatar: addState(ConstructAvatar),
ConstructText,
ConstructName,
};

View File

@ -2,7 +2,7 @@ const preact = require('preact');
const { connect } = require('preact-redux');
const range = require('lodash/range');
const { ConstructAvatar, ConstructText } = require('./construct');
const { ConstructAvatar, ConstructName } = require('./construct');
const SkillBtn = require('./game.construct.skill.btn');
const ConstructAnimationText = require('./game.construct.anim.text');
@ -82,7 +82,7 @@ class GameConstruct extends preact.Component {
<div class="right">
<ConstructLife construct={construct} />
<ConstructAvatar construct={construct} />
<ConstructText construct={construct} />
<ConstructName construct={construct} />
<ConstructAnimationText construct={construct} />
</div>
</div>

View File

@ -31,7 +31,6 @@ class TargetSvg extends Component {
if (newProps.game !== this.props.game) return true;
if (newProps.account !== this.props.account) return true;
if (newProps.animating !== this.props.animating) return true;
if (newProps.animSkill !== this.props.animSkill) return true;
if (newProps.gameEffectInfo !== this.props.gameEffectInfo) return true;
if (newProps.tutorialGame !== this.props.tutorialGame) return true;
if (newState.width !== this.state.width) return true;
@ -44,12 +43,9 @@ class TargetSvg extends Component {
// Changing State Variables
account,
animating,
animSkill,
game,
gameEffectInfo,
tutorialGame,
// Static
itemInfo,
} = props;
const { width, height } = state;
@ -87,14 +83,14 @@ class TargetSvg extends Component {
const otherTeam = game.players.find(t => t.id !== account.id);
const playerTeamIds = playerTeam.constructs.map(c => c.id);
const outgoing = game.stack.filter(stack => playerTeamIds.includes(stack.source_construct_id));
const outgoing = game.stack.filter(stack => stack.player === account.id);
function getPath(cast) {
const source = playerTeam.constructs.findIndex(c => c.id === cast.source_construct_id);
const defensive = playerTeamIds.includes(cast.target_construct_id);
const source = playerTeam.constructs.findIndex(c => c.id === cast.source);
const defensive = playerTeamIds.includes(cast.target);
const target = defensive
? playerTeam.constructs.findIndex(c => c.id === cast.target_construct_id)
: otherTeam.constructs.findIndex(c => c.id === cast.target_construct_id);
? playerTeam.constructs.findIndex(c => c.id === cast.target)
: otherTeam.constructs.findIndex(c => c.id === cast.target);
const skillNumber = window.innerWidth <= 800 // mobile styling trigger
? playerTeam.constructs[source].skills.findIndex(s => s.skill === cast.skill)

View File

@ -83,11 +83,11 @@ function registerEvents(store) {
if (animating) return false;
if (game && currentGame) {
if (game.resolved.length !== currentGame.resolved.length) {
if (game.events.length !== currentGame.events.length) {
store.dispatch(actions.setAnimating(true));
store.dispatch(actions.setGameSkillInfo(null));
// stop fetching the game state til animations are done
const newRes = game.resolved.slice(currentGame.resolved.length);
const newRes = game.events[currentGame.events.length];
return eachSeries(newRes, (r, cb) => {
if (!r.event) return cb();
let timeout = animations.getTime(r.stages);