wip
This commit is contained in:
+5
-2
@@ -21,9 +21,9 @@ use account::{Account, account_create, account_login, account_from_token, accoun
|
||||
use skill::{Skill};
|
||||
// use zone::{Zone, zone_create, zone_join, zone_close};
|
||||
use spec::{Spec};
|
||||
use player::{Score, player_mm_cryps_set, Player};
|
||||
use player::{Score, player_mm_cryps_set};
|
||||
use instance::{Instance, instance_state, instance_new, instance_ready, instance_join};
|
||||
use vbox::{Var, vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim, vbox_unequip};
|
||||
use vbox::{Var, VboxInfo, vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim, vbox_unequip, vbox_info};
|
||||
|
||||
pub struct Rpc;
|
||||
|
||||
@@ -86,6 +86,8 @@ impl Rpc {
|
||||
"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),
|
||||
|
||||
"vbox_info" => Ok(RpcResponse { method: "vbox_info".to_string(), params: RpcResult::VboxInfo(vbox_info()) }),
|
||||
|
||||
_ => Err(format_err!("unknown method - {:?}", v.method)),
|
||||
};
|
||||
|
||||
@@ -392,6 +394,7 @@ pub enum RpcResult {
|
||||
Account(Account),
|
||||
CrypList(Vec<Cryp>),
|
||||
GameState(Game),
|
||||
VboxInfo(VboxInfo),
|
||||
InstanceScores(Vec<(String, Score)>),
|
||||
// ZoneState(Zone),
|
||||
// ZoneClose(()),
|
||||
|
||||
+50
-1
@@ -344,7 +344,8 @@ impl From<Spec> for Var {
|
||||
}
|
||||
|
||||
|
||||
struct Combo {
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
pub struct Combo {
|
||||
var: Var,
|
||||
units: Vec<Var>,
|
||||
}
|
||||
@@ -417,6 +418,50 @@ fn get_combos() -> Vec<Combo> {
|
||||
return combinations;
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
pub struct VarInfo {
|
||||
pub v: Var,
|
||||
pub spec: bool,
|
||||
pub skill: bool,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
pub struct VboxInfo {
|
||||
pub combos: Vec<Combo>,
|
||||
pub vars: Vec<VarInfo>,
|
||||
}
|
||||
|
||||
pub fn vbox_info() -> VboxInfo {
|
||||
let combos = get_combos();
|
||||
let mut vars = combos
|
||||
.into_iter()
|
||||
.flat_map(|mut c| {
|
||||
c.units.push(c.var);
|
||||
c.units
|
||||
})
|
||||
.collect::<Vec<Var>>();
|
||||
|
||||
vars.sort_unstable();
|
||||
vars.dedup();
|
||||
|
||||
let vars = vars
|
||||
.into_iter()
|
||||
.map(|v| VarInfo {
|
||||
v,
|
||||
spec: v.into_spec().is_some(),
|
||||
skill: v.into_skill().is_some(),
|
||||
})
|
||||
.collect::<Vec<VarInfo>>();
|
||||
|
||||
let combos = get_combos();
|
||||
|
||||
return VboxInfo {
|
||||
combos,
|
||||
vars,
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
pub struct Vbox {
|
||||
pub bits: u16,
|
||||
@@ -632,4 +677,8 @@ mod tests {
|
||||
assert_eq!(count.red, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vbox_info_test() {
|
||||
println!("{:#?}", vbox_info());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user