From fbd1f367af45983e8249a43f3e33d67b6411b669 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 10 May 2024 23:26:44 +0200 Subject: [PATCH 1/3] Shitty Tiredness --- gameserver/src/net/handlers/battle.rs | 144 ++++++++++++++------------ 1 file changed, 79 insertions(+), 65 deletions(-) diff --git a/gameserver/src/net/handlers/battle.rs b/gameserver/src/net/handlers/battle.rs index 36eb3c3..97ef7a3 100644 --- a/gameserver/src/net/handlers/battle.rs +++ b/gameserver/src/net/handlers/battle.rs @@ -1,76 +1,90 @@ -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_start_cocoon_stage_cs_req( + session: &PlayerSession, + body: &StartCocoonStageCsReq, +) -> Result<()> { + let player_info = session.player_info(); -pub async fn on_get_bag_cs_req(session: &PlayerSession, _: &GetBagCsReq) -> Result<()> { - let json_data = fs::read_to_string("PATH HERE").expect("Failed to read inventory.json"); - let json_value: Value = serde_json::from_str(&json_data).expect("Failed to parse JSON data"); + let rsp = StartCocoonStageScRsp { + retcode: 0, + prop_entity_id: body.prop_entity_id, + cocoon_id: body.cocoon_id, + wave: body.wave, + battle_info: Some(SceneBattleInfo { + stage_id: 201012311, + logic_random_seed: 4444, + battle_id: 1, + battle_avatar_list: player_info + .lineup + .avatar_list + .iter() + .map(|avatar| BattleAvatar { + index: avatar.slot, + id: avatar.id, + level: 80, + promotion: 6, + rank: 6, + hp: 10000, + avatar_type: 3, + sp: Some(AmountInfo { + cur_amount: 10000, + max_amount: 10000, + }), + ..Default::default() + }) + .collect(), + monster_wave_list: globals + .monster_wave_list + .iter() + .map(|monster_list| SceneMonsterWave { + monster_list: monster_list + .iter() + .map(|id| SceneMonsterData { + monster_id: *id, + ..Default::default() + }) + .collect(), + ..Default::default() + }) + .collect(), + ..Default::default() + }), + }; - // 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_START_COCOON_STAGE_SC_RSP, rsp).await +} + +pub async fn on_get_cur_battle_info_cs_req( + session: &PlayerSession, + _body: &GetCurBattleInfoCsReq, +) -> Result<()> { 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![], - } + CMD_GET_CUR_BATTLE_INFO_SC_RSP, + GetCurBattleInfoScRsp { + battle_info: Some(SceneBattleInfo::default()), + ffbpkghgmjm: Some(Fjojkdhlonn::default()), + ..Default::default() + }, ) .await +} - // let rsp = GetBagScRsp { - // - // } +pub async fn on_pve_battle_result_cs_req( + session: &PlayerSession, + body: &PveBattleResultCsReq, +) -> Result<()> { + session + .send( + CMD_P_V_E_BATTLE_RESULT_SC_RSP, + PveBattleResultScRsp { + retcode: 0, + end_status: body.end_status, + battle_id: body.battle_id, + ..Default::default() + }, + ) + .await } \ No newline at end of file From 73a20a09eff8b4ac242ef0db05e1a2cd9e488156 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 10 May 2024 23:31:40 +0200 Subject: [PATCH 2/3] added more functionality ig --- gameserver/src/net/handlers/inventory.rs | 28 ++++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/gameserver/src/net/handlers/inventory.rs b/gameserver/src/net/handlers/inventory.rs index 465b642..4aff84b 100644 --- a/gameserver/src/net/handlers/inventory.rs +++ b/gameserver/src/net/handlers/inventory.rs @@ -9,7 +9,7 @@ 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("PATH HERE").expect("Failed to read inventory.json"); + 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 @@ -18,7 +18,11 @@ pub async fn on_get_bag_cs_req(session: &PlayerSession, _: &GetBagCsReq) -> Resu 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 l2: u32 = json_value[1]["level"].as_i64().expect("Failed") as u32; + let ip1: u32 = json_value[0]["is_protected"].as_i64().expect("Failed") as u32; + let ip2: u32 = json_value[1]["is_protected"].as_i64().expect("Failed") as u32; + let p1: u32 = json_value[0]["promotion"].as_i64().expect("Failed") as u32; + let p2: u32 = json_value[1]["promotion"].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( @@ -29,8 +33,8 @@ pub async fn on_get_bag_cs_req(session: &PlayerSession, _: &GetBagCsReq) -> Resu 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: t1, rank: r1, exp: 0, unique_id: 57, promotion: p1, level: l1, base_avatar_id: 0, is_protected: ip1, ..Default::default()}, + Equipment {tid: t2, rank: r2, exp: 0, unique_id: 58, promotion: p2, level: l2, base_avatar_id: 0, is_protected: ip2, ..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()}, @@ -57,14 +61,14 @@ pub async fn on_get_bag_cs_req(session: &PlayerSession, _: &GetBagCsReq) -> Resu gddpphikjae: vec![], macfjibhfad: vec![], clkjaanbfpp: vec![ 101 ], - // .iter() - // .map(|id| { - // // { - // // tid: *id, - // // num: 500 - // // } - // }) - // .collect(), + // .iter() + // .map(|id| { + // // { + // // tid: *id, + // // num: 500 + // // } + // }) + // .collect(), biahmcppikj: vec![], } ) From 607f4cc903e841e57bc0d48a8aa574aa52b8e2a4 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 10 May 2024 23:35:03 +0200 Subject: [PATCH 3/3] Evn more --- gameserver/src/net/handlers/inventory.json | 3 ++- gameserver/src/net/handlers/inventory.rs | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gameserver/src/net/handlers/inventory.json b/gameserver/src/net/handlers/inventory.json index 1970d69..0a6d5c3 100644 --- a/gameserver/src/net/handlers/inventory.json +++ b/gameserver/src/net/handlers/inventory.json @@ -1,4 +1,5 @@ [ {"tid": 23002, "rank": 3, "exp": 0, "unique_id": 57, "promotion": 6, "level": 75, "base_avatar_id": 0, "is_protected": true}, - {"tid": 23015, "rank": 4, "exp": 0, "unique_id": 58, "promotion": 6, "level": 80, "base_avatar_id": 0, "is_protected": true} + {"tid": 23015, "rank": 4, "exp": 0, "unique_id": 58, "promotion": 6, "level": 80, "base_avatar_id": 0, "is_protected": true}, + {"tid": 23015, "rank": 4, "exp": 0, "unique_id": 59, "promotion": 6, "level": 79, "base_avatar_id": 0, "is_protected": true} ] diff --git a/gameserver/src/net/handlers/inventory.rs b/gameserver/src/net/handlers/inventory.rs index 4aff84b..a3175ca 100644 --- a/gameserver/src/net/handlers/inventory.rs +++ b/gameserver/src/net/handlers/inventory.rs @@ -15,14 +15,19 @@ pub async fn on_get_bag_cs_req(session: &PlayerSession, _: &GetBagCsReq) -> Resu // 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 r3: u32 = json_value[2]["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 t3: u32 = json_value[2]["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[1]["level"].as_i64().expect("Failed") as u32; + let l3: u32 = json_value[2]["level"].as_i64().expect("Failed") as u32; let ip1: u32 = json_value[0]["is_protected"].as_i64().expect("Failed") as u32; let ip2: u32 = json_value[1]["is_protected"].as_i64().expect("Failed") as u32; + let ip3: u32 = json_value[2]["is_protected"].as_i64().expect("Failed") as u32; let p1: u32 = json_value[0]["promotion"].as_i64().expect("Failed") as u32; let p2: u32 = json_value[1]["promotion"].as_i64().expect("Failed") as u32; + let p3: u32 = json_value[2]["promotion"].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( @@ -35,7 +40,7 @@ pub async fn on_get_bag_cs_req(session: &PlayerSession, _: &GetBagCsReq) -> Resu equipment_list: vec![ Equipment {tid: t1, rank: r1, exp: 0, unique_id: 57, promotion: p1, level: l1, base_avatar_id: 0, is_protected: ip1, ..Default::default()}, Equipment {tid: t2, rank: r2, exp: 0, unique_id: 58, promotion: p2, level: l2, base_avatar_id: 0, is_protected: ip2, ..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: t3, rank: r3, exp: 0, unique_id: 59, promotion: p3, level: l3, base_avatar_id: 0, is_protected: ip3, ..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()},