no skillz
This commit is contained in:
parent
621676732d
commit
45cf9d9530
87
client/src/components/instance.create.form.jsx
Normal file
87
client/src/components/instance.create.form.jsx
Normal file
@ -0,0 +1,87 @@
|
||||
const preact = require('preact');
|
||||
const { connect } = require('preact-redux');
|
||||
const { Component } = require('preact');
|
||||
|
||||
const addState = connect(
|
||||
function receiveState(state) {
|
||||
const { ws, selectedCryps } = state;
|
||||
|
||||
function sendInstanceNew(sCryps, name, players) {
|
||||
if (sCryps.length) {
|
||||
return ws.sendInstanceNew(sCryps, name, players);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return {
|
||||
sendInstanceNew,
|
||||
selectedCryps,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
class InstanceCreateForm extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = { players: 1, name: '' };
|
||||
|
||||
const { sendInstanceNew, selectedCryps } = props;
|
||||
|
||||
this.sendInstanceNew = sendInstanceNew.bind(this);
|
||||
|
||||
this.nameChange = this.nameChange.bind(this);
|
||||
this.playersChange = this.playersChange.bind(this);
|
||||
this.handleSubmit = this.handleSubmit.bind(this);
|
||||
}
|
||||
|
||||
playersChange(event) {
|
||||
this.setState({ players: Number(event.target.value) });
|
||||
}
|
||||
|
||||
nameChange(event) {
|
||||
this.setState({ name: event.target.value });
|
||||
}
|
||||
|
||||
handleSubmit(event) {
|
||||
event.preventDefault();
|
||||
this.sendInstanceNew(this.props.selectedCryps, this.state.name, this.state.players);
|
||||
this.setState({ name: '', players: 2 });
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div
|
||||
className="">
|
||||
<div className="create-form">
|
||||
<div>+</div>
|
||||
<label>instance name</label>
|
||||
<input
|
||||
className="login-input"
|
||||
type="text"
|
||||
value={this.state.value}
|
||||
placeholder="name"
|
||||
onChange={this.nameChange}
|
||||
/>
|
||||
<label htmlFor="playerSelect">players</label>
|
||||
<select id="playerSelect"
|
||||
onChange={this.playersChange}
|
||||
>
|
||||
<option value={1}>pve</option>
|
||||
<option selected value={2}>2</option>
|
||||
<option value={4}>4</option>
|
||||
<option value={8}>8</option>
|
||||
<option value={16}>16</option>
|
||||
</select>
|
||||
<button
|
||||
onClick={this.handleSubmit}
|
||||
type="submit">
|
||||
create
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = addState(InstanceCreateForm);
|
||||
@ -138,6 +138,10 @@ impl Instance {
|
||||
.position(|p| p.id == player_id)
|
||||
.ok_or(err_msg("player_id not found"))?;
|
||||
|
||||
if self.players[i].cryps.iter().all(|c| c.skills.len() == 0) {
|
||||
return Err(err_msg("your cryps have no skills"));
|
||||
}
|
||||
|
||||
self.players[i].set_ready(true);
|
||||
|
||||
if self.phase == InstancePhase::Lobby && self.can_start() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user