comment zones:
This commit is contained in:
parent
909af4c9e3
commit
da21350fda
@ -13,6 +13,8 @@ cost system for items
|
|||||||
design / implement specs
|
design / implement specs
|
||||||
combo specs
|
combo specs
|
||||||
round system for games
|
round system for games
|
||||||
|
add cryps to player
|
||||||
|
find opponent or do pve
|
||||||
|
|
||||||
## SOON
|
## SOON
|
||||||
* clean up categories
|
* clean up categories
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use rpc::{AccountCreateParams, AccountLoginParams};
|
|||||||
|
|
||||||
use cryp::{Cryp, CrypRecover, cryp_write, cryp_recover};
|
use cryp::{Cryp, CrypRecover, cryp_write, cryp_recover};
|
||||||
use game::Game;
|
use game::Game;
|
||||||
use zone::{Zone, zone_delete};
|
// use zone::{Zone, zone_delete};
|
||||||
use skill::{Skill};
|
use skill::{Skill};
|
||||||
|
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
@ -205,33 +205,33 @@ pub fn account_game_history(tx: &mut Transaction, account: &Account) -> Result<V
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn account_zone(tx: &mut Transaction, account: &Account) -> Result<Zone, Error> {
|
// pub fn account_zone(tx: &mut Transaction, account: &Account) -> Result<Zone, Error> {
|
||||||
let query = "
|
// let query = "
|
||||||
SELECT *
|
// SELECT *
|
||||||
FROM zones
|
// FROM zones
|
||||||
WHERE account = $1
|
// WHERE account = $1
|
||||||
AND active = true;
|
// AND active = true;
|
||||||
";
|
// ";
|
||||||
|
|
||||||
let result = tx
|
// let result = tx
|
||||||
.query(query, &[&account.id])?;
|
// .query(query, &[&account.id])?;
|
||||||
|
|
||||||
let returned = match result.iter().next() {
|
// let returned = match result.iter().next() {
|
||||||
Some(row) => row,
|
// Some(row) => row,
|
||||||
None => return Err(err_msg("no active zone")),
|
// None => return Err(err_msg("no active zone")),
|
||||||
};
|
// };
|
||||||
|
|
||||||
// tells from_slice to cast into a cryp
|
// // tells from_slice to cast into a cryp
|
||||||
let bytes: Vec<u8> = returned.get("data");
|
// let bytes: Vec<u8> = returned.get("data");
|
||||||
let zone = match from_slice::<Zone>(&bytes) {
|
// let zone = match from_slice::<Zone>(&bytes) {
|
||||||
Ok(z) => z,
|
// Ok(z) => z,
|
||||||
Err(_) => {
|
// Err(_) => {
|
||||||
zone_delete(tx, returned.get("id"))?;
|
// zone_delete(tx, returned.get("id"))?;
|
||||||
return Err(err_msg("invalid zone removed"))
|
// return Err(err_msg("invalid zone removed"))
|
||||||
},
|
// },
|
||||||
};
|
// };
|
||||||
|
|
||||||
return Ok(zone);
|
// return Ok(zone);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use account::Account;
|
|||||||
use rpc::{GameStateParams, GameSkillParams, GamePveParams};
|
use rpc::{GameStateParams, GameSkillParams, GamePveParams};
|
||||||
use cryp::{Cryp, cryp_get};
|
use cryp::{Cryp, cryp_get};
|
||||||
use skill::{Skill, Cast, ResolutionResult};
|
use skill::{Skill, Cast, ResolutionResult};
|
||||||
use zone::{node_finish};
|
// use zone::{node_finish};
|
||||||
use mob::{generate_mob_team};
|
use mob::{generate_mob_team};
|
||||||
|
|
||||||
pub type Log = Vec<String>;
|
pub type Log = Vec<String>;
|
||||||
@ -659,13 +659,13 @@ pub fn game_update(game: &Game, tx: &mut Transaction) -> Result<(), Error> {
|
|||||||
|
|
||||||
result.iter().next().ok_or(format_err!("game {:?} could not be written", game))?;
|
result.iter().next().ok_or(format_err!("game {:?} could not be written", game))?;
|
||||||
|
|
||||||
if game.finished() {
|
// if game.finished() {
|
||||||
// check for zone update
|
// // check for zone update
|
||||||
if let Some((z, i)) = game.zone {
|
// if let Some((z, i)) = game.zone {
|
||||||
node_finish(game, z, i, tx)?;
|
// node_finish(game, z, i, tx)?;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ 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;
|
||||||
@ -28,7 +28,7 @@ mod rpc;
|
|||||||
mod account;
|
mod account;
|
||||||
mod instance;
|
mod instance;
|
||||||
mod player;
|
mod player;
|
||||||
mod zone;
|
// mod zone;
|
||||||
mod mob;
|
mod mob;
|
||||||
|
|
||||||
mod vbox;
|
mod vbox;
|
||||||
|
|||||||
@ -17,9 +17,9 @@ use failure::err_msg;
|
|||||||
use net::Db;
|
use net::Db;
|
||||||
use cryp::{Cryp, cryp_spawn, cryp_learn};
|
use cryp::{Cryp, cryp_spawn, cryp_learn};
|
||||||
use game::{Game, game_state, game_pve, game_skill};
|
use game::{Game, game_state, game_pve, game_skill};
|
||||||
use account::{Account, account_create, account_login, account_from_token, account_cryps, account_zone};
|
use account::{Account, account_create, account_login, account_from_token, account_cryps};
|
||||||
use skill::{Skill};
|
use skill::{Skill};
|
||||||
use zone::{Zone, zone_create, zone_join, zone_close};
|
// use zone::{Zone, zone_create, zone_join, zone_close};
|
||||||
use spec::{Spec};
|
use spec::{Spec};
|
||||||
use player::{player_state, player_create, player_cryps_set, Player};
|
use player::{player_state, player_create, player_cryps_set, Player};
|
||||||
use instance::{instance_join};
|
use instance::{instance_join};
|
||||||
@ -64,7 +64,7 @@ impl Rpc {
|
|||||||
|
|
||||||
// auth methods
|
// auth methods
|
||||||
"account_cryps" => Rpc::account_cryps(data, &mut tx, account.unwrap(), client),
|
"account_cryps" => Rpc::account_cryps(data, &mut tx, account.unwrap(), client),
|
||||||
"account_zone" => Rpc::account_zone(data, &mut tx, account.unwrap(), client),
|
// "account_zone" => Rpc::account_zone(data, &mut tx, account.unwrap(), client),
|
||||||
|
|
||||||
"cryp_spawn" => Rpc::cryp_spawn(data, &mut tx, account.unwrap(), client),
|
"cryp_spawn" => Rpc::cryp_spawn(data, &mut tx, account.unwrap(), client),
|
||||||
|
|
||||||
@ -72,9 +72,9 @@ impl Rpc {
|
|||||||
"game_pve" => Rpc::game_pve(data, &mut tx, account.unwrap(), client),
|
"game_pve" => Rpc::game_pve(data, &mut tx, account.unwrap(), client),
|
||||||
"game_skill" => Rpc::game_skill(data, &mut tx, account.unwrap(), client),
|
"game_skill" => Rpc::game_skill(data, &mut tx, account.unwrap(), client),
|
||||||
|
|
||||||
"zone_create" => Rpc::zone_create(data, &mut tx, account.unwrap(), client),
|
// "zone_create" => Rpc::zone_create(data, &mut tx, account.unwrap(), client),
|
||||||
"zone_join" => Rpc::zone_join(data, &mut tx, account.unwrap(), client),
|
// "zone_join" => Rpc::zone_join(data, &mut tx, account.unwrap(), client),
|
||||||
"zone_close" => Rpc::zone_close(data, &mut tx, account.unwrap(), client),
|
// "zone_close" => Rpc::zone_close(data, &mut tx, account.unwrap(), client),
|
||||||
|
|
||||||
"instance_join" => Rpc::instance_join(data, &mut tx, account.unwrap(), client),
|
"instance_join" => Rpc::instance_join(data, &mut tx, account.unwrap(), client),
|
||||||
"player_state" => Rpc::player_state(data, &mut tx, account.unwrap(), client),
|
"player_state" => Rpc::player_state(data, &mut tx, account.unwrap(), client),
|
||||||
@ -220,45 +220,45 @@ impl Rpc {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn account_zone(_data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
// fn account_zone(_data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
Ok(RpcResponse {
|
// Ok(RpcResponse {
|
||||||
method: "zone_state".to_string(),
|
// method: "zone_state".to_string(),
|
||||||
params: RpcResult::ZoneState(account_zone(tx, &account)?)
|
// params: RpcResult::ZoneState(account_zone(tx, &account)?)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn zone_create(_data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
// fn zone_create(_data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
// let _msg = from_slice::<ZoneCreateMsg>(&data).or(Err(err_msg("invalid params")))?;
|
// // let _msg = from_slice::<ZoneCreateMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
|
|
||||||
let response = RpcResponse {
|
// let response = RpcResponse {
|
||||||
method: "zone_state".to_string(),
|
// method: "zone_state".to_string(),
|
||||||
params: RpcResult::ZoneState(zone_create(tx, &account)?)
|
// params: RpcResult::ZoneState(zone_create(tx, &account)?)
|
||||||
};
|
// };
|
||||||
|
|
||||||
return Ok(response);
|
// return Ok(response);
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn zone_join(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
// fn zone_join(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
let msg = from_slice::<ZoneJoinMsg>(&data).or(Err(err_msg("invalid params")))?;
|
// let msg = from_slice::<ZoneJoinMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
|
|
||||||
let response = RpcResponse {
|
// let response = RpcResponse {
|
||||||
method: "game_state".to_string(),
|
// method: "game_state".to_string(),
|
||||||
params: RpcResult::GameState(zone_join(msg.params, tx, &account)?)
|
// params: RpcResult::GameState(zone_join(msg.params, tx, &account)?)
|
||||||
};
|
// };
|
||||||
|
|
||||||
return Ok(response);
|
// return Ok(response);
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn zone_close(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
// fn zone_close(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
let msg = from_slice::<ZoneCloseMsg>(&data).or(Err(err_msg("invalid params")))?;
|
// let msg = from_slice::<ZoneCloseMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
|
|
||||||
let response = RpcResponse {
|
// let response = RpcResponse {
|
||||||
method: "zone_close".to_string(),
|
// method: "zone_close".to_string(),
|
||||||
params: RpcResult::ZoneClose(zone_close(msg.params, tx, &account)?)
|
// params: RpcResult::ZoneClose(zone_close(msg.params, tx, &account)?)
|
||||||
};
|
// };
|
||||||
|
|
||||||
return Ok(response);
|
// return Ok(response);
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn instance_join(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
fn instance_join(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
let msg = from_slice::<InstanceJoinMsg>(&data).or(Err(err_msg("invalid params")))?;
|
let msg = from_slice::<InstanceJoinMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
@ -371,8 +371,8 @@ pub enum RpcResult {
|
|||||||
Account(Account),
|
Account(Account),
|
||||||
CrypList(Vec<Cryp>),
|
CrypList(Vec<Cryp>),
|
||||||
GameState(Game),
|
GameState(Game),
|
||||||
ZoneState(Zone),
|
// ZoneState(Zone),
|
||||||
ZoneClose(()),
|
// ZoneClose(()),
|
||||||
|
|
||||||
PlayerState(Player),
|
PlayerState(Player),
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user