This commit is contained in:
ntr 2018-11-29 20:19:17 +11:00
parent 0dd96ae961
commit 38af55aacd
6 changed files with 85 additions and 82 deletions

View File

@ -1,6 +1,7 @@
<!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>

View File

@ -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');
});
}

View File

@ -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,

View File

@ -1,3 +1,18 @@
Pve needs to be good, not many players early on
Randomly generated PVE graph to traverse with scattered rewards
Two types of XP -> Skill xp and Cryp XP
Skill XP allocates points in skill tree
Cryp XP allocates points in Cryp passive tree
Skills can be customised via skill tree
Cryp obiendience a deteoriating bar (placeholder name)
Cryps gain obedience when playing with you in PVE, PVP or using items
Obedience drains over time
Obedience drains faster when training / missions
Having obedience is desirable for getting good rewards
# Principles
* Experience something
* Express something
@ -11,13 +26,9 @@
* skills
* handle setting account better maybe?
* ensure cryp untargetable and doesn't resolve when KO
* remove all statuses etc when KO
* calculate
* hp increase/decrease
* private fields for opponents
* attack
* can you attack yourself?
* write players row for every team+cryp added
* return results<>
* defensive
@ -26,8 +37,6 @@
*
* Items
* unselect item with esc + button
* Grid reroll
* Colour scheme
* Missions
@ -38,8 +47,6 @@
* delete games when a cryp is deleted
* does this need to happen? can have historical games
* run nginx as not root
# Art Styles
* Aztec
* youkai

View File

@ -63,10 +63,10 @@ impl Rpc {
"game_skill" => Rpc::game_skill(data, &mut tx, account.unwrap(), client),
"game_target" => Rpc::game_target(data, &mut tx, account.unwrap(), client),
"account_cryps" => Rpc::account_cryps(data, &mut tx, account.unwrap(), client),
"item_list" => Rpc::item_list(data, &mut tx, account.unwrap(), client),
"account_items" => Rpc::account_items(data, &mut tx, account.unwrap(), client),
"item_use" => Rpc::item_use(data, &mut tx, account.unwrap(), client),
_ => Err(err_msg("unknown method")),
_ => Err(format_err!("unknown method - {:?}", v.method)),
};
tx.commit()?;
@ -258,9 +258,9 @@ impl Rpc {
})
}
fn item_list(_data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
fn account_items(_data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
Ok(RpcResponse {
method: "item_list".to_string(),
method: "account_items".to_string(),
params: RpcResult::ItemList(items_list(tx, &account)?)
})
}