aoe targetting fixed

This commit is contained in:
Mashy 2019-07-23 18:04:33 +10:00
parent ef11d14752
commit 4c68d11a28
7 changed files with 24 additions and 16 deletions

View File

@ -12,7 +12,7 @@ function getObjects(resolution, stages, game, account) {
if (!resolution) return none(); if (!resolution) return none();
if (!resolution.target) return none(); if (!resolution.target) return none();
const [, event] = resolution.event; const [type, event] = resolution.event;
if (!event || !event.skill) return none(); if (!event || !event.skill) return none();
const playerTeam = game.players.find(t => t.id === account.id); const playerTeam = game.players.find(t => t.id === account.id);
@ -22,6 +22,14 @@ function getObjects(resolution, stages, game, account) {
const sourceIsPlayer = playerTeamIds.includes(resolution.source.id); const sourceIsPlayer = playerTeamIds.includes(resolution.source.id);
const targetIsPlayer = playerTeamIds.includes(resolution.target.id); const targetIsPlayer = playerTeamIds.includes(resolution.target.id);
const targetting = () => {
if (type === 'AoeSkill') {
if (targetIsPlayer) return playerTeamIds;
return otherTeamIds;
}
return [resolution.target.id];
};
const sameTeam = (sourceIsPlayer && targetIsPlayer) || (!sourceIsPlayer && !targetIsPlayer); const sameTeam = (sourceIsPlayer && targetIsPlayer) || (!sourceIsPlayer && !targetIsPlayer);
let y = 0; let y = 0;
if (!sameTeam) y = targetIsPlayer ? 1 : -1; if (!sameTeam) y = targetIsPlayer ? 1 : -1;
@ -29,7 +37,7 @@ function getObjects(resolution, stages, game, account) {
const i = sourceIsPlayer const i = sourceIsPlayer
? playerTeamIds.findIndex(c => c === resolution.source.id) ? playerTeamIds.findIndex(c => c === resolution.source.id)
: otherTeamIds.findIndex(c => c === resolution.source.id); : otherTeamIds.findIndex(c => c === resolution.source.id);
const j = targetIsPlayer const j = targetIsPlayer
? playerTeamIds.findIndex(c => c === resolution.target.id) ? playerTeamIds.findIndex(c => c === resolution.target.id)
: otherTeamIds.findIndex(c => c === resolution.target.id); : otherTeamIds.findIndex(c => c === resolution.target.id);
@ -56,11 +64,10 @@ function getObjects(resolution, stages, game, account) {
const animTarget = { const animTarget = {
skill, skill,
constructId: resolution.target.id, constructId: targetting(),
player: playerTeamIds.includes(resolution.target.id), player: playerTeamIds.includes(resolution.target.id),
direction, direction,
}; };
return { return {
animSource, animSource,
animTarget, animTarget,
@ -109,11 +116,11 @@ function getFocusTargets(resolution, game) {
if (type === 'AoeSkill') { if (type === 'AoeSkill') {
const targetTeam = game.players.find(t => t.constructs.find(c => c.id === target)); const targetTeam = game.players.find(t => t.constructs.find(c => c.id === target));
const targetTeamIds = targetTeam.constructs.map(c => c.id); const targetTeamIds = targetTeam.constructs.map(c => c.id);
if (source !== target) return targetTeamIds.push(source); if (source !== target) targetTeamIds.push(source);
return targetTeamIds; return targetTeamIds;
} }
if (source !== target) return [source, target]; if (source !== target) return [source, target];
return target; return [target];
} }
function getText(resolution, sequence) { function getText(resolution, sequence) {

View File

@ -63,7 +63,7 @@ class ConstructAnimation extends Component {
constructId, constructId,
} = animTarget; } = animTarget;
if (construct.id !== constructId) return false; if (!constructId.includes(construct.id)) return false;
// find target animation // find target animation
const chooseAnim = (skill) => { const chooseAnim = (skill) => {

View File

@ -106,7 +106,7 @@ class Break extends Component {
componentWillUnmount() { componentWillUnmount() {
for (let i = this.animations.length - 1; i >= 0; i--) { for (let i = this.animations.length - 1; i >= 0; i--) {
this.animations[i].reset(); this.animations[i].reset();
} } this.props.animCb();
} }
} }

View File

@ -98,7 +98,12 @@ class Ruin extends Component {
componentWillUnmount() { componentWillUnmount() {
for (let i = this.animations.length - 1; i >= 0; i--) { for (let i = this.animations.length - 1; i >= 0; i--) {
this.animations[i].reset(); this.animations[i].reset();
} this.props.animCb(); }
try {
this.props.animCb();
} catch (e) {
console.log(e);
}
} }
} }

View File

@ -132,7 +132,7 @@ class ConstructAvatar extends Component {
} }
// this is the target // this is the target
if (animTarget && animTarget.constructId === construct.id) { if (animTarget && animTarget.constructId.includes(construct.id)) {
// console.warn(construct.name, 'should update') // console.warn(construct.name, 'should update')
return true; return true;
} }
@ -141,7 +141,7 @@ class ConstructAvatar extends Component {
const prevSrc = this.props.animSource && this.props.animSource.constructId === construct.id; const prevSrc = this.props.animSource && this.props.animSource.constructId === construct.id;
if (prevSrc && !animSource) return true; if (prevSrc && !animSource) return true;
const prevTarget = this.props.animTarget && this.props.animTarget.constructId === construct.id; const prevTarget = this.props.animTarget && this.props.animTarget.constructId.includes(construct.id);
if (prevTarget && !animTarget) return true; if (prevTarget && !animTarget) return true;
// console.warn(construct.name, 'not updating'); // console.warn(construct.name, 'not updating');

View File

@ -8,12 +8,8 @@ const { ConstructAvatar, ConstructText } = require('./construct');
const { ConstructAnimation } = require('./animations'); const { ConstructAnimation } = require('./animations');
const shapes = require('./shapes'); const shapes = require('./shapes');
const SkillBtn = require('./skill.btn'); const SkillBtn = require('./skill.btn');
const actions = require('../actions');
const addState = connect( const addState = connect(
function receiveState(state) { function receiveState(state) {
const { const {

View File

@ -62,7 +62,7 @@ function registerEvents(store) {
const anims = animations.getObjects(r, sequence, game, account); const anims = animations.getObjects(r, sequence, game, account);
const text = animations.getText(r, sequence); const text = animations.getText(r, sequence);
store.dispatch(actions.setAnimFocus(animations.getFocusTargets(r))); store.dispatch(actions.setAnimFocus(animations.getFocusTargets(r, game)));
if (sequence.includes('START_SKILL')) store.dispatch(actions.setAnimSource(anims.animSource)); if (sequence.includes('START_SKILL')) store.dispatch(actions.setAnimSource(anims.animSource));
if (sequence.includes('END_SKILL')) { if (sequence.includes('END_SKILL')) {