From ee41831b67bc4506f716ea135601311b8eca8e9c Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 10 May 2024 23:22:49 +0200 Subject: [PATCH] Forgot inventory.rs --- gameserver/src/net/handlers/inventory.rs | 76 ++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 gameserver/src/net/handlers/inventory.rs diff --git a/gameserver/src/net/handlers/inventory.rs b/gameserver/src/net/handlers/inventory.rs new file mode 100644 index 0000000..87830c5 --- /dev/null +++ b/gameserver/src/net/handlers/inventory.rs @@ -0,0 +1,76 @@ +use anyhow::Result; +use proto::*; +use super::*; +use crate::game::globals; +use serde_json::json; +use serde_json::Value; +use std::fs; + +use crate::{net::PlayerSession, util}; + +pub async fn on_get_bag_cs_req(session: &PlayerSession, _: &GetBagCsReq) -> Result<()> { + let json_data = fs::read_to_string("C:/Users/Al-Shebli/Downloads/HSR 2.3 beta/JadeSR-masters/jadesr/gameserver/src/net/handlers/inventory.json").expect("Failed to read inventory.json"); + let json_value: Value = serde_json::from_str(&json_data).expect("Failed to parse JSON data"); + + // Extract ranks + let r1: u32 = json_value[0]["rank"].as_i64().expect("Failed to get rank for Equipment1") as u32; + let r2: u32 = json_value[1]["rank"].as_i64().expect("Failed to get rank for Equipment2") as u32; + let t1: u32 = json_value[0]["tid"].as_i64().expect("Failed") as u32; + let t2: u32 = json_value[1]["tid"].as_i64().expect("Failed") as u32; + let l1: u32 = json_value[0]["level"].as_i64().expect("Failed") as u32; + let l2: u32 = json_value[0]["level"].as_i64().expect("Failed") as u32; + //let e_rank3: u32 = json_value[2]["rank"].as_i64().expect("Failed to get rank for Equipment3") as u32; + session + .send( + CMD_GET_BAG_SC_RSP, + GetBagScRsp { + kkdobdmaipc: vec![], + fllcfpejibd: vec![], + lgjeabihdpn: vec![], + retcode: 0, + equipment_list: vec![ + Equipment {tid: t1, rank: r1, exp: 0, unique_id: 57, promotion: 6, level: l1, base_avatar_id: 0, is_protected: true, ..Default::default()}, + Equipment {tid: t2, rank: r2, exp: 0, unique_id: 58, promotion: 6, level: l2, base_avatar_id: 0, is_protected: true, ..Default::default()}, + Equipment {tid: 23024, rank: 5, exp: 0, unique_id: 59, promotion: 6, level: 80, base_avatar_id: 0, is_protected: true, ..Default::default()}, + Equipment {tid: 23024, rank: 5, exp: 0, unique_id: 60, promotion: 6, level: 80, base_avatar_id: 0, is_protected: true, ..Default::default()}, + Equipment {tid: 23024, rank: 5, exp: 0, unique_id: 61, promotion: 6, level: 80, base_avatar_id: 0, is_protected: true, ..Default::default()}, + Equipment {tid: 23024, rank: 5, exp: 0, unique_id: 62, promotion: 6, level: 80, base_avatar_id: 0, is_protected: true, ..Default::default()}, + Equipment {tid: 23024, rank: 5, exp: 0, unique_id: 63, promotion: 6, level: 80, base_avatar_id: 0, is_protected: true, ..Default::default()}, + Equipment {tid: 23024, rank: 5, exp: 0, unique_id: 64, promotion: 6, level: 80, base_avatar_id: 0, is_protected: true, ..Default::default()}, + Equipment {tid: 23024, rank: 5, exp: 0, unique_id: 65, promotion: 6, level: 80, base_avatar_id: 0, is_protected: true, ..Default::default()}, + Equipment {tid: 23024, rank: 5, exp: 0, unique_id: 66, promotion: 6, level: 80, base_avatar_id: 0, is_protected: true, ..Default::default()}, + Equipment {tid: 23024, rank: 1, exp: 0, unique_id: 67, promotion: 0, level: 1, base_avatar_id: 0, is_protected: true, ..Default::default()}, + //Equipment {tid: 1, rank: 1, exp: 0, unique_id: 59, promotion: 6, level: 1, base_avatar_id: 0, is_protected: true, ..Default::default()} + ], + mbedbdbmekj: 0, + relic_list: vec![ + Relic { + unique_id: 1488, + base_avatar_id: 1315, // avatar id + tid: 61202, + level: 15, is_protected: true, + main_affix_id: 1, + sub_affix_list: vec![ RelicAffix { affix_id: 7, cnt: 830, step: 20 }], ..Default::default() } + ], + odeefdlejgg: vec![], + niemagjlpdl: vec![], + gddpphikjae: vec![], + macfjibhfad: vec![], + clkjaanbfpp: vec![ 101 ], + // .iter() + // .map(|id| { + // // { + // // tid: *id, + // // num: 500 + // // } + // }) + // .collect(), + biahmcppikj: vec![], + } + ) + .await + + // let rsp = GetBagScRsp { + // + // } +} \ No newline at end of file