gardening
This commit is contained in:
parent
e1a26d66d5
commit
a321805f54
@ -310,6 +310,10 @@ CONSTRUCT DAMAGE
|
|||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.resolving .targeting {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
COMBAT ANIMATIONS
|
COMBAT ANIMATIONS
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -778,25 +778,25 @@ impl Construct {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn evade(&self, skill: Skill) -> Option<Event> {
|
// pub fn evade(&self, skill: Skill) -> Option<Event> {
|
||||||
if self.evasion.value == 0 {
|
// if self.evasion.value == 0 {
|
||||||
return None;
|
// return None;
|
||||||
}
|
// }
|
||||||
|
|
||||||
let mut rng = thread_rng();
|
// let mut rng = thread_rng();
|
||||||
let green_life_pct = (self.green_life.value * 100) / self.green_life.value;
|
// let green_life_pct = (self.green_life.value * 100) / self.green_life.value;
|
||||||
let evasion_rating = (self.evasion.value * green_life_pct) / 100;
|
// let evasion_rating = (self.evasion.value * green_life_pct) / 100;
|
||||||
let roll = rng.gen_range(0, 100);
|
// let roll = rng.gen_range(0, 100);
|
||||||
info!("{:} < {:?}", roll, evasion_rating);
|
// info!("{:} < {:?}", roll, evasion_rating);
|
||||||
|
|
||||||
match roll < evasion_rating {
|
// match roll < evasion_rating {
|
||||||
true => Some(Event::Evasion {
|
// true => Some(Event::Evasion {
|
||||||
skill,
|
// skill,
|
||||||
evasion_rating: evasion_rating,
|
// evasion_rating: evasion_rating,
|
||||||
}),
|
// }),
|
||||||
false => None,
|
// false => None,
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn construct_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result<Construct, Error> {
|
pub fn construct_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result<Construct, Error> {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use rpc::{GameStateParams, GameSkillParams};
|
|||||||
use construct::{Construct};
|
use construct::{Construct};
|
||||||
use skill::{Skill, Effect, Cast, Resolution, Event, resolution_steps};
|
use skill::{Skill, Effect, Cast, Resolution, Event, resolution_steps};
|
||||||
use player::{Player};
|
use player::{Player};
|
||||||
use instance::{instance_game_finished, global_game_finished};
|
use instance::{instance_game_finished};
|
||||||
|
|
||||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||||
pub enum Phase {
|
pub enum Phase {
|
||||||
@ -73,10 +73,6 @@ impl Game {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn joinable(&self) -> bool {
|
|
||||||
self.can_start()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn player_add(&mut self, mut player: Player) -> Result<&mut Game, Error> {
|
pub fn player_add(&mut self, mut player: Player) -> Result<&mut Game, Error> {
|
||||||
if self.players.len() == self.player_num {
|
if self.players.len() == self.player_num {
|
||||||
return Err(err_msg("maximum number of players"));
|
return Err(err_msg("maximum number of players"));
|
||||||
@ -115,17 +111,6 @@ impl Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn construct_by_id_take(&mut self, id: Uuid) -> Construct {
|
|
||||||
match self.players.iter_mut().find(|t| t.constructs.iter().any(|c| c.id == id)) {
|
|
||||||
Some(player) => {
|
|
||||||
let i = player.constructs.iter().position(|c| c.id == id).unwrap();
|
|
||||||
player.constructs.remove(i)
|
|
||||||
}
|
|
||||||
None => panic!("id not in game {:}", id),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fn all_constructs(&self) -> Vec<Construct> {
|
fn all_constructs(&self) -> Vec<Construct> {
|
||||||
self.players.clone()
|
self.players.clone()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -495,7 +480,7 @@ impl Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn log_resolution(&mut self, speed: u64, resolution: &Resolution) -> &mut Game {
|
fn log_resolution(&mut self, speed: u64, resolution: &Resolution) -> &mut Game {
|
||||||
let Resolution { source, target, event, stages } = resolution;
|
let Resolution { source, target, event, stages: _ } = resolution;
|
||||||
match event {
|
match event {
|
||||||
Event::Ko { skill: _ }=>
|
Event::Ko { skill: _ }=>
|
||||||
self.log.push(format!("{:} KO!", target.name)),
|
self.log.push(format!("{:} KO!", target.name)),
|
||||||
@ -973,11 +958,11 @@ mod tests {
|
|||||||
|
|
||||||
let x_player_id = Uuid::new_v4();
|
let x_player_id = Uuid::new_v4();
|
||||||
x.account = x_player_id;
|
x.account = x_player_id;
|
||||||
let mut x_player = Player::new(x_player_id, &"ntr".to_string(), vec![x]);
|
let x_player = Player::new(x_player_id, &"ntr".to_string(), vec![x]);
|
||||||
|
|
||||||
let y_player_id = Uuid::new_v4();
|
let y_player_id = Uuid::new_v4();
|
||||||
y.account = y_player_id;
|
y.account = y_player_id;
|
||||||
let mut y_player = Player::new(y_player_id, &"mash".to_string(), vec![y]);
|
let y_player = Player::new(y_player_id, &"mash".to_string(), vec![y]);
|
||||||
|
|
||||||
game
|
game
|
||||||
.player_add(x_player).unwrap()
|
.player_add(x_player).unwrap()
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use chrono::Duration;
|
|||||||
|
|
||||||
use rpc::{InstanceLobbyParams, InstanceJoinParams, InstanceReadyParams, InstanceStateParams};
|
use rpc::{InstanceLobbyParams, InstanceJoinParams, InstanceReadyParams, InstanceStateParams};
|
||||||
use account::Account;
|
use account::Account;
|
||||||
use player::{Player, player_create, player_get, player_global_update};
|
use player::{Player, player_create};
|
||||||
use construct::{Construct, construct_get};
|
use construct::{Construct, construct_get};
|
||||||
use mob::{instance_mobs};
|
use mob::{instance_mobs};
|
||||||
use game::{Game, Phase, game_get, game_write};
|
use game::{Game, Phase, game_get, game_write};
|
||||||
@ -688,27 +688,6 @@ pub fn instance_join(params: InstanceJoinParams, tx: &mut Transaction, account:
|
|||||||
instance_update(tx, instance)
|
instance_update(tx, instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn instance_ready_global(tx: &mut Transaction, _account: &Account, player: Player) -> Result<Game, Error> {
|
|
||||||
// // get the game
|
|
||||||
// let game = match game_global_get(tx) {
|
|
||||||
// Ok(g) => {
|
|
||||||
// info!("received global game {:?}", g.id);
|
|
||||||
// // if there is one try to join
|
|
||||||
// match game_instance_join(tx, player.clone(), g.id) {
|
|
||||||
// Ok(g) => g,
|
|
||||||
// // if fails make a new one
|
|
||||||
// Err(_e) => game_instance_new(tx, vec![player], Uuid::new_v4(), Uuid::nil())?,
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// // if not found make a new one
|
|
||||||
// Err(_) => game_instance_new(tx, vec![player], Uuid::new_v4(), Uuid::nil())?,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// // set the current game
|
|
||||||
// game_global_set(tx, &game)?;
|
|
||||||
// Ok(game)
|
|
||||||
// }
|
|
||||||
|
|
||||||
pub fn instance_ready(params: InstanceReadyParams, tx: &mut Transaction, account: &Account) -> Result<Instance, Error> {
|
pub fn instance_ready(params: InstanceReadyParams, tx: &mut Transaction, account: &Account) -> Result<Instance, Error> {
|
||||||
let mut instance = instance_get(tx, params.instance_id)?;
|
let mut instance = instance_get(tx, params.instance_id)?;
|
||||||
let player_id = instance.account_player(account.id)?.id;
|
let player_id = instance.account_player(account.id)?.id;
|
||||||
@ -735,22 +714,6 @@ pub fn instance_state(params: InstanceStateParams, tx: &mut Transaction, account
|
|||||||
Ok(RpcResult::InstanceState(instance))
|
Ok(RpcResult::InstanceState(instance))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn global_game_finished(tx: &mut Transaction, game: &Game) -> Result<(), Error> {
|
|
||||||
let winner = game.winner().ok_or(err_msg("game not finished"))?;
|
|
||||||
|
|
||||||
for player in game.players.iter() {
|
|
||||||
let mut player = player_get(tx, player.id, Uuid::nil())?;
|
|
||||||
match player.id == winner.id {
|
|
||||||
true => player.add_win(),
|
|
||||||
false => player.add_loss(),
|
|
||||||
};
|
|
||||||
player.vbox.fill();
|
|
||||||
player_global_update(tx, player, true)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn instance_game_finished(tx: &mut Transaction, game: &Game, instance_id: Uuid) -> Result<(), Error> {
|
pub fn instance_game_finished(tx: &mut Transaction, game: &Game, instance_id: Uuid) -> Result<(), Error> {
|
||||||
let mut instance = instance_get(tx, instance_id)?;
|
let mut instance = instance_get(tx, instance_id)?;
|
||||||
instance.game_finished(game)?;
|
instance.game_finished(game)?;
|
||||||
|
|||||||
@ -19,15 +19,8 @@ static DB_POOL_SIZE: u32 = 20;
|
|||||||
pub type Db = PooledConnection<PostgresConnectionManager>;
|
pub type Db = PooledConnection<PostgresConnectionManager>;
|
||||||
|
|
||||||
use rpc::{Rpc};
|
use rpc::{Rpc};
|
||||||
use util::{startup};
|
|
||||||
use warden::{warden};
|
use warden::{warden};
|
||||||
|
|
||||||
// struct Server {
|
|
||||||
// client: WebSocket<TcpStream>,
|
|
||||||
// rpc: Rpc,
|
|
||||||
// db: Pool<PostgresConnectionManager>,
|
|
||||||
// }
|
|
||||||
|
|
||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
struct RpcErrorResponse {
|
struct RpcErrorResponse {
|
||||||
err: String
|
err: String
|
||||||
@ -88,10 +81,10 @@ pub fn start() {
|
|||||||
|
|
||||||
let pool = db_connection(database_url);
|
let pool = db_connection(database_url);
|
||||||
|
|
||||||
{
|
// {
|
||||||
let startup_connection = pool.get().expect("unable to get db connection");
|
// let startup_connection = pool.get().expect("unable to get db connection");
|
||||||
startup(startup_connection).unwrap();
|
// startup(startup_connection).unwrap();
|
||||||
}
|
// }
|
||||||
|
|
||||||
let server = TcpListener::bind("0.0.0.0:40000").unwrap();
|
let server = TcpListener::bind("0.0.0.0:40000").unwrap();
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +1,15 @@
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
|
|
||||||
use serde_cbor::{from_slice, to_vec};
|
|
||||||
|
|
||||||
use postgres::transaction::Transaction;
|
use postgres::transaction::Transaction;
|
||||||
|
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use failure::err_msg;
|
use failure::err_msg;
|
||||||
|
|
||||||
use account::Account;
|
use account::Account;
|
||||||
use construct::{Construct, Colours, construct_get};
|
use construct::{Construct, Colours};
|
||||||
use vbox::{Vbox};
|
use vbox::{Vbox};
|
||||||
use item::{Item, ItemEffect};
|
use item::{Item, ItemEffect};
|
||||||
use rpc::{PlayerConstructsSetParams};
|
|
||||||
use instance::{Instance};
|
|
||||||
use skill::{Effect};
|
use skill::{Effect};
|
||||||
|
|
||||||
const DISCARD_COST: u16 = 5;
|
const DISCARD_COST: u16 = 5;
|
||||||
@ -291,53 +287,21 @@ impl Player {
|
|||||||
.find(|c| c.affected(Effect::Taunt))
|
.find(|c| c.affected(Effect::Taunt))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_constructs(&mut self, mut constructs: Vec<Construct>) -> &mut Player {
|
|
||||||
constructs.sort_unstable_by_key(|c| c.id);
|
|
||||||
self.constructs = constructs;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn construct_by_id(&mut self, id: Uuid) -> Option<&mut Construct> {
|
pub fn construct_by_id(&mut self, id: Uuid) -> Option<&mut Construct> {
|
||||||
self.constructs.iter_mut().find(|c| c.id == id)
|
self.constructs.iter_mut().find(|c| c.id == id)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn player_get(tx: &mut Transaction, account_id: Uuid, instance_id: Uuid) -> Result<Player, Error> {
|
|
||||||
let query = "
|
|
||||||
SELECT *
|
|
||||||
FROM players
|
|
||||||
WHERE account = $1
|
|
||||||
AND instance = $2
|
|
||||||
FOR UPDATE;
|
|
||||||
";
|
|
||||||
|
|
||||||
let result = tx
|
|
||||||
.query(query, &[&account_id, &instance_id])?;
|
|
||||||
|
|
||||||
let returned = match result.iter().next() {
|
|
||||||
Some(row) => row,
|
|
||||||
None => return Err(err_msg("player not found")),
|
|
||||||
};
|
|
||||||
|
|
||||||
// tells from_slice to cast into a construct
|
|
||||||
let bytes: Vec<u8> = returned.get("data");
|
|
||||||
let data = from_slice::<Player>(&bytes)?;
|
|
||||||
|
|
||||||
return Ok(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn player_create(tx: &mut Transaction, player: Player, instance: Uuid, account: &Account) -> Result<Player, Error> {
|
pub fn player_create(tx: &mut Transaction, player: Player, instance: Uuid, account: &Account) -> Result<Player, Error> {
|
||||||
let player_bytes = to_vec(&player)?;
|
|
||||||
|
|
||||||
let query = "
|
let query = "
|
||||||
INSERT INTO players (id, instance, account, data)
|
INSERT INTO players (id, instance, account)
|
||||||
VALUES ($1, $2, $3, $4)
|
VALUES ($1, $2, $3)
|
||||||
RETURNING id, account;
|
RETURNING id, account;
|
||||||
";
|
";
|
||||||
|
|
||||||
let result = tx
|
let result = tx
|
||||||
.query(query, &[&Uuid::new_v4(), &instance, &account.id, &player_bytes])?;
|
.query(query, &[&Uuid::new_v4(), &instance, &account.id])?;
|
||||||
|
|
||||||
let _returned = result.iter().next().expect("no row written");
|
let _returned = result.iter().next().expect("no row written");
|
||||||
|
|
||||||
@ -346,71 +310,6 @@ pub fn player_create(tx: &mut Transaction, player: Player, instance: Uuid, accou
|
|||||||
return Ok(player);
|
return Ok(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn player_global_update(tx: &mut Transaction, mut player: Player, ignore_phase: bool) -> Result<Player, Error> {
|
|
||||||
// sort vbox for niceness
|
|
||||||
player.vbox.bound.sort_unstable();
|
|
||||||
|
|
||||||
let bytes = to_vec(&player)?;
|
|
||||||
|
|
||||||
let query = "
|
|
||||||
UPDATE players
|
|
||||||
SET data = $1, updated_at = now()
|
|
||||||
WHERE id = $2
|
|
||||||
RETURNING id, data;
|
|
||||||
";
|
|
||||||
|
|
||||||
let result = tx
|
|
||||||
.query(query, &[&bytes, &player.id])?;
|
|
||||||
|
|
||||||
result.iter().next().ok_or(format_err!("player {:?} could not be written", player))?;
|
|
||||||
|
|
||||||
Ok(player)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn player_delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> {
|
|
||||||
let query = "
|
|
||||||
DELETE
|
|
||||||
FROM players
|
|
||||||
WHERE id = $1;
|
|
||||||
";
|
|
||||||
|
|
||||||
let result = tx
|
|
||||||
.execute(query, &[&id])?;
|
|
||||||
|
|
||||||
if result != 1 {
|
|
||||||
return Err(format_err!("unable to delete player {:?}", id));
|
|
||||||
}
|
|
||||||
|
|
||||||
info!("player deleted {:?}", id);
|
|
||||||
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn player_mm_constructs_set(params: PlayerConstructsSetParams, tx: &mut Transaction, account: &Account) -> Result<Instance, Error> {
|
|
||||||
if params.construct_ids.len() != 3 {
|
|
||||||
return Err(err_msg("player size is 3"));
|
|
||||||
}
|
|
||||||
|
|
||||||
let constructs = params.construct_ids
|
|
||||||
.iter()
|
|
||||||
.map(|id| construct_get(tx, *id, account.id))
|
|
||||||
.collect::<Result<Vec<Construct>, Error>>()?;
|
|
||||||
|
|
||||||
let player = match player_get(tx, account.id, Uuid::nil()) {
|
|
||||||
Ok(mut p) => {
|
|
||||||
p.constructs = constructs;
|
|
||||||
p.vbox = Vbox::new();
|
|
||||||
player_global_update(tx, p, false)?
|
|
||||||
},
|
|
||||||
Err(_) => {
|
|
||||||
player_create(tx, Player::new(account.id, &account.name, constructs), Uuid::nil(), &account)?
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let instance = Instance::global(player);
|
|
||||||
Ok(instance)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use mob::instance_mobs;
|
use mob::instance_mobs;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ use game::{Game, game_state, game_skill, game_ready};
|
|||||||
use account::{Account, account_create, account_login, account_from_token, account_constructs, account_instances};
|
use account::{Account, account_create, account_login, account_from_token, account_constructs, account_instances};
|
||||||
use skill::{Skill};
|
use skill::{Skill};
|
||||||
use spec::{Spec};
|
use spec::{Spec};
|
||||||
use player::{Score, player_mm_constructs_set};
|
use player::{Score};
|
||||||
use instance::{Instance, instance_state, instance_new, instance_ready, instance_join};
|
use instance::{Instance, instance_state, instance_new, instance_ready, instance_join};
|
||||||
use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim, vbox_unequip};
|
use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim, vbox_unequip};
|
||||||
use item::{Item, ItemInfoCtr, item_info};
|
use item::{Item, ItemInfoCtr, item_info};
|
||||||
@ -53,6 +53,7 @@ impl Rpc {
|
|||||||
match v.method.as_ref() {
|
match v.method.as_ref() {
|
||||||
"account_create" => (),
|
"account_create" => (),
|
||||||
"account_login" => (),
|
"account_login" => (),
|
||||||
|
"item_info" => (),
|
||||||
_ => match account {
|
_ => match account {
|
||||||
Some(_) => (),
|
Some(_) => (),
|
||||||
None => return Err(err_msg("auth required")),
|
None => return Err(err_msg("auth required")),
|
||||||
@ -62,14 +63,14 @@ impl Rpc {
|
|||||||
// now we have the method name
|
// now we have the method name
|
||||||
// match on that to determine what fn to call
|
// match on that to determine what fn to call
|
||||||
let response = match v.method.as_ref() {
|
let response = match v.method.as_ref() {
|
||||||
// no auth methods
|
// NO AUTH
|
||||||
"account_create" => Rpc::account_create(data, &mut tx, client),
|
"account_create" => Rpc::account_create(data, &mut tx, client),
|
||||||
"account_login" => Rpc::account_login(data, &mut tx, client),
|
"account_login" => Rpc::account_login(data, &mut tx, client),
|
||||||
|
"item_info" => Ok(RpcResponse { method: "item_info".to_string(), params: RpcResult::ItemInfo(item_info()) }),
|
||||||
|
|
||||||
// auth methods
|
// AUTH METHODS
|
||||||
"account_constructs" => Rpc::account_constructs(data, &mut tx, account.unwrap(), client),
|
"account_constructs" => Rpc::account_constructs(data, &mut tx, account.unwrap(), client),
|
||||||
"account_instances" => Rpc::account_instances(data, &mut tx, account.unwrap(), client),
|
"account_instances" => Rpc::account_instances(data, &mut tx, account.unwrap(), client),
|
||||||
// "account_zone" => Rpc::account_zone(data, &mut tx, account.unwrap(), client),
|
|
||||||
|
|
||||||
"construct_spawn" => Rpc::construct_spawn(data, &mut tx, account.unwrap(), client),
|
"construct_spawn" => Rpc::construct_spawn(data, &mut tx, account.unwrap(), client),
|
||||||
|
|
||||||
@ -82,7 +83,6 @@ impl Rpc {
|
|||||||
"instance_new" => Rpc::instance_new(data, &mut tx, account.unwrap(), client),
|
"instance_new" => Rpc::instance_new(data, &mut tx, account.unwrap(), client),
|
||||||
"instance_state" => Rpc::instance_state(data, &mut tx, account.unwrap(), client),
|
"instance_state" => Rpc::instance_state(data, &mut tx, account.unwrap(), client),
|
||||||
|
|
||||||
"player_mm_constructs_set" => Rpc::player_mm_constructs_set(data, &mut tx, account.unwrap(), client),
|
|
||||||
"player_vbox_accept" => Rpc::player_vbox_accept(data, &mut tx, account.unwrap(), client),
|
"player_vbox_accept" => Rpc::player_vbox_accept(data, &mut tx, account.unwrap(), client),
|
||||||
"player_vbox_apply" => Rpc::player_vbox_apply(data, &mut tx, account.unwrap(), client),
|
"player_vbox_apply" => Rpc::player_vbox_apply(data, &mut tx, account.unwrap(), client),
|
||||||
"player_vbox_combine" => Rpc::player_vbox_combine(data, &mut tx, account.unwrap(), client),
|
"player_vbox_combine" => Rpc::player_vbox_combine(data, &mut tx, account.unwrap(), client),
|
||||||
@ -90,7 +90,6 @@ impl Rpc {
|
|||||||
"player_vbox_reclaim" => Rpc::player_vbox_reclaim(data, &mut tx, account.unwrap(), client),
|
"player_vbox_reclaim" => Rpc::player_vbox_reclaim(data, &mut tx, account.unwrap(), client),
|
||||||
"player_vbox_unequip" => Rpc::player_vbox_unequip(data, &mut tx, account.unwrap(), client),
|
"player_vbox_unequip" => Rpc::player_vbox_unequip(data, &mut tx, account.unwrap(), client),
|
||||||
|
|
||||||
"item_info" => Ok(RpcResponse { method: "item_info".to_string(), params: RpcResult::ItemInfo(item_info()) }),
|
|
||||||
|
|
||||||
_ => Err(format_err!("unknown method - {:?}", v.method)),
|
_ => Err(format_err!("unknown method - {:?}", v.method)),
|
||||||
};
|
};
|
||||||
@ -296,17 +295,6 @@ impl Rpc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn player_mm_constructs_set(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
|
||||||
let msg = from_slice::<PlayerConstructsSetMsg>(&data).or(Err(err_msg("invalid params")))?;
|
|
||||||
|
|
||||||
let response = RpcResponse {
|
|
||||||
method: "instance_state".to_string(),
|
|
||||||
params: RpcResult::InstanceState(player_mm_constructs_set(msg.params, tx, &account)?)
|
|
||||||
};
|
|
||||||
|
|
||||||
return Ok(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn player_vbox_accept(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
fn player_vbox_accept(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
let msg = from_slice::<VboxAcceptMsg>(&data).or(Err(err_msg("invalid params")))?;
|
let msg = from_slice::<VboxAcceptMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
|
|
||||||
@ -341,7 +329,7 @@ impl Rpc {
|
|||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn player_vbox_apply(data: Vec<u8>, tx: &mut Transaction, account: Account, client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
fn player_vbox_apply(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
let msg = from_slice::<VboxApplyMsg>(&data).or(Err(err_msg("invalid params")))?;
|
let msg = from_slice::<VboxApplyMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
|
|
||||||
let response = RpcResponse {
|
let response = RpcResponse {
|
||||||
@ -363,7 +351,7 @@ impl Rpc {
|
|||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn player_vbox_unequip(data: Vec<u8>, tx: &mut Transaction, account: Account, client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
fn player_vbox_unequip(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
let msg = from_slice::<VboxUnequipMsg>(&data).or(Err(err_msg("invalid params")))?;
|
let msg = from_slice::<VboxUnequipMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
|
|
||||||
let response = RpcResponse {
|
let response = RpcResponse {
|
||||||
|
|||||||
@ -1372,9 +1372,7 @@ impl Skill {
|
|||||||
Skill::ClutchIII |
|
Skill::ClutchIII |
|
||||||
Skill::ParryI |
|
Skill::ParryI |
|
||||||
Skill::ParryII |
|
Skill::ParryII |
|
||||||
Skill::ParryIII |
|
Skill::ParryIII => true,
|
||||||
Skill::Block |
|
|
||||||
Skill::ParryI => true,
|
|
||||||
|
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,24 +1,20 @@
|
|||||||
use net::Db;
|
// use net::Db;
|
||||||
// Db Commons
|
// Db Commons
|
||||||
use failure::Error;
|
// use failure::Error;
|
||||||
|
|
||||||
// use game::{game_global_startup};
|
// pub fn startup(db: Db) -> Result<(), Error> {
|
||||||
|
// let tx = db.transaction()?;
|
||||||
|
|
||||||
pub fn startup(db: Db) -> Result<(), Error> {
|
// info!("running startup fns");
|
||||||
let mut tx = db.transaction()?;
|
|
||||||
|
|
||||||
info!("running startup fns");
|
// match tx.commit() {
|
||||||
|
// Ok(_) => {
|
||||||
// game_global_startup(&mut tx)?;
|
// info!("startup processes completed");
|
||||||
|
// Ok(())
|
||||||
match tx.commit() {
|
// },
|
||||||
Ok(_) => {
|
// Err(e) => Err(format_err!("failed to commit startup tx {:?}", e)),
|
||||||
info!("startup processes completed");
|
// }
|
||||||
Ok(())
|
// }
|
||||||
},
|
|
||||||
Err(e) => Err(format_err!("failed to commit startup tx {:?}", e)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait IntPct {
|
pub trait IntPct {
|
||||||
fn pct(self, pct: u64) -> u64;
|
fn pct(self, pct: u64) -> u64;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user