Merge branch 'master' of ssh://cryps.gg:40022/~/cryps

This commit is contained in:
ntr 2018-10-20 16:32:24 +11:00
commit 88b947e2fb
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 // eslint-disable-next-line
const preact = require('preact'); const preact = require('preact');
function renderLogin({ account, submitLogin }) { function renderLogin({ account, submitLogin, submitRegister}) {
if (account) return <div>{JSON.stringify(account)}</div>; if (account) return <div>{JSON.stringify(account)}</div>;
const details = { const details = {
@ -42,12 +42,24 @@ function renderLogin({ account, submitLogin }) {
</div> </div>
<div className="field"> <div className="field">
<p className="control"> <p className="control">
<button
className="button inverted"
type="submit"
onClick={() => submitLogin("ntr", "grepgrepgrep")}>
Default
</button>
<button <button
className="button inverted" className="button inverted"
type="submit" type="submit"
onClick={() => submitLogin(details.name, details.password)}> onClick={() => submitLogin(details.name, details.password)}>
Login Login
</button> </button>
<button
className="button inverted"
type="submit"
onClick={() => submitRegister(details.name, details.password)}>
Register
</button>
</p> </p>
</div> </div>
</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) { function submitLogin(name, password) {
return ws.sendAccountLogin(name, password); return ws.sendAccountLogin(name, password);
} }
function submitRegister(name, password) {
return { account: state.account, submitLogin }; 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 // Connection opened
ws.addEventListener('open', function wsOpen(event) { 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 // Listen for messages
@ -101,6 +101,10 @@ function createSocket(store) {
send({ method: 'account_login', params: { name, password } }); send({ method: 'account_login', params: { name, password } });
} }
function sendAccountRegister(name, password) {
send({ method: 'account_create', params: { name, password } });
}
function sendCrypSpawn(name) { function sendCrypSpawn(name) {
send({ method: 'cryp_spawn', params: { name } }); send({ method: 'cryp_spawn', params: { name } });
} }
@ -148,6 +152,7 @@ function createSocket(store) {
return { return {
sendAccountLogin, sendAccountLogin,
sendAccountRegister,
sendCombatPve, sendCombatPve,
sendCrypSpawn, sendCrypSpawn,
sendItemUse, sendItemUse,