From 4496374d509cf3a0dd0d0e23a538b04968ca3074 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 30 May 2019 20:34:50 +1000 Subject: [PATCH 1/4] oldschool animations --- client/src/components/game.component.jsx | 4 +- client/src/components/game.construct.jsx | 4 +- client/src/components/list.jsx | 4 +- client/src/components/team.jsx | 4 +- client/src/utils.jsx | 54 ++++++++++-------------- 5 files changed, 30 insertions(+), 40 deletions(-) diff --git a/client/src/components/game.component.jsx b/client/src/components/game.component.jsx index fe110229..e29837f3 100644 --- a/client/src/components/game.component.jsx +++ b/client/src/components/game.component.jsx @@ -1,5 +1,5 @@ const preact = require('preact'); -const { STATS, eventClasses, getCombatText, constructAvatar } = require('../utils'); +const { STATS, eventClasses, getCombatText, ConstructAvatar } = require('../utils'); // const { animationDivs } = require('../animations'); const GameConstruct = require('./game.construct'); const shapes = require('./shapes'); @@ -164,7 +164,7 @@ function GamePanel(props) {
selectSkillTarget(construct.id)} > - {constructAvatar(construct.name, construct.id)} + {combatTextEl}
diff --git a/client/src/components/game.construct.jsx b/client/src/components/game.construct.jsx index a12d231f..27683c93 100644 --- a/client/src/components/game.construct.jsx +++ b/client/src/components/game.construct.jsx @@ -3,7 +3,7 @@ const preact = require('preact'); const range = require('lodash/range'); const actions = require('../actions'); -const { STATS, eventClasses, getCombatText, constructAvatar } = require('../utils'); +const { STATS, eventClasses, getCombatText, ConstructAvatar } = require('../utils'); const { animationDivs } = require('../animations'); const shapes = require('./shapes'); @@ -105,7 +105,7 @@ function GameConstruct(props) {
selectSkillTarget(construct.id)} > - {constructAvatar(construct.name, construct.id)} + {combatTextEl} {anim}
diff --git a/client/src/components/list.jsx b/client/src/components/list.jsx index 778f9e11..203b7789 100644 --- a/client/src/components/list.jsx +++ b/client/src/components/list.jsx @@ -1,7 +1,7 @@ const { connect } = require('preact-redux'); const preact = require('preact'); -const { stringSort, NULL_UUID, COLOURS, constructAvatar } = require('./../utils'); +const { stringSort, NULL_UUID, COLOURS, ConstructAvatar } = require('./../utils'); const actions = require('./../actions'); const InstanceCreateForm = require('./instance.create.form'); @@ -118,7 +118,7 @@ function List(args) {
- {constructAvatar(construct.name, construct.id)} +

{construct.name}

); diff --git a/client/src/components/team.jsx b/client/src/components/team.jsx index 0acb1b3f..08772138 100644 --- a/client/src/components/team.jsx +++ b/client/src/components/team.jsx @@ -4,7 +4,7 @@ const range = require('lodash/range'); const actions = require('./../actions'); const { COLOURS } = require('./../utils'); -const { stringSort, constructAvatar } = require('./../utils'); +const { stringSort, ConstructAvatar } = require('./../utils'); const SpawnButton = require('./spawn.button'); const idSort = stringSort('id'); @@ -86,7 +86,7 @@ function Team(args) { className="menu-construct" style={ { 'border-color': borderColour || 'whitesmoke' } } onClick={() => selectConstruct(construct.id)} > - {constructAvatar(construct.name, construct.id)} +

{construct.name}

); diff --git a/client/src/utils.jsx b/client/src/utils.jsx index 004a419d..bb57e8e7 100644 --- a/client/src/utils.jsx +++ b/client/src/utils.jsx @@ -1,4 +1,5 @@ const preact = require('preact'); +const { Component } = require('preact'); const get = require('lodash/get'); const anime = require('animejs').default; @@ -78,20 +79,25 @@ function clearAnimation(id) { animations[id] = false; } -function constructAvatar(name, id) { - // useEffect(() => { - // animateConstruct(id); - // return () => clearAnimation(id); - // }); +class ConstructAvatar extends Component { + render() { + return ( + event.target.setAttribute('src', '/molecules/726.svg')} + /> + ); + } - return ( - event.target.setAttribute('src', '/molecules/726.svg')} - /> - ); + componentDidMount() { + animateConstruct(this.props.id); + } + + componentDidUnmount() { + clearAnimation(this.props.id); + } } function instanceConstruct(name, id) { @@ -100,6 +106,8 @@ function instanceConstruct(name, id) { // return () => clearAnimation(id); // }); + setTimeout(() => animateConstruct(id), 50); + return (
{ - // animateConstruct(id); - // return () => clearAnimation(id); - // }); - - return ( -
selectSkillTarget(id)} - style={{ 'background-image': `url(/molecules/${genAvatar(name)}.svg)` }} > - {combatTextEl} -
- ); -} - const NULL_UUID = '00000000-0000-0000-0000-000000000000'; const STATS = { @@ -459,9 +450,8 @@ module.exports = { convertItem, numSort, genAvatar, - constructAvatar, + ConstructAvatar, instanceConstruct, - gameConstructImg, requestAvatar, eventClasses, getCombatSequence, From dd84df3153dcd60410cccd548fa7bc3e05658a15 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 30 May 2019 20:36:13 +1000 Subject: [PATCH 2/4] willunmount --- client/src/utils.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/utils.jsx b/client/src/utils.jsx index bb57e8e7..825899a7 100644 --- a/client/src/utils.jsx +++ b/client/src/utils.jsx @@ -95,7 +95,7 @@ class ConstructAvatar extends Component { animateConstruct(this.props.id); } - componentDidUnmount() { + componentWillUnmount() { clearAnimation(this.props.id); } } From 9fae28e7a83e843051a3432cc8a2cb5402266923 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 30 May 2019 21:01:39 +1000 Subject: [PATCH 3/4] bot actions fix --- server/src/construct.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/construct.rs b/server/src/construct.rs index 5473a563..99425daa 100644 --- a/server/src/construct.rs +++ b/server/src/construct.rs @@ -373,7 +373,7 @@ impl Construct { let i = match available.len() { 1 => 0, - _ => rng.gen_range(0, available.len() - 1), + _ => rng.gen_range(0, available.len()), }; return Some(available[i].skill); From 5e2425a83c87250dda57fb5a9da1791c49feb1d4 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 30 May 2019 21:20:39 +1000 Subject: [PATCH 4/4] login input fix --- client/src/components/login.component.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/components/login.component.jsx b/client/src/components/login.component.jsx index 2e8ba903..43c7671f 100644 --- a/client/src/components/login.component.jsx +++ b/client/src/components/login.component.jsx @@ -14,13 +14,13 @@ function renderLogin({ submitLogin, submitRegister }) { className="login-input" type="email" placeholder="username" - onChange={e => (details.name = e.target.value)} + onInput={e => (details.name = e.target.value)} /> (details.password = e.target.value)} + onInput={e => (details.password = e.target.value)} />