title
This commit is contained in:
+12
-11
@@ -1,12 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script defer src="https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
|
||||
<link rel="stylesheet" href="./node_modules/izitoast/dist/css/iziToast.min.css"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
<script src="./index.js"></script>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>cryps.gg - mnml pvp tbs</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script defer src="https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
|
||||
<link rel="stylesheet" href="./node_modules/izitoast/dist/css/iziToast.min.css"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
<script src="./index.js"></script>
|
||||
</html>
|
||||
@@ -115,9 +115,9 @@ function registerEvents(registry, events) {
|
||||
],
|
||||
});
|
||||
|
||||
const prompt = document.querySelector('#login'); // Selector of your toast
|
||||
events.once('ACCOUNT', function closeLoginCb() {
|
||||
toast.hide({ transitionOut: 'fadeOut' }, prompt, 'event');
|
||||
const prompt = document.querySelector('#login'); // Selector of your toast
|
||||
if (prompt) toast.hide({ transitionOut: 'fadeOut' }, prompt, 'event');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+16
-21
@@ -15,8 +15,6 @@ function errorToast(err) {
|
||||
function createSocket(events) {
|
||||
let ws;
|
||||
|
||||
let gameStateTimeout;
|
||||
|
||||
function connect() {
|
||||
ws = new WebSocket(SOCKET_URL);
|
||||
ws.binaryType = 'arraybuffer';
|
||||
@@ -29,7 +27,7 @@ function createSocket(events) {
|
||||
});
|
||||
|
||||
events.loginPrompt();
|
||||
if (!process.env.NODE_ENV === 'production') {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } });
|
||||
}
|
||||
});
|
||||
@@ -64,9 +62,9 @@ function createSocket(events) {
|
||||
|
||||
account = login;
|
||||
events.setAccount(login);
|
||||
send({ method: 'account_cryps', params: {} });
|
||||
send({ method: 'item_list', params: {} });
|
||||
console.log(account);
|
||||
sendAccountItems();
|
||||
sendAccountCryps();
|
||||
sendGameJoinableList();
|
||||
}
|
||||
|
||||
function accountCryps(response) {
|
||||
@@ -86,15 +84,13 @@ function createSocket(events) {
|
||||
|
||||
function crypSpawn(response) {
|
||||
const [structName, cryp] = response;
|
||||
console.log('got a new cryp', cryp);
|
||||
}
|
||||
|
||||
function gamePve(response) {
|
||||
const [structName, game] = response;
|
||||
console.log('got a new game', game);
|
||||
}
|
||||
|
||||
function itemList(response) {
|
||||
function accountItems(response) {
|
||||
const [structName, items] = response;
|
||||
events.setItems(items);
|
||||
}
|
||||
@@ -116,6 +112,14 @@ function createSocket(events) {
|
||||
send({ method: 'account_create', params: { name, password } });
|
||||
}
|
||||
|
||||
function sendAccountCryps() {
|
||||
send({ method: 'account_cryps', params: {} });
|
||||
}
|
||||
|
||||
function sendAccountItems() {
|
||||
send({ method: 'account_items', params: {} });
|
||||
}
|
||||
|
||||
function sendCrypSpawn(name) {
|
||||
send({ method: 'cryp_spawn', params: { name } });
|
||||
}
|
||||
@@ -170,15 +174,6 @@ function createSocket(events) {
|
||||
events.setActiveItem(null);
|
||||
}
|
||||
|
||||
|
||||
// -------------
|
||||
// Events
|
||||
// -------------
|
||||
|
||||
function clearGameStateInterval() {
|
||||
clearInterval(gameStateTimeout);
|
||||
}
|
||||
|
||||
// -------------
|
||||
// Handling
|
||||
// -------------
|
||||
@@ -192,7 +187,7 @@ function createSocket(events) {
|
||||
account_login: accountLogin,
|
||||
account_create: accountLogin,
|
||||
account_cryps: accountCryps,
|
||||
item_list: itemList,
|
||||
account_items: accountItems,
|
||||
};
|
||||
|
||||
// decodes the cbor and
|
||||
@@ -201,7 +196,6 @@ function createSocket(events) {
|
||||
// decode binary msg from server
|
||||
const blob = new Uint8Array(event.data);
|
||||
const res = cbor.decode(blob);
|
||||
console.log(res);
|
||||
|
||||
// check for error and split into response type and data
|
||||
if (res.err) return errorToast(res.err);
|
||||
@@ -211,9 +205,10 @@ function createSocket(events) {
|
||||
}
|
||||
|
||||
return {
|
||||
clearGameStateInterval,
|
||||
sendAccountLogin,
|
||||
sendAccountCreate,
|
||||
sendAccountCryps,
|
||||
sendAccountItems,
|
||||
sendGameState,
|
||||
sendGamePve,
|
||||
sendGamePvp,
|
||||
|
||||
Reference in New Issue
Block a user