set animfocus server side
This commit is contained in:
parent
261ab1d48b
commit
b405608510
@ -23,22 +23,7 @@ function getAnimTarget(resolution, account) {
|
||||
};
|
||||
}
|
||||
|
||||
function getFocusTargets(resolution, game, account) {
|
||||
if (resolution.variant[1] === 'HitAoe') {
|
||||
const playerTeam = game.players.find(t => t.id === account.id);
|
||||
const playerTeamIds = playerTeam.constructs.map(c => c.id);
|
||||
const otherTeam = game.players.find(t => t.id !== account.id);
|
||||
const otherTeamIds = otherTeam.constructs.map(c => c.id);
|
||||
if (resolution.cast.player === account) return playerTeamIds;
|
||||
return otherTeamIds;
|
||||
}
|
||||
|
||||
const { source, target } = resolution.cast;
|
||||
return [source, target];
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getAnimSource,
|
||||
getAnimTarget,
|
||||
getFocusTargets,
|
||||
};
|
||||
|
||||
@ -5,7 +5,7 @@ const eachSeries = require('async/eachSeries');
|
||||
const sample = require('lodash/sample');
|
||||
|
||||
const actions = require('./actions');
|
||||
const { getAnimSource, getAnimTarget, getFocusTargets } = require('./animations.utils');
|
||||
const { getAnimSource, getAnimTarget } = require('./animations.utils');
|
||||
const { infoToast, errorToast } = require('./utils');
|
||||
const { tutorialVbox } = require('./tutorial.utils');
|
||||
const { TIMES } = require('./constants');
|
||||
@ -90,18 +90,19 @@ function registerEvents(store) {
|
||||
const newRes = game.events[currentGame.events.length];
|
||||
return eachSeries(newRes, (r, cb) => {
|
||||
const timeout = r.delay;
|
||||
const focusTargets = getFocusTargets(r, game, account);
|
||||
store.dispatch(actions.setAnimFocus(focusTargets));
|
||||
store.dispatch(actions.setAnimFocus(r.focus));
|
||||
|
||||
if (r.variant[0] === 'Cast') {
|
||||
const animSource = getAnimSource(r, account);
|
||||
store.dispatch(actions.setAnimSource(animSource));
|
||||
store.dispatch(actions.setAnimText(null));
|
||||
|
||||
setTimeout(() => store.dispatch(actions.setAnimSource(null)), TIMES.SOURCE_DURATION_MS);
|
||||
} else if (r.variant[0].includes('Hit')) {
|
||||
const animTarget = getAnimTarget(r, account);
|
||||
store.dispatch(actions.setAnimTarget(animTarget));
|
||||
store.dispatch(actions.setAnimText(null));
|
||||
|
||||
setTimeout(() => store.dispatch(actions.setAnimTarget(null)), TIMES.TARGET_DURATION_MS);
|
||||
} else {
|
||||
store.dispatch(actions.setAnimText(r));
|
||||
|
||||
@ -231,6 +231,7 @@ pub type Disable = Vec<Effect>;
|
||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||
pub struct Event {
|
||||
pub cast: Cast,
|
||||
pub focus: Vec<Uuid>,
|
||||
pub variant: EventVariant,
|
||||
pub delay: i64,
|
||||
}
|
||||
@ -274,8 +275,14 @@ impl EventVariant {
|
||||
|
||||
pub fn to_event(&self, cast: Cast) -> Event {
|
||||
let delay = self.delay();
|
||||
let focus = match self {
|
||||
EventVariant::HitAoe { target: _ } => vec![cast.source, cast.target], // some tricky multi target here l8r
|
||||
_ => vec![cast.source, cast.target],
|
||||
};
|
||||
|
||||
Event {
|
||||
cast,
|
||||
focus,
|
||||
variant: *self,
|
||||
delay,
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user