animText -> resolution

This commit is contained in:
Mashy 2019-12-09 08:57:32 +10:00
parent 912b2c9059
commit 445a641b8d
9 changed files with 43 additions and 44 deletions

View File

@ -1,12 +1,11 @@
export const setAccount = value => ({ type: 'SET_ACCOUNT', value });
export const setAnimating = value => ({ type: 'SET_ANIMATING', value });
export const setAnimCb = value => ({ type: 'SET_ANIM_CB', value });
export const setAnimFocus = value => ({ type: 'SET_ANIM_FOCUS', value });
export const setAnimSkill = value => ({ type: 'SET_ANIM_SKILL', value });
export const setAnimSkill = value => ({ type: 'SET_ANIM_SKILL', value });
export const setAnimSource = value => ({ type: 'SET_ANIM_SOURCE', value });
export const setAnimTarget = value => ({ type: 'SET_ANIM_TARGET', value });
export const setAnimText = value => ({ type: 'SET_ANIM_TEXT', value });
export const setResolution = value => ({ type: 'SET_RESOLUTION', value });
export const setDemo = value => ({ type: 'SET_DEMO', value });

View File

@ -51,10 +51,10 @@ function createSocket(store) {
if (r.stages.includes('POST_SKILL') && text) {
// timeout to prevent text classes from being added too soon
if (timeout === TIMES.POST_SKILL_DURATION_MS) {
store.dispatch(actions.setAnimText(text));
store.dispatch(actions.setResolution(text));
} else {
setTimeout(
() => store.dispatch(actions.setAnimText(text)),
() => store.dispatch(actions.setResolution(text)),
timeout - TIMES.POST_SKILL_DURATION_MS
);
}
@ -64,7 +64,7 @@ function createSocket(store) {
store.dispatch(actions.setAnimSkill(null));
store.dispatch(actions.setAnimSource(null));
store.dispatch(actions.setAnimTarget(null));
store.dispatch(actions.setAnimText(null));
store.dispatch(actions.setResolution(null));
store.dispatch(actions.setAnimFocus([]));
if (r.stages.includes('END_SKILL') && animations.isCbAnim(anims.animSkill)) return true;
return cb();
@ -75,7 +75,7 @@ function createSocket(store) {
store.dispatch(actions.setAnimSkill(null));
store.dispatch(actions.setAnimSource(null));
store.dispatch(actions.setAnimTarget(null));
store.dispatch(actions.setAnimText(null));
store.dispatch(actions.setResolution(null));
store.dispatch(actions.setAnimating(false));
store.dispatch(actions.setGameEffectInfo(null));

View File

@ -7,7 +7,7 @@ function setAnimations(r, store, account) {
store.dispatch(actions.setAnimFocus(focus));
if (type === 'Cast') {
store.dispatch(actions.setAnimText(null));
store.dispatch(actions.setResolution(null));
const { construct, player, direction: [x, y] } = variant;
const animY = y && player === account.id ? -1 : y;
@ -22,7 +22,7 @@ function setAnimations(r, store, account) {
}
if (type.includes('Hit')) {
store.dispatch(actions.setAnimText(null));
store.dispatch(actions.setResolution(null));
const { construct, player, direction: [x, y] } = variant;
const animY = y && player === account.id ? -1 : y;
@ -38,14 +38,14 @@ function setAnimations(r, store, account) {
return setTimeout(() => store.dispatch(actions.setAnimTarget(null)), TIMES.TARGET_DURATION_MS);
}
return store.dispatch(actions.setAnimText(r));
return store.dispatch(actions.setResolution(r));
}
function clearAnimations(store) {
store.dispatch(actions.setAnimSkill(null));
store.dispatch(actions.setAnimSource(null));
store.dispatch(actions.setAnimTarget(null));
store.dispatch(actions.setAnimText(null));
store.dispatch(actions.setResolution(null));
store.dispatch(actions.setAnimating(false));
store.dispatch(actions.setGameEffectInfo(null));
store.dispatch(actions.setAnimFocus(null));

View File

@ -13,8 +13,8 @@ const { ConstructAnimation } = require('./animations');
const addState = connect(
function receiveState(state) {
const { animSource, animTarget, animText } = state;
return { animSource, animTarget, animText };
const { animSource, animTarget, resolution } = state;
return { animSource, animTarget, resolution };
}
);
@ -62,9 +62,9 @@ class ConstructAvatar extends Component {
}
componentDidUpdate(prevProps) {
const { animSource, animTarget, animText, construct } = this.props;
const { animSource, animTarget, resolution, construct } = this.props;
// a different text object and text construct
if (animText && animText !== prevProps.animText && animText.constructId === construct.id) {
if (resolution && resolution !== prevProps.resolution && resolution.constructId === construct.id) {
return wiggle(construct.id, this.idle);
}
@ -86,10 +86,10 @@ class ConstructAvatar extends Component {
shouldComponentUpdate(newProps) {
const { animSource, animTarget, animText, construct, mouseOver } = newProps;
const { animSource, animTarget, resolution, construct, mouseOver } = newProps;
if (animSource !== this.props.animSource) return true;
if (animTarget !== this.props.animTarget) return true;
if (animText !== this.props.animText) return true;
if (resolution !== this.props.resolution) return true;
if (construct !== this.props.construct) return true;
if (mouseOver !== this.props.mouseOver) return true;
return false;

View File

@ -7,17 +7,17 @@ const shapes = require('./shapes');
const { removeTier } = require('../utils');
const { TIMES } = require('./../constants');
const addState = connect(({ animText, itemInfo }) => ({ animText, itemInfo }));
const addState = connect(({ resolution, itemInfo }) => ({ resolution, itemInfo }));
class AnimText extends preact.Component {
shouldComponentUpdate(newProps) {
if (newProps.animText !== this.props.animText) return true;
if (newProps.resolution !== this.props.resolution) return true;
return false;
}
componentDidUpdate(prevProps) {
const { animText, construct } = this.props;
if (animText && animText !== prevProps.animText && animText.event[1].construct === construct.id) {
const { resolution, construct } = this.props;
if (resolution && resolution !== prevProps.resolution && resolution.event[1].construct === construct.id) {
anime({
targets: '.combat-text',
top: '40%',
@ -28,10 +28,10 @@ class AnimText extends preact.Component {
}
render() {
const { construct, animText, itemInfo } = this.props;
if (animText && animText.event[1].construct === construct.id) {
const { construct, resolution, itemInfo } = this.props;
if (resolution && resolution.event[1].construct === construct.id) {
const itemSourceDescription = () => {
const itemSource = itemInfo.combos.filter(c => c.item === removeTier(animText.skill));
const itemSource = itemInfo.combos.filter(c => c.item === removeTier(resolution.skill));
const itemSourceInfo = itemSource.length
? `${itemSource[0].components[0]} ${itemSource[0].components[1]} ${itemSource[0].components[2]}`
: false;
@ -40,7 +40,7 @@ class AnimText extends preact.Component {
};
const generateAnimText = () => {
const [type, event] = animText.event;
const [type, event] = resolution.event;
if (type === 'Ko') return <h1><span>KO!</span></h1>;
if (type === 'Disable') {
const { disable } = event;
@ -82,7 +82,7 @@ class AnimText extends preact.Component {
return (
<div class="combat-text">
<h2><span>{animText.skill}</span></h2>
<h2><span>{resolution.skill}</span></h2>
<span>{itemSourceDescription()}</span>
{generateAnimText()}
</div>

View File

@ -7,7 +7,7 @@ const shapes = require('./shapes');
const { INFO } = require('./../constants');
const addState = connect(
({ animText, itemInfo, gameSkillInfo }) => ({ animText, itemInfo, gameSkillInfo }),
({ resolution, itemInfo, gameSkillInfo }) => ({ resolution, itemInfo, gameSkillInfo }),
function receiveDispatch(dispatch) {
function setGameEffectInfo(info) {
@ -21,8 +21,8 @@ const addState = connect(
class GameConstructEffects extends preact.Component {
shouldComponentUpdate(newProps) {
if (newProps.animText && newProps.animText !== this.props.animText) {
const [type, info] = newProps.animText.event;
if (newProps.resolution && newProps.resolution !== this.props.resolution) {
const [type, info] = newProps.resolution.event;
if (info.construct === this.props.construct.id
&& (type === 'Effect' || type === 'Removal')) return true;
}
@ -32,7 +32,7 @@ class GameConstructEffects extends preact.Component {
render() {
const {
animText,
resolution,
construct,
gameSkillInfo,
setGameEffectInfo,
@ -56,7 +56,7 @@ class GameConstructEffects extends preact.Component {
</div>);
}
const effects = animText ? animText.event[1].display.effects : construct.effects;
const effects = resolution ? resolution.event[1].display.effects : construct.effects;
const renderEffects = effects.length
? effects.map(c =>

View File

@ -17,7 +17,7 @@ const addState = connect(
activeSkill,
animFocus,
animText,
resolution,
} = state;
function selectSkillTarget(targetConstructId) {
@ -30,7 +30,7 @@ const addState = connect(
return {
activeSkill,
animFocus,
animText,
resolution,
selectSkillTarget,
};
}
@ -40,7 +40,7 @@ class GameConstruct extends preact.Component {
shouldComponentUpdate(newProps) {
if (newProps.activeSkill !== this.props.activeSkill) return true;
if (newProps.animFocus !== this.props.animFocus) return true;
if (newProps.animText !== this.props.animText) return true;
if (newProps.resolution !== this.props.resolution) return true;
if (newProps.construct !== this.props.construct) return true;
return false;
}
@ -50,13 +50,13 @@ class GameConstruct extends preact.Component {
// Changing state variables
activeSkill,
animFocus,
animText,
resolution,
selectSkillTarget,
construct,
player,
} = this.props;
const koEvent = animText && animText.text === 'KO!' && animText.constructId === construct.id;
const koEvent = resolution && resolution.text === 'KO!' && resolution.constructId === construct.id;
const ko = construct.green_life.value === 0 && !koEvent ? 'ko' : '';
const cssClass = () => {

View File

@ -3,12 +3,12 @@ const { connect } = require('preact-redux');
const shapes = require('./shapes');
const addState = connect(({ animText }) => ({ animText }));
const addState = connect(({ resolution }) => ({ resolution }));
class GameConstructLife extends preact.Component {
shouldComponentUpdate(newProps) {
if (newProps.animText && newProps.animText !== this.props.animText) {
const [type, info] = newProps.animText.event;
if (newProps.resolution && newProps.resolution !== this.props.resolution) {
const [type, info] = newProps.resolution.event;
if (info.construct === this.props.construct.id
&& (type === 'Damage' || type === 'Healing' || type === 'Recharge')) return true;
}
@ -17,7 +17,7 @@ class GameConstructLife extends preact.Component {
}
render() {
const { construct, animText } = this.props;
const { construct, resolution } = this.props;
const lifeBars = (redLife, greenLife, blueLife) => {
return (
<div class="stats">
@ -37,8 +37,8 @@ class GameConstructLife extends preact.Component {
);
};
if (animText) {
const { red, blue, green } = animText.event[1].display;
if (resolution) {
const { red, blue, green } = resolution.event[1].display;
return lifeBars(red, green, blue);
}

View File

@ -14,12 +14,12 @@ module.exports = {
activeSkill: createReducer(null, 'SET_ACTIVE_SKILL'),
animating: createReducer(false, 'SET_ANIMATING'),
animCb: createReducer(null, 'SET_ANIM_CB'),
animSkill: createReducer(null, 'SET_ANIM_SKILL'),
animSource: createReducer(null, 'SET_ANIM_SOURCE'),
animFocus: createReducer(null, 'SET_ANIM_FOCUS'),
animTarget: createReducer(null, 'SET_ANIM_TARGET'),
animText: createReducer(null, 'SET_ANIM_TEXT'),
resolution: createReducer(null, 'SET_RESOLUTION'),
demo: createReducer(null, 'SET_DEMO'),