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