Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c7ee7361dd
2
client/assets/styles/skeleton.css
vendored
2
client/assets/styles/skeleton.css
vendored
@ -172,7 +172,7 @@ input[type="reset"],
|
|||||||
input[type="button"] {
|
input[type="button"] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 38px;
|
height: 38px;
|
||||||
padding: 0 30px;
|
/*padding: 0 2em;*/
|
||||||
color: #555;
|
color: #555;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
|
|||||||
@ -8,6 +8,7 @@ export const setNav = value => ({ type: 'SET_NAV', value });
|
|||||||
export const setShowNav = value => ({ type: 'SET_SHOW_NAV', value });
|
export const setShowNav = value => ({ type: 'SET_SHOW_NAV', value });
|
||||||
export const setInstance = value => ({ type: 'SET_INSTANCE', value });
|
export const setInstance = value => ({ type: 'SET_INSTANCE', value });
|
||||||
export const setPing = value => ({ type: 'SET_PING', value });
|
export const setPing = value => ({ type: 'SET_PING', value });
|
||||||
|
export const setPlayer = value => ({ type: 'SET_PLAYER', value });
|
||||||
export const setGame = value => ({ type: 'SET_GAME', value });
|
export const setGame = value => ({ type: 'SET_GAME', value });
|
||||||
export const setResolution = value => ({ type: 'SET_RESOLUTION', value });
|
export const setResolution = value => ({ type: 'SET_RESOLUTION', value });
|
||||||
export const setShowLog = value => ({ type: 'SET_SHOW_LOG', value });
|
export const setShowLog = value => ({ type: 'SET_SHOW_LOG', value });
|
||||||
|
|||||||
@ -11,12 +11,9 @@ function InfoComponent(args) {
|
|||||||
itemInfo,
|
itemInfo,
|
||||||
|
|
||||||
combiner,
|
combiner,
|
||||||
instance,
|
player,
|
||||||
account,
|
|
||||||
} = args;
|
} = args;
|
||||||
|
|
||||||
const player = instance.players.find(p => p.id === account.id);
|
|
||||||
|
|
||||||
function Info() {
|
function Info() {
|
||||||
if (!info) return false;
|
if (!info) return false;
|
||||||
const fullInfo = itemInfo.items.find(i => i.item === info) || INFO[info];
|
const fullInfo = itemInfo.items.find(i => i.item === info) || INFO[info];
|
||||||
|
|||||||
@ -11,6 +11,7 @@ const addState = connect(
|
|||||||
info,
|
info,
|
||||||
itemInfo,
|
itemInfo,
|
||||||
instance,
|
instance,
|
||||||
|
player,
|
||||||
account,
|
account,
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ const addState = connect(
|
|||||||
info,
|
info,
|
||||||
itemInfo,
|
itemInfo,
|
||||||
instance,
|
instance,
|
||||||
|
player,
|
||||||
account,
|
account,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@ -10,8 +10,7 @@ const actions = require('../actions');
|
|||||||
|
|
||||||
const addState = connect(
|
const addState = connect(
|
||||||
function receiveState(state) {
|
function receiveState(state) {
|
||||||
const { ws, instance, account, nav } = state;
|
const { ws, instance, player, account, nav } = state;
|
||||||
const player = instance.players.find(p => p.id === account.id);
|
|
||||||
|
|
||||||
function sendInstanceReady() {
|
function sendInstanceReady() {
|
||||||
return ws.sendInstanceReady(instance.id);
|
return ws.sendInstanceReady(instance.id);
|
||||||
|
|||||||
@ -8,8 +8,7 @@ const actions = require('../actions');
|
|||||||
|
|
||||||
const addState = connect(
|
const addState = connect(
|
||||||
function receiveState(state) {
|
function receiveState(state) {
|
||||||
const { ws, instance, account, itemInfo, itemEquip, activeConstruct } = state;
|
const { ws, instance, player, account, itemInfo, itemEquip, activeConstruct } = state;
|
||||||
const player = instance.players.find(p => p.id === account.id);
|
|
||||||
|
|
||||||
function sendInstanceReady() {
|
function sendInstanceReady() {
|
||||||
return ws.sendInstanceReady(instance.id);
|
return ws.sendInstanceReady(instance.id);
|
||||||
|
|||||||
@ -8,8 +8,7 @@ const { convertItem } = require('./../utils');
|
|||||||
|
|
||||||
const addState = connect(
|
const addState = connect(
|
||||||
function receiveState(state) {
|
function receiveState(state) {
|
||||||
const { account, activeConstruct, itemInfo, info, ws, instance, itemUnequip } = state;
|
const { account, activeConstruct, itemInfo, info, ws, instance, player, itemUnequip } = state;
|
||||||
const player = instance.players.find(p => p.id === account.id);
|
|
||||||
|
|
||||||
function sendUnequip(constructId, item) {
|
function sendUnequip(constructId, item) {
|
||||||
return ws.sendVboxUnequip(instance.id, constructId, item);
|
return ws.sendVboxUnequip(instance.id, constructId, item);
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
// eslint-disable-next-line
|
|
||||||
const preact = require('preact');
|
|
||||||
|
|
||||||
function renderLogin({ submitLogin, submitRegister }) {
|
|
||||||
const details = {
|
|
||||||
name: '',
|
|
||||||
password: '',
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<main>
|
|
||||||
<div className="login">
|
|
||||||
<input
|
|
||||||
className="login-input"
|
|
||||||
type="email"
|
|
||||||
placeholder="username"
|
|
||||||
onInput={e => (details.name = e.target.value)}
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
className="login-input"
|
|
||||||
type="password"
|
|
||||||
placeholder="password"
|
|
||||||
onInput={e => (details.password = e.target.value)}
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
className="login-btn"
|
|
||||||
onClick={() => submitLogin(details.name, details.password)}>
|
|
||||||
Login
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="login-btn"
|
|
||||||
onClick={() => submitRegister(details.name, details.password)}>
|
|
||||||
Register
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="login-btn"
|
|
||||||
onClick={() => document.location.assign('https://discord.gg/YJJgurM')}>
|
|
||||||
Discord + Invites
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = renderLogin;
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
const { connect } = require('preact-redux');
|
|
||||||
|
|
||||||
const Login = require('./login.component');
|
|
||||||
|
|
||||||
const addState = connect(
|
|
||||||
(state) => {
|
|
||||||
const { ws, account } = state;
|
|
||||||
function submitLogin(name, password) {
|
|
||||||
return ws.sendAccountLogin(name, password);
|
|
||||||
}
|
|
||||||
function submitRegister(name, password) {
|
|
||||||
console.log(name, password);
|
|
||||||
return ws.sendAccountCreate(name, password);
|
|
||||||
}
|
|
||||||
return { account, submitLogin, submitRegister };
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
module.exports = addState(Login);
|
|
||||||
93
client/src/components/login.jsx
Normal file
93
client/src/components/login.jsx
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
// eslint-disable-next-line
|
||||||
|
const preact = require('preact');
|
||||||
|
const { Component } = require('preact')
|
||||||
|
const { connect } = require('preact-redux');
|
||||||
|
|
||||||
|
const addState = connect(
|
||||||
|
(state) => {
|
||||||
|
const { ws, account } = state;
|
||||||
|
function submitLogin(name, password) {
|
||||||
|
return ws.sendAccountLogin(name, password);
|
||||||
|
}
|
||||||
|
function submitRegister(name, password) {
|
||||||
|
console.log(name, password);
|
||||||
|
return ws.sendAccountCreate(name, password);
|
||||||
|
}
|
||||||
|
return { account, submitLogin, submitRegister };
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
class Login extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.state = { name: '', password: '' };
|
||||||
|
|
||||||
|
this.nameInput = this.nameInput.bind(this);
|
||||||
|
this.passwordInput = this.passwordInput.bind(this);
|
||||||
|
this.loginSubmit = this.loginSubmit.bind(this);
|
||||||
|
this.registerSubmit = this.registerSubmit.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
nameInput(event) {
|
||||||
|
console.log(event.target.value);
|
||||||
|
this.setState({ name: event.target.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
passwordInput(event) {
|
||||||
|
this.setState({ password: event.target.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
loginSubmit(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
console.log(this.state);
|
||||||
|
this.props.submitLogin(this.state.name, this.state.password);
|
||||||
|
this.setState({ name: '', password: '' });
|
||||||
|
}
|
||||||
|
|
||||||
|
registerSubmit(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
this.props.submitRegister(this.state.name, this.state.password);
|
||||||
|
console.log(this.state);
|
||||||
|
this.setState({ name: '', password: '' });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<main>
|
||||||
|
<div className="login">
|
||||||
|
<input
|
||||||
|
className="login-input"
|
||||||
|
type="email"
|
||||||
|
placeholder="username"
|
||||||
|
onInput={this.nameInput}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
className="login-input"
|
||||||
|
type="password"
|
||||||
|
placeholder="password"
|
||||||
|
onInput={this.passwordInput}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
className="login-btn"
|
||||||
|
onClick={this.loginSubmit}>
|
||||||
|
Login
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="login-btn"
|
||||||
|
onClick={this.registerSubmit}>
|
||||||
|
Register
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="login-btn"
|
||||||
|
onClick={() => document.location.assign('https://discord.gg/YJJgurM')}>
|
||||||
|
Discord + Invites
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = addState(Login);
|
||||||
@ -2,7 +2,7 @@
|
|||||||
const preact = require('preact');
|
const preact = require('preact');
|
||||||
const { connect } = require('preact-redux');
|
const { connect } = require('preact-redux');
|
||||||
|
|
||||||
const LoginContainer = require('./login.container');
|
const Login = require('./login');
|
||||||
const GameContainer = require('./game.container');
|
const GameContainer = require('./game.container');
|
||||||
const Instance = require('./instance.component');
|
const Instance = require('./instance.component');
|
||||||
const Team = require('./team');
|
const Team = require('./team');
|
||||||
@ -24,7 +24,7 @@ function Main(props) {
|
|||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return <LoginContainer />;
|
return <Login />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game) {
|
if (game) {
|
||||||
@ -35,6 +35,8 @@ function Main(props) {
|
|||||||
return <Instance />;
|
return <Instance />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.warn('nav', nav, instance, game)
|
||||||
|
|
||||||
if (nav === 'team') return <Team />;
|
if (nav === 'team') return <Team />;
|
||||||
if (nav === 'list') return <List />;
|
if (nav === 'list') return <List />;
|
||||||
|
|
||||||
|
|||||||
@ -10,16 +10,14 @@ const addState = connect(
|
|||||||
function receiveState(state) {
|
function receiveState(state) {
|
||||||
const {
|
const {
|
||||||
ws,
|
ws,
|
||||||
account,
|
|
||||||
instance,
|
instance,
|
||||||
|
player,
|
||||||
combiner,
|
combiner,
|
||||||
reclaiming,
|
reclaiming,
|
||||||
vboxHighlight,
|
vboxHighlight,
|
||||||
itemInfo,
|
itemInfo,
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
const player = instance.players.find(p => p.id === account.id);
|
|
||||||
|
|
||||||
function sendVboxDiscard() {
|
function sendVboxDiscard() {
|
||||||
return ws.sendVboxDiscard(instance.id);
|
return ws.sendVboxDiscard(instance.id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -120,9 +120,12 @@ function registerEvents(store) {
|
|||||||
if (v) {
|
if (v) {
|
||||||
ws.startInstanceStateTimeout(v.id);
|
ws.startInstanceStateTimeout(v.id);
|
||||||
|
|
||||||
|
const player = v.players.find(p => p.id === account.id);
|
||||||
|
store.dispatch(actions.setPlayer(player));
|
||||||
|
|
||||||
if (!instance || v.id !== instance.id) {
|
if (!instance || v.id !== instance.id) {
|
||||||
store.dispatch(actions.setNav('vbox'));
|
store.dispatch(actions.setNav('vbox'));
|
||||||
const first = v.players.find(p => p.id === account.id).constructs[0];
|
const first = player.constructs[0];
|
||||||
store.dispatch(actions.setActiveConstruct(first));
|
store.dispatch(actions.setActiveConstruct(first));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@ module.exports = {
|
|||||||
nav: createReducer(null, 'SET_NAV'),
|
nav: createReducer(null, 'SET_NAV'),
|
||||||
showNav: createReducer(null, 'SET_SHOW_NAV'),
|
showNav: createReducer(null, 'SET_SHOW_NAV'),
|
||||||
ping: createReducer(null, 'SET_PING'),
|
ping: createReducer(null, 'SET_PING'),
|
||||||
|
player: createReducer(null, 'SET_PLAYER'),
|
||||||
reclaiming: createReducer(false, 'SET_RECLAIMING'),
|
reclaiming: createReducer(false, 'SET_RECLAIMING'),
|
||||||
resolution: createReducer(null, 'SET_RESOLUTION'),
|
resolution: createReducer(null, 'SET_RESOLUTION'),
|
||||||
showLog: createReducer(false, 'SET_SHOW_LOG'),
|
showLog: createReducer(false, 'SET_SHOW_LOG'),
|
||||||
|
|||||||
@ -4,11 +4,7 @@ use tungstenite::Message::Binary;
|
|||||||
use postgres::transaction::Transaction;
|
use postgres::transaction::Transaction;
|
||||||
use std::net::{TcpStream};
|
use std::net::{TcpStream};
|
||||||
|
|
||||||
// demo
|
|
||||||
use std::iter;
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use rand::{thread_rng, Rng};
|
|
||||||
use rand::distributions::{Alphanumeric};
|
|
||||||
|
|
||||||
use serde_cbor::{from_slice, to_vec};
|
use serde_cbor::{from_slice, to_vec};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
@ -353,11 +349,6 @@ impl Rpc {
|
|||||||
params: RpcResult::InstanceState(vbox_apply(msg.params, tx, &account)?)
|
params: RpcResult::InstanceState(vbox_apply(msg.params, tx, &account)?)
|
||||||
};
|
};
|
||||||
|
|
||||||
Rpc::send_msg(client, RpcResponse {
|
|
||||||
method: "account_constructs".to_string(),
|
|
||||||
params: RpcResult::ConstructList(account_constructs(tx, &account)?)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,11 +371,6 @@ impl Rpc {
|
|||||||
params: RpcResult::InstanceState(vbox_unequip(msg.params, tx, &account)?)
|
params: RpcResult::InstanceState(vbox_unequip(msg.params, tx, &account)?)
|
||||||
};
|
};
|
||||||
|
|
||||||
Rpc::send_msg(client, RpcResponse {
|
|
||||||
method: "account_constructs".to_string(),
|
|
||||||
params: RpcResult::ConstructList(account_constructs(tx, &account)?)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user