From b664396ddf6930df6f9006ec397cae6bb7b2234c Mon Sep 17 00:00:00 2001 From: ntr Date: Wed, 3 Apr 2019 23:15:51 +1100 Subject: [PATCH] specs in info --- client/src/components/info.component.jsx | 34 +++++++------- client/src/components/spawn.button.jsx | 59 ++++++++++++++++++++++++ client/src/reducers.jsx | 2 +- client/src/socket.jsx | 2 +- 4 files changed, 77 insertions(+), 20 deletions(-) create mode 100644 client/src/components/spawn.button.jsx diff --git a/client/src/components/info.component.jsx b/client/src/components/info.component.jsx index 283f6766..fac21c21 100644 --- a/client/src/components/info.component.jsx +++ b/client/src/components/info.component.jsx @@ -6,9 +6,7 @@ function Info(args) { info, sendUnequip, } = args; - if (!info) return (
 
); - - console.log(info); + if (!info.length) return (
 
); const [type, value] = info; @@ -29,24 +27,24 @@ function Info(args) { if (type === 'cryp') { const cryp = value; - const stats = [ - { stat: 'hp', disp: 'Hp', colour: '#1FF01F' }, - { stat: 'red_shield', disp: 'Red Shield', colour: '#a52a2a' }, - { stat: 'blue_shield', disp: 'Blue Shield', colour: '#3498db' }, - { stat: 'red_damage', disp: 'Red Damage', colour: '#a52a2a' }, - { stat: 'blue_damage', disp: 'Blue Damage', colour: '#3498db' }, - { stat: 'green_damage', disp: 'Green Damage', colour: '#1FF01F' }, - { stat: 'speed', disp: 'Speed', colour: '#FFD123' }, - ].map((s, i) => ( -
{s.disp}: {cryp[s.stat].max}
- )); - const skills = cryp.skills.map((s, i) => ); + const skills = cryp.skills.map((s, i) => + + ); + + const specs = cryp.specs.map((s, i) => + + ); return (
-
{cryp.name}
- {stats} - {skills} +
{cryp.name}
+
+ {skills} +
+
+ {specs} +
+
); } diff --git a/client/src/components/spawn.button.jsx b/client/src/components/spawn.button.jsx new file mode 100644 index 00000000..b81b2e45 --- /dev/null +++ b/client/src/components/spawn.button.jsx @@ -0,0 +1,59 @@ +const preact = require('preact'); +const { Component } = require('preact'); + +class SpawnButton extends Component { + constructor(props) { + super(props); + + this.state = { value: null, enabled: false }; + + this.handleChange = this.handleChange.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + this.enable = this.enable.bind(this); + } + + handleChange(event) { + this.setState({ value: event.target.value }); + } + + handleSubmit(event) { + event.preventDefault(); + this.props.spawn(this.state.value); + this.setState({ value: null, enabled: false }); + } + + enable() { + this.setState({ enabled: true }); + } + + render() { + return ( +
+
this.enable()} > +

+

+ + +
+
+ ); + } +} + +module.exports = SpawnButton; \ No newline at end of file diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index 12eebe8f..d48b18ad 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -110,7 +110,7 @@ function wsReducer(state = defaultWs, action) { } } -const defaultInfo = null; +const defaultInfo = []; function infoReducer(state = defaultInfo, action) { switch (action.type) { case actions.SET_INFO: diff --git a/client/src/socket.jsx b/client/src/socket.jsx index b1499f7c..e7f08ba3 100644 --- a/client/src/socket.jsx +++ b/client/src/socket.jsx @@ -95,7 +95,7 @@ function createSocket(events) { function sendVboxUnequip(instanceId, crypId, target) { send({ method: 'player_vbox_unequip', params: { instance_id: instanceId, cryp_id: crypId, target } }); - events.setInfo(null); + events.setInfo([]); } function sendVboxDiscard(instanceId) {