animations env

This commit is contained in:
ntr
2019-06-29 14:42:34 +10:00
parent 6651735758
commit 214214e838
10 changed files with 289 additions and 39 deletions
+22 -1
View File
@@ -13,7 +13,7 @@ use ws::{MnmlSocket};
use construct::{Construct, construct_spawn, construct_delete};
use game::{Game, game_state, game_skill, game_ready};
use account::{Account, account_constructs, account_instances};
use skill::{Skill};
use skill::{Skill, dev_resolve, Resolutions};
use instance::{Instance, instance_state, instance_list, instance_new, instance_ready, instance_join};
use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim, vbox_unequip};
use item::{Item, ItemInfoCtr, item_info};
@@ -39,6 +39,7 @@ pub fn receive(data: Vec<u8>, db: &Db, _client: &mut MnmlWs, begin: Instant, acc
// if no auth required
match v.method.as_ref() {
"item_info" => return Ok(RpcResult::ItemInfo(item_info())),
"dev_game_resolve" => return handle_dev_resolve(data),
_ => match account {
Some(_) => (),
None => return Err(err_msg("auth required")),
@@ -209,6 +210,11 @@ fn handle_vbox_unequip(data: Vec<u8>, tx: &mut Transaction, account: &Account) -
Ok(RpcResult::InstanceState(vbox_unequip(msg.params, tx, &account)?))
}
fn handle_dev_resolve(data: Vec<u8>) -> Result<RpcResult, Error> {
let msg = from_slice::<DevResolveMsg>(&data).or(Err(err_msg("invalid params")))?;
Ok(RpcResult::DevResolutions(dev_resolve(msg.params.a, msg.params.b, msg.params.skill)))
}
#[derive(Debug,Clone,Serialize,Deserialize)]
pub struct RpcErrorResponse {
pub err: String
@@ -226,6 +232,8 @@ pub enum RpcResult {
InstanceState(Instance),
Pong(()),
DevResolutions(Resolutions),
}
#[derive(Debug,Clone,Serialize,Deserialize)]
@@ -434,6 +442,19 @@ pub struct VboxReclaimParams {
pub index: usize,
}
#[derive(Debug,Clone,Serialize,Deserialize)]
struct DevResolveMsg {
method: String,
params: DevResolveParams,
}
#[derive(Debug,Clone,Serialize,Deserialize)]
pub struct DevResolveParams {
pub a: Uuid,
pub b: Uuid,
pub skill: Skill,
}
// #[cfg(test)]
// mod tests {
// use super::*;
+9 -1
View File
@@ -8,6 +8,14 @@ use item::{Item};
use game::{Game};
use effect::{Effect, Colour, Cooldown};
pub fn dev_resolve(a_id: Uuid, b_id: Uuid, skill: Skill) -> Resolutions {
let mut a = Construct::new();
a.id = a_id;
let mut b = Construct::new();
b.id = b_id;
return resolve(skill, &mut a, &mut b, vec![]);
}
pub fn resolution_steps(cast: &Cast, game: &mut Game) -> Resolutions {
let mut resolutions = vec![];
@@ -464,7 +472,7 @@ pub enum Event {
Evasion { skill: Skill, evasion_rating: u64 },
}
type Resolutions = Vec<Resolution>;
pub type Resolutions = Vec<Resolution>;
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
pub enum Skill {