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