clientside rounds changes

This commit is contained in:
ntr
2019-06-06 00:03:27 +10:00
parent 1f5fba80f1
commit 6e513e3da7
9 changed files with 95 additions and 159 deletions
+1 -1
View File
@@ -23,8 +23,8 @@ document.fonts.load('16pt "Jura"').then(() => {
setupKeys(store);
const ws = createSocket(events);
store.dispatch(actions.setWs(ws));
ws.connect();
events.setWs(ws);
const App = () => (
<Provider store={store}>
+1 -1
View File
@@ -65,7 +65,7 @@ function Instance(args) {
<tr key={i}
className={p.ready ? 'ready' : ''}>
<td>{p.name}</td>
<td>{p.score.wins} / {p.score.losses}</td>
<td>{p.wins} / {p.losses}</td>
<td>{pText}</td>
</tr>
);
+15 -19
View File
@@ -6,9 +6,9 @@ const addState = connect(
function receiveState(state) {
const { ws, team } = state;
function sendInstanceNew(sConstructs, name, players) {
function sendInstanceNew(sConstructs, name, pve) {
if (sConstructs.length) {
return ws.sendInstanceNew(sConstructs, name, players);
return ws.sendInstanceNew(sConstructs, name, pve);
}
return false;
}
@@ -24,19 +24,19 @@ class InstanceCreateForm extends Component {
constructor(props) {
super(props);
this.state = { players: 2, name: '' };
this.state = { pve: false, name: '' };
const { sendInstanceNew } = props;
this.sendInstanceNew = sendInstanceNew.bind(this);
this.nameInput = this.nameInput.bind(this);
this.playersChange = this.playersChange.bind(this);
this.pveChange = this.pveChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
playersChange(event) {
this.setState({ players: Number(event.target.value) });
pveChange() {
this.setState({ pve: !this.state.pve });
}
nameInput(event) {
@@ -45,8 +45,8 @@ class InstanceCreateForm extends Component {
handleSubmit(event) {
event.preventDefault();
this.sendInstanceNew(this.props.team, this.state.name, this.state.players);
this.setState({ name: '', players: 2 });
this.sendInstanceNew(this.props.team, this.state.name, this.state.pve);
this.setState({ name: '', pve: false });
}
render() {
@@ -62,21 +62,17 @@ class InstanceCreateForm extends Component {
type="text"
disabled={disabled}
value={this.state.name}
placeholder="name"
placeholder="game name"
onInput={this.nameInput}
/>
<label htmlFor="playerSelect">players</label>
<select id="playerSelect"
<label htmlFor="pveSelect">vs CPU</label>
<input id="pveSelect"
type="checkbox"
disabled={disabled}
value={this.state.players}
onChange={this.playersChange}
checked={this.state.pve}
onChange={this.pveChange}
>
<option value={1}>pve</option>
<option value={2}>2</option>
<option value={4}>4</option>
<option value={8}>8</option>
<option value={16}>16</option>
</select>
</input>
</form>
<button
onClick={this.handleSubmit}
+1 -1
View File
@@ -56,7 +56,7 @@ function List(args) {
const instancePanels = instanceList.map(instance => {
const player = instance.players.find(p => p.id === account.id);
const scoreText = player
? `${player.score.wins} : ${player.score.losses}`
? `${player.wins} : ${player.losses}`
: '';
function instanceClick() {
+3 -2
View File
@@ -125,8 +125,8 @@ function createSocket(events) {
send({ method: 'instance_join', params: { instance_id: instanceId, construct_ids: constructs } });
}
function sendInstanceNew(constructs, name, players) {
send({ method: 'instance_new', params: { construct_ids: constructs, name, players } });
function sendInstanceNew(constructs, name, pve) {
send({ method: 'instance_new', params: { construct_ids: constructs, name, pve } });
}
function sendInstanceReady(instanceId) {
@@ -284,6 +284,7 @@ function createSocket(events) {
if (account) {
events.setAccount(account);
sendAccountInstances();
sendInstanceList();
sendAccountConstructs();
}