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,12 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <title>cryps.gg - mnml pvp tbs</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta charset="utf-8">
<script defer src="https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./node_modules/izitoast/dist/css/iziToast.min.css"></script> <script defer src="https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
</head> <link rel="stylesheet" href="./node_modules/izitoast/dist/css/iziToast.min.css"></script>
<body> </head>
</body> <body>
<script src="./index.js"></script> </body>
<script src="./index.js"></script>
</html> </html>

View File

@ -115,9 +115,9 @@ function registerEvents(registry, events) {
], ],
}); });
const prompt = document.querySelector('#login'); // Selector of your toast
events.once('ACCOUNT', function closeLoginCb() { 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) { function createSocket(events) {
let ws; let ws;
let gameStateTimeout;
function connect() { function connect() {
ws = new WebSocket(SOCKET_URL); ws = new WebSocket(SOCKET_URL);
ws.binaryType = 'arraybuffer'; ws.binaryType = 'arraybuffer';
@ -29,7 +27,7 @@ function createSocket(events) {
}); });
events.loginPrompt(); events.loginPrompt();
if (!process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV !== 'production') {
send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } }); send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } });
} }
}); });
@ -64,9 +62,9 @@ function createSocket(events) {
account = login; account = login;
events.setAccount(login); events.setAccount(login);
send({ method: 'account_cryps', params: {} }); sendAccountItems();
send({ method: 'item_list', params: {} }); sendAccountCryps();
console.log(account); sendGameJoinableList();
} }
function accountCryps(response) { function accountCryps(response) {
@ -86,15 +84,13 @@ function createSocket(events) {
function crypSpawn(response) { function crypSpawn(response) {
const [structName, cryp] = response; const [structName, cryp] = response;
console.log('got a new cryp', cryp);
} }
function gamePve(response) { function gamePve(response) {
const [structName, game] = response; const [structName, game] = response;
console.log('got a new game', game);
} }
function itemList(response) { function accountItems(response) {
const [structName, items] = response; const [structName, items] = response;
events.setItems(items); events.setItems(items);
} }
@ -116,6 +112,14 @@ function createSocket(events) {
send({ method: 'account_create', params: { name, password } }); send({ method: 'account_create', params: { name, password } });
} }
function sendAccountCryps() {
send({ method: 'account_cryps', params: {} });
}
function sendAccountItems() {
send({ method: 'account_items', params: {} });
}
function sendCrypSpawn(name) { function sendCrypSpawn(name) {
send({ method: 'cryp_spawn', params: { name } }); send({ method: 'cryp_spawn', params: { name } });
} }
@ -170,15 +174,6 @@ function createSocket(events) {
events.setActiveItem(null); events.setActiveItem(null);
} }
// -------------
// Events
// -------------
function clearGameStateInterval() {
clearInterval(gameStateTimeout);
}
// ------------- // -------------
// Handling // Handling
// ------------- // -------------
@ -192,7 +187,7 @@ function createSocket(events) {
account_login: accountLogin, account_login: accountLogin,
account_create: accountLogin, account_create: accountLogin,
account_cryps: accountCryps, account_cryps: accountCryps,
item_list: itemList, account_items: accountItems,
}; };
// decodes the cbor and // decodes the cbor and
@ -201,7 +196,6 @@ function createSocket(events) {
// decode binary msg from server // decode binary msg from server
const blob = new Uint8Array(event.data); const blob = new Uint8Array(event.data);
const res = cbor.decode(blob); const res = cbor.decode(blob);
console.log(res);
// check for error and split into response type and data // check for error and split into response type and data
if (res.err) return errorToast(res.err); if (res.err) return errorToast(res.err);
@ -211,9 +205,10 @@ function createSocket(events) {
} }
return { return {
clearGameStateInterval,
sendAccountLogin, sendAccountLogin,
sendAccountCreate, sendAccountCreate,
sendAccountCryps,
sendAccountItems,
sendGameState, sendGameState,
sendGamePve, sendGamePve,
sendGamePvp, 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 # Principles
* Experience something * Experience something
* Express something * Express something
@ -11,13 +26,9 @@
* skills * skills
* handle setting account better maybe? * handle setting account better maybe?
* ensure cryp untargetable and doesn't resolve when KO
* remove all statuses etc when KO
* calculate * calculate
* hp increase/decrease * hp increase/decrease
* private fields for opponents * private fields for opponents
* attack
* can you attack yourself?
* write players row for every team+cryp added * write players row for every team+cryp added
* return results<> * return results<>
* defensive * defensive
@ -26,8 +37,6 @@
* *
* Items * Items
* unselect item with esc + button
* Grid reroll
* Colour scheme * Colour scheme
* Missions * Missions
@ -38,8 +47,6 @@
* delete games when a cryp is deleted * delete games when a cryp is deleted
* does this need to happen? can have historical games * does this need to happen? can have historical games
* run nginx as not root
# Art Styles # Art Styles
* Aztec * Aztec
* youkai * youkai

View File

@ -1,36 +1,36 @@
extern crate rand; extern crate rand;
extern crate uuid; extern crate uuid;
extern crate tungstenite; extern crate tungstenite;
extern crate env_logger; extern crate env_logger;
extern crate bcrypt; extern crate bcrypt;
extern crate dotenv; extern crate dotenv;
extern crate petgraph; extern crate petgraph;
extern crate postgres; extern crate postgres;
extern crate r2d2; extern crate r2d2;
extern crate r2d2_postgres; extern crate r2d2_postgres;
extern crate serde; extern crate serde;
extern crate serde_cbor; extern crate serde_cbor;
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;
#[macro_use] extern crate failure; #[macro_use] extern crate failure;
// #[macro_use] extern crate failure_derive; // #[macro_use] extern crate failure_derive;
mod cryp; mod cryp;
mod game; mod game;
mod net; mod net;
mod skill; mod skill;
mod passives; mod passives;
mod rpc; mod rpc;
mod account; mod account;
mod item; mod item;
use dotenv::dotenv; use dotenv::dotenv;
use net::{start}; use net::{start};
fn main() { fn main() {
dotenv().ok(); dotenv().ok();
start() start()
} }

View File

@ -63,10 +63,10 @@ impl Rpc {
"game_skill" => Rpc::game_skill(data, &mut tx, account.unwrap(), client), "game_skill" => Rpc::game_skill(data, &mut tx, account.unwrap(), client),
"game_target" => Rpc::game_target(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), "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), "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()?; 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 { Ok(RpcResponse {
method: "item_list".to_string(), method: "account_items".to_string(),
params: RpcResult::ItemList(items_list(tx, &account)?) params: RpcResult::ItemList(items_list(tx, &account)?)
}) })
} }