cleanup add aoe focusTargets
This commit is contained in:
parent
9ae52b39ce
commit
b8cb296bd6
@ -1,15 +1,7 @@
|
|||||||
const { removeTier } = require('./utils');
|
const { removeTier } = require('./utils');
|
||||||
|
|
||||||
function none() {
|
|
||||||
return {
|
|
||||||
animSource: null,
|
|
||||||
animTarget: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function getObjects(resolution, game, account) {
|
function getObjects(resolution, game, account) {
|
||||||
const [type, event] = resolution.variant;
|
const [type, event] = resolution.variant;
|
||||||
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);
|
||||||
const playerTeamIds = playerTeam.constructs.map(c => c.id);
|
const playerTeamIds = playerTeam.constructs.map(c => c.id);
|
||||||
@ -41,6 +33,20 @@ function getObjects(resolution, game, account) {
|
|||||||
const direction = { x, y };
|
const direction = { x, y };
|
||||||
// const targetTeam = targetIsPlayer ? playerTeamIds : otherTeamIds;
|
// const targetTeam = targetIsPlayer ? playerTeamIds : otherTeamIds;
|
||||||
|
|
||||||
|
const getFocusTargets = () => {
|
||||||
|
if (type === 'HitCast') {
|
||||||
|
const { source } = event;
|
||||||
|
const { target } = resolution;
|
||||||
|
if (source !== target) return [source, target];
|
||||||
|
return [target];
|
||||||
|
}
|
||||||
|
if (type === 'AoeSkill') {
|
||||||
|
if (targetIsPlayer) return playerTeamIds;
|
||||||
|
return otherTeamIds;
|
||||||
|
}
|
||||||
|
return [resolution.target];
|
||||||
|
};
|
||||||
|
|
||||||
const animSource = {
|
const animSource = {
|
||||||
animation: 'sourceCast',
|
animation: 'sourceCast',
|
||||||
constructId: event.source,
|
constructId: event.source,
|
||||||
@ -57,19 +63,11 @@ function getObjects(resolution, game, account) {
|
|||||||
return {
|
return {
|
||||||
animSource,
|
animSource,
|
||||||
animTarget,
|
animTarget,
|
||||||
|
focusTargets: getFocusTargets(),
|
||||||
|
skill: event.skill,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFocusTargets(resolution) {
|
|
||||||
const [type, event] = resolution.variant;
|
|
||||||
if (type === 'HitCast') {
|
|
||||||
const { source } = event;
|
|
||||||
const { target } = resolution;
|
|
||||||
if (source !== target) return [source, target];
|
|
||||||
return [target];
|
|
||||||
}
|
|
||||||
return [resolution.target];
|
|
||||||
}
|
|
||||||
|
|
||||||
function isCbAnim(skill) {
|
function isCbAnim(skill) {
|
||||||
return ['Attack', 'Blast', 'Siphon', 'SiphonTick', 'Strike', 'Chaos', 'Slay', 'Heal',
|
return ['Attack', 'Blast', 'Siphon', 'SiphonTick', 'Strike', 'Chaos', 'Slay', 'Heal',
|
||||||
@ -81,7 +79,6 @@ function isCbAnim(skill) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getFocusTargets,
|
|
||||||
getObjects,
|
getObjects,
|
||||||
isCbAnim,
|
isCbAnim,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -89,22 +89,24 @@ function registerEvents(store) {
|
|||||||
const newRes = game.events[currentGame.events.length];
|
const newRes = game.events[currentGame.events.length];
|
||||||
return eachSeries(newRes, (r, cb) => {
|
return eachSeries(newRes, (r, cb) => {
|
||||||
const timeout = r.delay;
|
const timeout = r.delay;
|
||||||
const anims = animations.getObjects(r, game, account);
|
|
||||||
|
|
||||||
if (r.variant[0].includes('Hit')) {
|
if (r.variant[0].includes('Hit')) {
|
||||||
|
const anims = animations.getObjects(r, game, account);
|
||||||
|
|
||||||
if (r.variant[0] === 'HitCast') {
|
if (r.variant[0] === 'HitCast') {
|
||||||
store.dispatch(actions.setAnimSource(anims.animSource));
|
store.dispatch(actions.setAnimSource(anims.animSource));
|
||||||
}
|
}
|
||||||
const { skill } = r.variant[1];
|
store.dispatch(actions.setAnimFocus(anims.focusTargets));
|
||||||
store.dispatch(actions.setAnimFocus(animations.getFocusTargets(r, game)));
|
store.dispatch(actions.setAnimSkill(anims.skill));
|
||||||
store.dispatch(actions.setAnimSkill(skill));
|
|
||||||
store.dispatch(actions.setAnimTarget(anims.animTarget));
|
store.dispatch(actions.setAnimTarget(anims.animTarget));
|
||||||
store.dispatch(actions.setAnimText(null));
|
store.dispatch(actions.setAnimText(null));
|
||||||
if (animations.isCbAnim(skill)) store.dispatch(actions.setAnimCb(cb));
|
|
||||||
|
if (animations.isCbAnim(anims.skill)) store.dispatch(actions.setAnimCb(cb));
|
||||||
|
|
||||||
return setTimeout(() => {
|
return setTimeout(() => {
|
||||||
store.dispatch(actions.setAnimSource(null));
|
store.dispatch(actions.setAnimSource(null));
|
||||||
store.dispatch(actions.setAnimTarget(null));
|
store.dispatch(actions.setAnimTarget(null));
|
||||||
if (r.variant[0].includes('Hit') && animations.isCbAnim(r.variant[1].skill)) return true;
|
if (r.variant[0].includes('Hit') && animations.isCbAnim(anims.skill)) return true;
|
||||||
return cb();
|
return cb();
|
||||||
}, timeout);
|
}, timeout);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user