Merge branch 'master' into turns

This commit is contained in:
ntr 2018-10-20 16:32:45 +11:00
commit 69e1a3fcea
3 changed files with 23 additions and 4 deletions

14
client/src/components/login.component.jsx Normal file → Executable file
View File

@ -1,7 +1,7 @@
// eslint-disable-next-line
const preact = require('preact');
function renderLogin({ account, submitLogin }) {
function renderLogin({ account, submitLogin, submitRegister}) {
if (account) return <div>{JSON.stringify(account)}</div>;
const details = {
@ -42,12 +42,24 @@ function renderLogin({ account, submitLogin }) {
</div>
<div className="field">
<p className="control">
<button
className="button inverted"
type="submit"
onClick={() => submitLogin("ntr", "grepgrepgrep")}>
Default
</button>
<button
className="button inverted"
type="submit"
onClick={() => submitLogin(details.name, details.password)}>
Login
</button>
<button
className="button inverted"
type="submit"
onClick={() => submitRegister(details.name, details.password)}>
Register
</button>
</p>
</div>
</div>

6
client/src/components/login.container.jsx Normal file → Executable file
View File

@ -8,8 +8,10 @@ const addState = connect(
function submitLogin(name, password) {
return ws.sendAccountLogin(name, password);
}
return { account: state.account, submitLogin };
function submitRegister(name, password) {
return ws.sendAccountRegister(name, password);
}
return { account: state.account, submitLogin, submitRegister };
}
);

7
client/src/socket.jsx Normal file → Executable file
View File

@ -24,7 +24,7 @@ function createSocket(store) {
// Connection opened
ws.addEventListener('open', function wsOpen(event) {
send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } });
//send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } });
});
// Listen for messages
@ -101,6 +101,10 @@ function createSocket(store) {
send({ method: 'account_login', params: { name, password } });
}
function sendAccountRegister(name, password) {
send({ method: 'account_create', params: { name, password } });
}
function sendCrypSpawn(name) {
send({ method: 'cryp_spawn', params: { name } });
}
@ -148,6 +152,7 @@ function createSocket(store) {
return {
sendAccountLogin,
sendAccountRegister,
sendCombatPve,
sendCrypSpawn,
sendItemUse,