Fixed HDD commissions | Reverted flatc expect #6

Merged
xeon merged 8 commits from :master into master 2025-03-18 21:50:56 +00:00
50 changed files with 15803 additions and 11006 deletions
Showing only changes of commit ee521a013b - Show all commits

View file

@ -42,7 +42,11 @@ impl GameState {
.iter() .iter()
.map(|&avatar_id| AvatarUnit { .map(|&avatar_id| AvatarUnit {
avatar_id, avatar_id,
properties: property_util::calculate_for_avatar(avatar_id, filecfg, dungeon_equip), properties: property_util::calculate_for_avatar(
avatar_id,
filecfg,
dungeon_equip,
),
}) })
.collect(), .collect(),
buddy_list: vec![BuddyUnit { buddy_list: vec![BuddyUnit {
@ -77,7 +81,11 @@ impl GameState {
.iter() .iter()
.map(|&avatar_id| AvatarUnit { .map(|&avatar_id| AvatarUnit {
avatar_id, avatar_id,
properties: property_util::calculate_for_avatar(avatar_id, filecfg, dungeon_equip), properties: property_util::calculate_for_avatar(
avatar_id,
filecfg,
dungeon_equip,
),
}) })
.collect(), .collect(),
buddy_list: vec![BuddyUnit { buddy_list: vec![BuddyUnit {

View file

@ -1,6 +1,9 @@
use std::collections::HashMap; use std::collections::HashMap;
use trigger_fileconfig::{AvatarBattleTemplate, AvatarLevelAdvanceTemplate, AvatarPassiveSkillTemplate, NapFileCfg, WeaponLevelTemplate, WeaponStarTemplate, WeaponTemplate}; use trigger_fileconfig::{
AvatarBattleTemplate, AvatarLevelAdvanceTemplate, AvatarPassiveSkillTemplate, NapFileCfg,
WeaponLevelTemplate, WeaponStarTemplate, WeaponTemplate,
};
use trigger_logic::{battle::EPropertyType, skill::EAvatarSkillType}; use trigger_logic::{battle::EPropertyType, skill::EAvatarSkillType};
use trigger_protocol::{Avatar, DungeonEquipInfo, Equip, Weapon}; use trigger_protocol::{Avatar, DungeonEquipInfo, Equip, Weapon};
@ -17,7 +20,7 @@ struct WeaponFileCfg<'a> {
} }
const BEN_AVATAR_ID: u32 = 1121; const BEN_AVATAR_ID: u32 = 1121;
const BEN_CORE_PASSIVE_PERCENTAGE: [i32;7] = [40, 46, 52, 60, 66, 72, 80]; const BEN_CORE_PASSIVE_PERCENTAGE: [i32; 7] = [40, 46, 52, 60, 66, 72, 80];
pub fn calculate_for_avatar( pub fn calculate_for_avatar(
avatar_id: u32, avatar_id: u32,
@ -25,23 +28,50 @@ pub fn calculate_for_avatar(
dungeon_equip: &DungeonEquipInfo, dungeon_equip: &DungeonEquipInfo,
) -> HashMap<u32, i32> { ) -> HashMap<u32, i32> {
let mut calculated_properties = HashMap::<_, _>::new(); let mut calculated_properties = HashMap::<_, _>::new();
let Some(player_avatar) = dungeon_equip.avatar_list.iter().find(|a| (*a).id == avatar_id) else { return calculated_properties; }; let Some(player_avatar) = dungeon_equip
let Some(avatar_file_cfg) = get_avatar_filecfg(avatar_id, filecfg) else { return calculated_properties; }; .avatar_list
.iter()
.find(|a| (*a).id == avatar_id)
else {
return calculated_properties;
};
let Some(avatar_file_cfg) = get_avatar_filecfg(avatar_id, filecfg) else {
return calculated_properties;
};
insert_avatar_battle_template_properties(&avatar_file_cfg, &mut calculated_properties); insert_avatar_battle_template_properties(&avatar_file_cfg, &mut calculated_properties);
insert_avatar_battle_level_advance_properties(&avatar_file_cfg, player_avatar, &mut calculated_properties); insert_avatar_battle_level_advance_properties(
&avatar_file_cfg,
player_avatar,
&mut calculated_properties,
);
perform_avatar_growth_promotion_calculations(player_avatar, &mut calculated_properties); perform_avatar_growth_promotion_calculations(player_avatar, &mut calculated_properties);
add_avatar_passive_skill_properties(&avatar_file_cfg, player_avatar, &mut calculated_properties); add_avatar_passive_skill_properties(
let player_weapon = dungeon_equip.weapon_list.iter().find(|w| w.uid == player_avatar.cur_weapon_uid); &avatar_file_cfg,
player_avatar,
&mut calculated_properties,
);
let player_weapon = dungeon_equip
.weapon_list
.iter()
.find(|w| w.uid == player_avatar.cur_weapon_uid);
if player_weapon.is_some() { if player_weapon.is_some() {
match get_weapon_filecfg(player_weapon.unwrap(), filecfg) { match get_weapon_filecfg(player_weapon.unwrap(), filecfg) {
Some(weapon_file_cfg) => { Some(weapon_file_cfg) => {
add_weapon_template_properties(&weapon_file_cfg, &mut calculated_properties); add_weapon_template_properties(&weapon_file_cfg, &mut calculated_properties);
}, }
None => {}, None => {}
}; };
} }
let player_dressed_equip_uids: Vec<u32> = player_avatar.dressed_equip_list.iter().map(|de| de.equip_uid).collect(); let player_dressed_equip_uids: Vec<u32> = player_avatar
let player_equips: Vec<&Equip> = dungeon_equip.equip_list.iter().filter(|e| player_dressed_equip_uids.contains(&e.uid)).collect(); .dressed_equip_list
.iter()
.map(|de| de.equip_uid)
.collect();
let player_equips: Vec<&Equip> = dungeon_equip
.equip_list
.iter()
.filter(|e| player_dressed_equip_uids.contains(&e.uid))
.collect();
if player_equips.len() > 0 { if player_equips.len() > 0 {
add_player_equip_properties(&player_equips, filecfg, &mut calculated_properties); add_player_equip_properties(&player_equips, filecfg, &mut calculated_properties);
add_equipment_suit_properties(&player_equips, filecfg, &mut calculated_properties); add_equipment_suit_properties(&player_equips, filecfg, &mut calculated_properties);
@ -58,14 +88,20 @@ fn get_avatar_filecfg(
avatar_id: u32, avatar_id: u32,
filecfg: &'static NapFileCfg, filecfg: &'static NapFileCfg,
) -> Option<AvatarFileCfg<'static>> { ) -> Option<AvatarFileCfg<'static>> {
let Some(avatar_battle_template) = filecfg.avatar_battle_template_tb().data().unwrap() let Some(avatar_battle_template) = filecfg
.avatar_battle_template_tb()
.data()
.unwrap()
.iter() .iter()
.find(|tmpl| tmpl.id() == avatar_id as i32) .find(|tmpl| tmpl.id() == avatar_id as i32)
else { else {
return None; return None;
}; };
let avatar_passive_skill_templates: Vec<AvatarPassiveSkillTemplate> = filecfg.avatar_passive_skill_template_tb().data().unwrap() let avatar_passive_skill_templates: Vec<AvatarPassiveSkillTemplate> = filecfg
.avatar_passive_skill_template_tb()
.data()
.unwrap()
.iter() .iter()
.filter(|tmpl| tmpl.avatar_id() == avatar_id as i32) .filter(|tmpl| tmpl.avatar_id() == avatar_id as i32)
.collect(); .collect();
@ -73,10 +109,13 @@ fn get_avatar_filecfg(
return None; return None;
} }
let avatar_level_advances: Vec<AvatarLevelAdvanceTemplate> = filecfg.avatar_level_advance_template_tb().data().unwrap() let avatar_level_advances: Vec<AvatarLevelAdvanceTemplate> = filecfg
.iter() .avatar_level_advance_template_tb()
.filter(|tmpl| tmpl.avatar_id() == avatar_id as i32) .data()
.collect(); .unwrap()
.iter()
.filter(|tmpl| tmpl.avatar_id() == avatar_id as i32)
.collect();
if avatar_level_advances.len() == 0 { if avatar_level_advances.len() == 0 {
return None; return None;
} }
@ -90,30 +129,75 @@ fn get_avatar_filecfg(
fn insert_avatar_battle_template_properties( fn insert_avatar_battle_template_properties(
avatar_file_cfg: &AvatarFileCfg, avatar_file_cfg: &AvatarFileCfg,
properties: &mut HashMap<u32, i32> properties: &mut HashMap<u32, i32>,
) { ) {
properties.insert(EPropertyType::HpMaxBase.into(), avatar_file_cfg.avatar_battle_template.hp_max()); properties.insert(
properties.insert(EPropertyType::HpMaxGrowth.into(), avatar_file_cfg.avatar_battle_template.health_growth()); EPropertyType::HpMaxBase.into(),
properties.insert(EPropertyType::AtkBase.into(), avatar_file_cfg.avatar_battle_template.attack()); avatar_file_cfg.avatar_battle_template.hp_max(),
properties.insert(EPropertyType::AtkGrowth.into(), avatar_file_cfg.avatar_battle_template.attack_growth()); );
properties.insert(EPropertyType::BreakStunBase.into(), avatar_file_cfg.avatar_battle_template.break_stun()); properties.insert(
properties.insert(EPropertyType::DefBase.into(), avatar_file_cfg.avatar_battle_template.defence()); EPropertyType::HpMaxGrowth.into(),
properties.insert(EPropertyType::DefGrowth.into(), avatar_file_cfg.avatar_battle_template.defence_growth()); avatar_file_cfg.avatar_battle_template.health_growth(),
properties.insert(EPropertyType::CritBase.into(), avatar_file_cfg.avatar_battle_template.crit()); );
properties.insert(EPropertyType::CritDmgBase.into(), avatar_file_cfg.avatar_battle_template.crit_damage()); properties.insert(
properties.insert(EPropertyType::PenBase.into(), avatar_file_cfg.avatar_battle_template.pen_rate()); EPropertyType::AtkBase.into(),
properties.insert(EPropertyType::PenValueBase.into(), avatar_file_cfg.avatar_battle_template.pen_delta()); avatar_file_cfg.avatar_battle_template.attack(),
properties.insert(EPropertyType::SpRecoverBase.into(), avatar_file_cfg.avatar_battle_template.sp_recover()); );
properties.insert(EPropertyType::ElementMysteryBase.into(), avatar_file_cfg.avatar_battle_template.element_mystery()); properties.insert(
properties.insert(EPropertyType::ElementAbnormalPowerBase.into(), avatar_file_cfg.avatar_battle_template.element_abnormal_power()); EPropertyType::AtkGrowth.into(),
avatar_file_cfg.avatar_battle_template.attack_growth(),
);
properties.insert(
EPropertyType::BreakStunBase.into(),
avatar_file_cfg.avatar_battle_template.break_stun(),
);
properties.insert(
EPropertyType::DefBase.into(),
avatar_file_cfg.avatar_battle_template.defence(),
);
properties.insert(
EPropertyType::DefGrowth.into(),
avatar_file_cfg.avatar_battle_template.defence_growth(),
);
properties.insert(
EPropertyType::CritBase.into(),
avatar_file_cfg.avatar_battle_template.crit(),
);
properties.insert(
EPropertyType::CritDmgBase.into(),
avatar_file_cfg.avatar_battle_template.crit_damage(),
);
properties.insert(
EPropertyType::PenBase.into(),
avatar_file_cfg.avatar_battle_template.pen_rate(),
);
properties.insert(
EPropertyType::PenValueBase.into(),
avatar_file_cfg.avatar_battle_template.pen_delta(),
);
properties.insert(
EPropertyType::SpRecoverBase.into(),
avatar_file_cfg.avatar_battle_template.sp_recover(),
);
properties.insert(
EPropertyType::ElementMysteryBase.into(),
avatar_file_cfg.avatar_battle_template.element_mystery(),
);
properties.insert(
EPropertyType::ElementAbnormalPowerBase.into(),
avatar_file_cfg
.avatar_battle_template
.element_abnormal_power(),
);
} }
fn insert_avatar_battle_level_advance_properties( fn insert_avatar_battle_level_advance_properties(
avatar_file_cfg: &AvatarFileCfg, avatar_file_cfg: &AvatarFileCfg,
player_avatar: &Avatar, player_avatar: &Avatar,
properties: &mut HashMap<u32, i32> properties: &mut HashMap<u32, i32>,
) { ) {
let Some(avatar_level_advance) = avatar_file_cfg.avatar_level_advances let Some(avatar_level_advance) = avatar_file_cfg
.avatar_level_advances
.iter() .iter()
.find(|tmpl| tmpl.id() == player_avatar.rank as i32) .find(|tmpl| tmpl.id() == player_avatar.rank as i32)
else { else {
@ -124,56 +208,73 @@ fn insert_avatar_battle_level_advance_properties(
return; return;
}; };
properties.insert(EPropertyType::HpMaxAdvance.into(), avatar_level_advance.hp_max()); properties.insert(
properties.insert(EPropertyType::AtkAdvance.into(), avatar_level_advance.attack()); EPropertyType::HpMaxAdvance.into(),
properties.insert(EPropertyType::DefAdvance.into(), avatar_level_advance.defence()); avatar_level_advance.hp_max(),
);
properties.insert(
EPropertyType::AtkAdvance.into(),
avatar_level_advance.attack(),
);
properties.insert(
EPropertyType::DefAdvance.into(),
avatar_level_advance.defence(),
);
} }
fn perform_avatar_growth_promotion_calculations( fn perform_avatar_growth_promotion_calculations(
player_avatar: &Avatar, player_avatar: &Avatar,
properties: &mut HashMap<u32, i32> properties: &mut HashMap<u32, i32>,
) { ) {
properties.insert( properties.insert(
EPropertyType::HpMaxBase.into(), EPropertyType::HpMaxBase.into(),
properties.get(&EPropertyType::HpMaxBase.into()).unwrap() properties.get(&EPropertyType::HpMaxBase.into()).unwrap()
+ (((player_avatar.level - 1) as f32 * *properties.get(&EPropertyType::HpMaxGrowth.into()).unwrap() as f32) / 10000f32) as i32 + (((player_avatar.level - 1) as f32
+ properties.get(&EPropertyType::HpMaxAdvance.into()).unwrap() * *properties.get(&EPropertyType::HpMaxGrowth.into()).unwrap() as f32)
/ 10000f32) as i32
+ properties.get(&EPropertyType::HpMaxAdvance.into()).unwrap(),
); );
properties.insert( properties.insert(
EPropertyType::AtkBase.into(), EPropertyType::AtkBase.into(),
properties.get(&EPropertyType::AtkBase.into()).unwrap() properties.get(&EPropertyType::AtkBase.into()).unwrap()
+ (((player_avatar.level - 1) as f32 * *properties.get(&EPropertyType::AtkGrowth.into()).unwrap() as f32) / 10000f32) as i32 + (((player_avatar.level - 1) as f32
+ properties.get(&EPropertyType::AtkAdvance.into()).unwrap() * *properties.get(&EPropertyType::AtkGrowth.into()).unwrap() as f32)
/ 10000f32) as i32
+ properties.get(&EPropertyType::AtkAdvance.into()).unwrap(),
); );
properties.insert( properties.insert(
EPropertyType::DefBase.into(), EPropertyType::DefBase.into(),
properties.get(&EPropertyType::DefBase.into()).unwrap() properties.get(&EPropertyType::DefBase.into()).unwrap()
+ (((player_avatar.level - 1) as f32 * *properties.get(&EPropertyType::DefGrowth.into()).unwrap() as f32) / 10000f32) as i32 + (((player_avatar.level - 1) as f32
+ properties.get(&EPropertyType::DefAdvance.into()).unwrap() * *properties.get(&EPropertyType::DefGrowth.into()).unwrap() as f32)
/ 10000f32) as i32
+ properties.get(&EPropertyType::DefAdvance.into()).unwrap(),
); );
} }
fn add_avatar_passive_skill_properties( fn add_avatar_passive_skill_properties(
avatar_file_cfg: &AvatarFileCfg, avatar_file_cfg: &AvatarFileCfg,
player_avatar: &Avatar, player_avatar: &Avatar,
properties: &mut HashMap<u32, i32> properties: &mut HashMap<u32, i32>,
) { ) {
let passive_skill_level = player_avatar.skill_type_level.iter() let passive_skill_level = player_avatar
.skill_type_level
.iter()
.find(|s| s.skill_type == EAvatarSkillType::CoreSkill as u32) .find(|s| s.skill_type == EAvatarSkillType::CoreSkill as u32)
.unwrap() .unwrap()
.level; .level;
avatar_file_cfg.avatar_passive_skill_templates avatar_file_cfg
.avatar_passive_skill_templates
.iter() .iter()
.find(|a| a.unlock_passive_skill_level() == passive_skill_level as i32) .find(|a| a.unlock_passive_skill_level() == passive_skill_level as i32)
.map(|tmpl| tmpl.propertys().unwrap()) .map(|tmpl| tmpl.propertys().unwrap())
.unwrap() .unwrap()
.iter() .iter()
.for_each(|p| { .for_each(|p| {
properties.insert( properties.insert(
p.property() as u32, p.property() as u32,
properties.get(&(p.property() as u32)).unwrap_or(&0) properties.get(&(p.property() as u32)).unwrap_or(&0) + p.value(),
+ p.value()
); );
}); });
} }
@ -182,26 +283,35 @@ fn get_weapon_filecfg(
player_weapon: &Weapon, player_weapon: &Weapon,
filecfg: &'static NapFileCfg, filecfg: &'static NapFileCfg,
) -> Option<WeaponFileCfg<'static>> { ) -> Option<WeaponFileCfg<'static>> {
let Some(weapon_template) = filecfg.weapon_template_tb().data().unwrap() let Some(weapon_template) = filecfg
.weapon_template_tb()
.data()
.unwrap()
.iter() .iter()
.find(|tmpl| tmpl.item_id() == player_weapon.id as i32) .find(|tmpl| tmpl.item_id() == player_weapon.id as i32)
else { else {
return None; return None;
}; };
let Some(weapon_level_template) = filecfg.weapon_level_template_tb().data().unwrap() let Some(weapon_level_template) = filecfg
.weapon_level_template_tb()
.data()
.unwrap()
.iter() .iter()
.find(|tmpl| tmpl.level() == player_weapon.level as i32) .find(|tmpl| tmpl.level() == player_weapon.level as i32)
else { else {
return None; return None;
}; };
let Some(weapon_star_template) = filecfg.weapon_star_template_tb().data().unwrap() let Some(weapon_star_template) = filecfg
.weapon_star_template_tb()
.data()
.unwrap()
.iter() .iter()
.find(|tmpl| tmpl.star() == player_weapon.star as i32) .find(|tmpl| tmpl.star() == player_weapon.star as i32)
else { else {
return None; return None;
}; };
Some(WeaponFileCfg { Some(WeaponFileCfg {
weapon_template, weapon_template,
@ -216,235 +326,297 @@ fn add_weapon_template_properties(
) { ) {
let base_property = weapon_file_cfg.weapon_template.base_property().unwrap(); let base_property = weapon_file_cfg.weapon_template.base_property().unwrap();
let base_property_value = base_property.value() let base_property_value = base_property.value()
+ (base_property.value() as f32 * weapon_file_cfg.weapon_level_template.rate() as f32 / 10000f32) as i32 + (base_property.value() as f32 * weapon_file_cfg.weapon_level_template.rate() as f32
+ (base_property.value() as f32 * weapon_file_cfg.weapon_star_template.star_rate() as f32 / 10000f32) as i32 / 10000f32) as i32
; + (base_property.value() as f32 * weapon_file_cfg.weapon_star_template.star_rate() as f32
/ 10000f32) as i32;
properties.insert( properties.insert(
base_property.property() as u32, base_property.property() as u32,
*properties.get(&(base_property.property() as u32)).unwrap_or(&0) *properties
+ base_property_value .get(&(base_property.property() as u32))
.unwrap_or(&0)
+ base_property_value,
); );
let rand_property = weapon_file_cfg.weapon_template.rand_property().unwrap(); let rand_property = weapon_file_cfg.weapon_template.rand_property().unwrap();
let rand_property_value = rand_property.value() let rand_property_value = rand_property.value()
+ (rand_property.value() as f32 * weapon_file_cfg.weapon_star_template.rand_rate() as f32 / 10000f32) as i32 + (rand_property.value() as f32 * weapon_file_cfg.weapon_star_template.rand_rate() as f32
; / 10000f32) as i32;
properties.insert( properties.insert(
rand_property.property() as u32, rand_property.property() as u32,
*properties.get(&(rand_property.property() as u32)).unwrap_or(&0) *properties
+ rand_property_value .get(&(rand_property.property() as u32))
.unwrap_or(&0)
+ rand_property_value,
); );
} }
fn add_player_equip_properties( fn add_player_equip_properties(
player_equips: &Vec<&Equip>, player_equips: &Vec<&Equip>,
filecfg: &'static NapFileCfg, filecfg: &'static NapFileCfg,
properties: &mut HashMap<u32, i32> properties: &mut HashMap<u32, i32>,
) { ) {
player_equips.iter().for_each(|pe| { player_equips.iter().for_each(|pe| {
let equip_rarity = (pe.id / 10) % 10; let equip_rarity = (pe.id / 10) % 10;
let property_rate = filecfg.equipment_level_template_tb() let property_rate = filecfg
.data().unwrap() .equipment_level_template_tb()
.iter().find(|tmpl| .data()
tmpl.rarity() == equip_rarity as i32 .unwrap()
&& tmpl.level() == pe.level as i32
).map(|tmpl| tmpl.property_rate())
.unwrap_or(1);
pe.propertys
.iter() .iter()
.for_each(|p| { .find(|tmpl| tmpl.rarity() == equip_rarity as i32 && tmpl.level() == pe.level as i32)
properties.insert( .map(|tmpl| tmpl.property_rate())
p.key, .unwrap_or(1);
properties.get(&p.key).unwrap_or(&0) pe.propertys.iter().for_each(|p| {
properties.insert(
p.key,
properties.get(&p.key).unwrap_or(&0)
+ p.base_value as i32 + p.base_value as i32
+ (p.base_value as f32 * property_rate as f32 / 10000f32) as i32 + (p.base_value as f32 * property_rate as f32 / 10000f32) as i32,
); );
}); });
pe.sub_propertys.iter() pe.sub_propertys.iter().for_each(|p| {
.for_each(|p| { properties.insert(
properties.insert( p.key,
p.key, properties.get(&p.key).unwrap_or(&0)
properties.get(&p.key).unwrap_or(&0) + (p.base_value as f32 * p.add_value as f32) as i32,
+ (p.base_value as f32 * p.add_value as f32) as i32 );
); });
});
}); });
} }
fn add_equipment_suit_properties( fn add_equipment_suit_properties(
player_equips: &Vec<&Equip>, player_equips: &Vec<&Equip>,
filecfg: &'static NapFileCfg, filecfg: &'static NapFileCfg,
properties: &mut HashMap<u32, i32> properties: &mut HashMap<u32, i32>,
) { ) {
let mut suit_counts = HashMap::<i32, i32>::new(); let mut suit_counts = HashMap::<i32, i32>::new();
player_equips.iter().for_each(|pe| { player_equips.iter().for_each(|pe| {
let suit_id = pe.id as i32 / 100 * 100; let suit_id = pe.id as i32 / 100 * 100;
suit_counts.insert( suit_counts.insert(suit_id, *suit_counts.get(&suit_id).unwrap_or(&0) + 1);
suit_id,
*suit_counts.get(&suit_id).unwrap_or(&0) + 1
);
}); });
suit_counts.iter().for_each(|sc| { suit_counts.iter().for_each(|sc| {
let Some(equipment_suit_template) = filecfg.equipment_suit_template_tb() let Some(equipment_suit_template) = filecfg
.data().unwrap() .equipment_suit_template_tb()
.iter().find(|tmpl| tmpl.id() == *sc.0) .data()
else { return; }; .unwrap()
.iter()
.find(|tmpl| tmpl.id() == *sc.0)
else {
return;
};
if equipment_suit_template.primary_condition() <= *sc.1 { if equipment_suit_template.primary_condition() <= *sc.1 {
equipment_suit_template.primary_suit_propertys().unwrap() equipment_suit_template
.iter().for_each(|p| { .primary_suit_propertys()
properties.insert( .unwrap()
p.property() as u32, .iter()
properties.get(&(p.property() as u32)).unwrap_or(&0) .for_each(|p| {
+ p.value() properties.insert(
); p.property() as u32,
}); properties.get(&(p.property() as u32)).unwrap_or(&0) + p.value(),
);
});
} }
}); });
} }
fn calculate_final_properties(properties: &mut HashMap<u32, i32>) {
fn calculate_final_properties(
properties: &mut HashMap<u32, i32>
) {
properties.insert( properties.insert(
EPropertyType::HpMax.into(), EPropertyType::HpMax.into(),
properties.get(&EPropertyType::HpMaxBase.into()).unwrap() properties.get(&EPropertyType::HpMaxBase.into()).unwrap()
+ ( + (*properties.get(&EPropertyType::HpMaxBase.into()).unwrap() as f32
*properties.get(&EPropertyType::HpMaxBase.into()).unwrap() as f32 * *properties
* *properties.get(&EPropertyType::HpMaxRatio.into()).unwrap_or(&0) as f32 .get(&EPropertyType::HpMaxRatio.into())
/ 10000f32 .unwrap_or(&0) as f32
).ceil() as i32 / 10000f32)
+ properties.get(&EPropertyType::HpMaxDelta.into()).unwrap_or(&0) .ceil() as i32
+ properties
.get(&EPropertyType::HpMaxDelta.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::Atk.into(), EPropertyType::Atk.into(),
properties.get(&EPropertyType::AtkBase.into()).unwrap() properties.get(&EPropertyType::AtkBase.into()).unwrap()
+ ( + (*properties.get(&EPropertyType::AtkBase.into()).unwrap() as f32
*properties.get(&EPropertyType::AtkBase.into()).unwrap() as f32 * *properties
* *properties.get(&EPropertyType::AtkRatio.into()).unwrap_or(&0) as f32 .get(&EPropertyType::AtkRatio.into())
/ 10000f32 .unwrap_or(&0) as f32
) as i32 / 10000f32) as i32
+ properties.get(&EPropertyType::AtkDelta.into()).unwrap_or(&0) + properties
.get(&EPropertyType::AtkDelta.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::BreakStun.into(), EPropertyType::BreakStun.into(),
properties.get(&EPropertyType::BreakStunBase.into()).unwrap() properties
+ ( .get(&EPropertyType::BreakStunBase.into())
*properties.get(&EPropertyType::BreakStunBase.into()).unwrap() as f32 .unwrap()
* *properties.get(&EPropertyType::BreakStunRatio.into()).unwrap_or(&0) as f32 + (*properties
/ 10000f32 .get(&EPropertyType::BreakStunBase.into())
) as i32 .unwrap() as f32
+ properties.get(&EPropertyType::BreakStunDelta.into()).unwrap_or(&0) * *properties
.get(&EPropertyType::BreakStunRatio.into())
.unwrap_or(&0) as f32
/ 10000f32) as i32
+ properties
.get(&EPropertyType::BreakStunDelta.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::Def.into(), EPropertyType::Def.into(),
properties.get(&EPropertyType::DefBase.into()).unwrap() properties.get(&EPropertyType::DefBase.into()).unwrap()
+ ( + (*properties.get(&EPropertyType::DefBase.into()).unwrap() as f32
*properties.get(&EPropertyType::DefBase.into()).unwrap() as f32 * *properties
* *properties.get(&EPropertyType::DefRatio.into()).unwrap_or(&0) as f32 .get(&EPropertyType::DefRatio.into())
/ 10000f32 .unwrap_or(&0) as f32
) as i32 / 10000f32) as i32
+ properties.get(&EPropertyType::DefDelta.into()).unwrap_or(&0) + properties
.get(&EPropertyType::DefDelta.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::Crit.into(), EPropertyType::Crit.into(),
properties.get(&EPropertyType::CritBase.into()).unwrap() properties.get(&EPropertyType::CritBase.into()).unwrap()
+ properties.get(&EPropertyType::CritDelta.into()).unwrap_or(&0) + properties
.get(&EPropertyType::CritDelta.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::CritDmg.into(), EPropertyType::CritDmg.into(),
properties.get(&EPropertyType::CritDmgBase.into()).unwrap() properties.get(&EPropertyType::CritDmgBase.into()).unwrap()
+ properties.get(&EPropertyType::CritDmgDelta.into()).unwrap_or(&0) + properties
.get(&EPropertyType::CritDmgDelta.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::Pen.into(), EPropertyType::Pen.into(),
properties.get(&EPropertyType::PenBase.into()).unwrap() properties.get(&EPropertyType::PenBase.into()).unwrap()
+ properties.get(&EPropertyType::PenDelta.into()).unwrap_or(&0) + properties
.get(&EPropertyType::PenDelta.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::PenValue.into(), EPropertyType::PenValue.into(),
properties.get(&EPropertyType::PenValueBase.into()).unwrap() properties.get(&EPropertyType::PenValueBase.into()).unwrap()
+ properties.get(&EPropertyType::PenValueDelta.into()).unwrap_or(&0) + properties
.get(&EPropertyType::PenValueDelta.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::SpRecover.into(), EPropertyType::SpRecover.into(),
properties.get(&EPropertyType::SpRecoverBase.into()).unwrap() properties
+ ( .get(&EPropertyType::SpRecoverBase.into())
*properties.get(&EPropertyType::SpRecoverBase.into()).unwrap() as f32 .unwrap()
* *properties.get(&EPropertyType::SpRecoverRatio.into()).unwrap_or(&0) as f32 + (*properties
/ 10000f32 .get(&EPropertyType::SpRecoverBase.into())
) as i32 .unwrap() as f32
+ properties.get(&EPropertyType::SpRecoverDelta.into()).unwrap_or(&0) * *properties
.get(&EPropertyType::SpRecoverRatio.into())
.unwrap_or(&0) as f32
/ 10000f32) as i32
+ properties
.get(&EPropertyType::SpRecoverDelta.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::ElementMystery.into(), EPropertyType::ElementMystery.into(),
properties.get(&EPropertyType::ElementMysteryBase.into()).unwrap() properties
+ properties.get(&EPropertyType::ElementMysteryDelta.into()).unwrap_or(&0) .get(&EPropertyType::ElementMysteryBase.into())
.unwrap()
+ properties
.get(&EPropertyType::ElementMysteryDelta.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::ElementAbnormalPower.into(), EPropertyType::ElementAbnormalPower.into(),
properties.get(&EPropertyType::ElementAbnormalPowerBase.into()).unwrap() properties
+ ( .get(&EPropertyType::ElementAbnormalPowerBase.into())
*properties.get(&EPropertyType::ElementAbnormalPowerBase.into()).unwrap() as f32 .unwrap()
* *properties.get(&EPropertyType::ElementAbnormalPowerRatio.into()).unwrap_or(&0) as f32 + (*properties
/ 10000f32 .get(&EPropertyType::ElementAbnormalPowerBase.into())
) as i32 .unwrap() as f32
+ properties.get(&EPropertyType::ElementAbnormalPowerDelta.into()).unwrap_or(&0) * *properties
.get(&EPropertyType::ElementAbnormalPowerRatio.into())
.unwrap_or(&0) as f32
/ 10000f32) as i32
+ properties
.get(&EPropertyType::ElementAbnormalPowerDelta.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::AddedDamageRatioPhysics.into(), EPropertyType::AddedDamageRatioPhysics.into(),
properties.get(&EPropertyType::AddedDamageRatioPhysics1.into()).unwrap_or(&0) properties
+ properties.get(&EPropertyType::AddedDamageRatioPhysics3.into()).unwrap_or(&0) .get(&EPropertyType::AddedDamageRatioPhysics1.into())
.unwrap_or(&0)
+ properties
.get(&EPropertyType::AddedDamageRatioPhysics3.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::AddedDamageRatioFire.into(), EPropertyType::AddedDamageRatioFire.into(),
properties.get(&EPropertyType::AddedDamageRatioFire1.into()).unwrap_or(&0) properties
+ properties.get(&EPropertyType::AddedDamageRatioFire3.into()).unwrap_or(&0) .get(&EPropertyType::AddedDamageRatioFire1.into())
.unwrap_or(&0)
+ properties
.get(&EPropertyType::AddedDamageRatioFire3.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::AddedDamageRatioIce.into(), EPropertyType::AddedDamageRatioIce.into(),
properties.get(&EPropertyType::AddedDamageRatioIce1.into()).unwrap_or(&0) properties
+ properties.get(&EPropertyType::AddedDamageRatioIce3.into()).unwrap_or(&0) .get(&EPropertyType::AddedDamageRatioIce1.into())
.unwrap_or(&0)
+ properties
.get(&EPropertyType::AddedDamageRatioIce3.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::AddedDamageRatioElec.into(), EPropertyType::AddedDamageRatioElec.into(),
properties.get(&EPropertyType::AddedDamageRatioElec1.into()).unwrap_or(&0) properties
+ properties.get(&EPropertyType::AddedDamageRatioElec3.into()).unwrap_or(&0) .get(&EPropertyType::AddedDamageRatioElec1.into())
.unwrap_or(&0)
+ properties
.get(&EPropertyType::AddedDamageRatioElec3.into())
.unwrap_or(&0),
); );
properties.insert( properties.insert(
EPropertyType::AddedDamageRatioEther.into(), EPropertyType::AddedDamageRatioEther.into(),
properties.get(&EPropertyType::AddedDamageRatioEther1.into()).unwrap_or(&0) properties
+ properties.get(&EPropertyType::AddedDamageRatioEther3.into()).unwrap_or(&0) .get(&EPropertyType::AddedDamageRatioEther1.into())
.unwrap_or(&0)
+ properties
.get(&EPropertyType::AddedDamageRatioEther3.into())
.unwrap_or(&0),
); );
} }
fn add_ben_core_passive( fn add_ben_core_passive(
avatar_id: u32, avatar_id: u32,
player_avatar: &Avatar, player_avatar: &Avatar,
properties: &mut HashMap<u32, i32> properties: &mut HashMap<u32, i32>,
) { ) {
if avatar_id != BEN_AVATAR_ID { if avatar_id != BEN_AVATAR_ID {
return; return;
} }
let core_level = player_avatar.skill_type_level.iter().find(|sl| sl.skill_type == EAvatarSkillType::CoreSkill as u32).unwrap().level as usize; let core_level = player_avatar
.skill_type_level
.iter()
.find(|sl| sl.skill_type == EAvatarSkillType::CoreSkill as u32)
.unwrap()
.level as usize;
let def_atk_bonus = match core_level { let def_atk_bonus = match core_level {
1..=7 => { 1..=7 => {
*properties.get(&EPropertyType::Def.into()).unwrap_or(&0) *properties.get(&EPropertyType::Def.into()).unwrap_or(&0)
* BEN_CORE_PASSIVE_PERCENTAGE[core_level - 1] * BEN_CORE_PASSIVE_PERCENTAGE[core_level - 1]
/ 100 / 100
}, }
_ => 0, _ => 0,
}; };
properties.insert( properties.insert(
EPropertyType::Atk.into(), EPropertyType::Atk.into(),
*properties.get(&EPropertyType::Atk.into()).unwrap_or(&0) *properties.get(&EPropertyType::Atk.into()).unwrap_or(&0) + def_atk_bonus,
+ def_atk_bonus
); );
} }
fn remove_custom_properties( fn remove_custom_properties(properties: &mut HashMap<u32, i32>) {
properties: &mut HashMap<u32, i32>
) {
properties.remove(&EPropertyType::HpMaxGrowth.into()); properties.remove(&EPropertyType::HpMaxGrowth.into());
properties.remove(&EPropertyType::AtkGrowth.into()); properties.remove(&EPropertyType::AtkGrowth.into());
properties.remove(&EPropertyType::DefGrowth.into()); properties.remove(&EPropertyType::DefGrowth.into());
@ -453,24 +625,89 @@ fn remove_custom_properties(
properties.remove(&EPropertyType::DefAdvance.into()); properties.remove(&EPropertyType::DefAdvance.into());
} }
fn set_battle_properties( fn set_battle_properties(properties: &mut HashMap<u32, i32>) {
properties: &mut HashMap<u32, i32> properties.insert(
) { EPropertyType::HpMaxBattle.into(),
properties.insert(EPropertyType::HpMaxBattle.into(), *properties.get(&EPropertyType::HpMax.into()).unwrap_or(&0)); *properties.get(&EPropertyType::HpMax.into()).unwrap_or(&0),
properties.insert(EPropertyType::AtkBattle.into(), *properties.get(&EPropertyType::Atk.into()).unwrap_or(&0)); );
properties.insert(EPropertyType::BreakStunBattle.into(), *properties.get(&EPropertyType::BreakStun.into()).unwrap_or(&0)); properties.insert(
properties.insert(EPropertyType::DefBattle.into(), *properties.get(&EPropertyType::Def.into()).unwrap_or(&0)); EPropertyType::AtkBattle.into(),
properties.insert(EPropertyType::CritBattle.into(), *properties.get(&EPropertyType::Crit.into()).unwrap_or(&0)); *properties.get(&EPropertyType::Atk.into()).unwrap_or(&0),
properties.insert(EPropertyType::CritDmgBattle.into(), *properties.get(&EPropertyType::CritDmg.into()).unwrap_or(&0)); );
properties.insert(EPropertyType::PenRatioBattle.into(), *properties.get(&EPropertyType::Pen.into()).unwrap_or(&0)); properties.insert(
properties.insert(EPropertyType::PenDeltaBattle.into(), *properties.get(&EPropertyType::PenValue.into()).unwrap_or(&0)); EPropertyType::BreakStunBattle.into(),
properties.insert(EPropertyType::SpRecoverBattle.into(), *properties.get(&EPropertyType::SpRecover.into()).unwrap_or(&0)); *properties
properties.insert(EPropertyType::ElementMysteryBattle.into(), *properties.get(&EPropertyType::ElementMystery.into()).unwrap_or(&0)); .get(&EPropertyType::BreakStun.into())
properties.insert(EPropertyType::ElementAbnormalPowerBattle.into(), *properties.get(&EPropertyType::ElementAbnormalPower.into()).unwrap_or(&0)); .unwrap_or(&0),
properties.insert(EPropertyType::AddedDamageRatioPhysicsBattle.into(), *properties.get(&EPropertyType::AddedDamageRatioPhysics.into()).unwrap_or(&0)); );
properties.insert(EPropertyType::AddedDamageRatioFireBattle.into(), *properties.get(&EPropertyType::AddedDamageRatioFire.into()).unwrap_or(&0)); properties.insert(
properties.insert(EPropertyType::AddedDamageRatioIceBattle.into(), *properties.get(&EPropertyType::AddedDamageRatioIce.into()).unwrap_or(&0)); EPropertyType::DefBattle.into(),
properties.insert(EPropertyType::AddedDamageRatioElecBattle.into(), *properties.get(&EPropertyType::AddedDamageRatioElec.into()).unwrap_or(&0)); *properties.get(&EPropertyType::Def.into()).unwrap_or(&0),
properties.insert(EPropertyType::AddedDamageRatioEtherBattle.into(), *properties.get(&EPropertyType::AddedDamageRatioEther.into()).unwrap_or(&0)); );
properties.insert(
} EPropertyType::CritBattle.into(),
*properties.get(&EPropertyType::Crit.into()).unwrap_or(&0),
);
properties.insert(
EPropertyType::CritDmgBattle.into(),
*properties.get(&EPropertyType::CritDmg.into()).unwrap_or(&0),
);
properties.insert(
EPropertyType::PenRatioBattle.into(),
*properties.get(&EPropertyType::Pen.into()).unwrap_or(&0),
);
properties.insert(
EPropertyType::PenDeltaBattle.into(),
*properties
.get(&EPropertyType::PenValue.into())
.unwrap_or(&0),
);
properties.insert(
EPropertyType::SpRecoverBattle.into(),
*properties
.get(&EPropertyType::SpRecover.into())
.unwrap_or(&0),
);
properties.insert(
EPropertyType::ElementMysteryBattle.into(),
*properties
.get(&EPropertyType::ElementMystery.into())
.unwrap_or(&0),
);
properties.insert(
EPropertyType::ElementAbnormalPowerBattle.into(),
*properties
.get(&EPropertyType::ElementAbnormalPower.into())
.unwrap_or(&0),
);
properties.insert(
EPropertyType::AddedDamageRatioPhysicsBattle.into(),
*properties
.get(&EPropertyType::AddedDamageRatioPhysics.into())
.unwrap_or(&0),
);
properties.insert(
EPropertyType::AddedDamageRatioFireBattle.into(),
*properties
.get(&EPropertyType::AddedDamageRatioFire.into())
.unwrap_or(&0),
);
properties.insert(
EPropertyType::AddedDamageRatioIceBattle.into(),
*properties
.get(&EPropertyType::AddedDamageRatioIce.into())
.unwrap_or(&0),
);
properties.insert(
EPropertyType::AddedDamageRatioElecBattle.into(),
*properties
.get(&EPropertyType::AddedDamageRatioElec.into())
.unwrap_or(&0),
);
properties.insert(
EPropertyType::AddedDamageRatioEtherBattle.into(),
*properties
.get(&EPropertyType::AddedDamageRatioEther.into())
.unwrap_or(&0),
);
}

View file

@ -10,7 +10,7 @@ use trigger_sv::{
net::ServerType, net::ServerType,
}; };
use crate::{logic::GameState, session::BattleSession, AppState}; use crate::{AppState, logic::GameState, session::BattleSession};
pub async fn handle_message(state: &'static AppState, packet: trigger_sv::message::NetworkPacket) { pub async fn handle_message(state: &'static AppState, packet: trigger_sv::message::NetworkPacket) {
match packet.opcode { match packet.opcode {

View file

@ -1,5 +1,5 @@
use trigger_encoding::Decodeable; use trigger_encoding::Decodeable;
use trigger_protocol::{util::ProtocolUnit, ClientCmdID, EndBattleCsReq}; use trigger_protocol::{ClientCmdID, EndBattleCsReq, util::ProtocolUnit};
use trigger_sv::message::GameStateCallback; use trigger_sv::message::GameStateCallback;
use super::BattleSession; use super::BattleSession;

View file

@ -4,7 +4,7 @@ use std::{
sync::{LazyLock, OnceLock}, sync::{LazyLock, OnceLock},
}; };
use axum::{routing::get, Router}; use axum::{Router, routing::get};
use config::{DispatchConfig, ResVersionConfig}; use config::{DispatchConfig, ResVersionConfig};
use tokio::net::TcpListener; use tokio::net::TcpListener;
use tracing::error; use tracing::error;

View file

@ -1,8 +1,8 @@
use axum::{extract::State, Json}; use axum::{Json, extract::State};
use crate::{ use crate::{
data::{QueryDispatchRsp, ServerListInfo},
AppState, AppState,
data::{QueryDispatchRsp, ServerListInfo},
}; };
pub const ROUTE_ENDPOINT: &str = "/query_dispatch"; pub const ROUTE_ENDPOINT: &str = "/query_dispatch";

View file

@ -1,20 +1,20 @@
use axum::{ use axum::{
Json,
extract::{Query, State}, extract::{Query, State},
response::IntoResponse, response::IntoResponse,
Json,
}; };
use base64::{display::Base64Display, engine::general_purpose::STANDARD, Engine}; use base64::{Engine, display::Base64Display, engine::general_purpose::STANDARD};
use serde::{Deserialize, Serialize, Serializer}; use serde::{Deserialize, Serialize, Serializer};
use tracing::debug; use tracing::debug;
use trigger_cryptography::rsa; use trigger_cryptography::rsa;
use trigger_sv::config::RsaSetting; use trigger_sv::config::RsaSetting;
use crate::{ use crate::{
AppState,
data::{ data::{
CdnConfExt, CdnDesignData, CdnGameRes, CdnSilenceData, RegionExtension, RegionSwitchFunc, CdnConfExt, CdnDesignData, CdnGameRes, CdnSilenceData, RegionExtension, RegionSwitchFunc,
ServerDispatchData, ServerGateway, ServerDispatchData, ServerGateway,
}, },
AppState,
}; };
pub const ROUTE_ENDPOINT: &str = "/query_gateway"; pub const ROUTE_ENDPOINT: &str = "/query_gateway";

View file

@ -1,11 +1,11 @@
use tracing::{debug, warn}; use tracing::{debug, warn};
use trigger_logic::quest::EQuestType; use trigger_logic::quest::EQuestType;
use trigger_protocol::{util::ProtocolUnit, AvatarSync, CafeSync, ItemSync, PlayerSyncScNotify}; use trigger_protocol::{AvatarSync, CafeSync, ItemSync, PlayerSyncScNotify, util::ProtocolUnit};
use trigger_sv::gm_command::GMCommand; use trigger_sv::gm_command::GMCommand;
use crate::AppState; use crate::AppState;
use super::{player::AvatarPropertyChanges, NapPlayer}; use super::{NapPlayer, player::AvatarPropertyChanges};
pub struct CommandContext<'player> { pub struct CommandContext<'player> {
pub player: &'player mut NapPlayer, pub player: &'player mut NapPlayer,

View file

@ -6,7 +6,7 @@ use quest::QuestModel;
use ramen::RamenModel; use ramen::RamenModel;
use role::RoleModel; use role::RoleModel;
use scene::SceneModel; use scene::SceneModel;
use trigger_database::{entity::*, prelude::*, DatabaseConnection}; use trigger_database::{DatabaseConnection, entity::*, prelude::*};
use trigger_fileconfig::NapFileCfg; use trigger_fileconfig::NapFileCfg;
use trigger_logic::{scene::ESceneType, template_ext::TemplateExt}; use trigger_logic::{scene::ESceneType, template_ext::TemplateExt};
use trigger_protocol::PlayerInfo; use trigger_protocol::PlayerInfo;

View file

@ -1,6 +1,6 @@
use trigger_database::DatabaseConnection;
use trigger_database::entity::*; use trigger_database::entity::*;
use trigger_database::prelude::*; use trigger_database::prelude::*;
use trigger_database::DatabaseConnection;
pub async fn load_player_basic_info( pub async fn load_player_basic_info(
db: &DatabaseConnection, db: &DatabaseConnection,

View file

@ -12,7 +12,7 @@ use tracing::{error, info};
use trigger_database::DatabaseConnection; use trigger_database::DatabaseConnection;
use trigger_fileconfig::NapFileCfg; use trigger_fileconfig::NapFileCfg;
use trigger_sv::{ use trigger_sv::{
config::{load_json_config, ServerEnvironmentConfiguration, TomlConfig}, config::{ServerEnvironmentConfiguration, TomlConfig, load_json_config},
die, logging, die, logging,
net::{ServerNetworkManager, ServerType}, net::{ServerNetworkManager, ServerType},
print_banner, print_banner,

View file

@ -1,9 +1,9 @@
use std::sync::Arc; use std::sync::Arc;
use crate::{ use crate::{
logic::{gm_util, NapPlayer},
session::GameSession,
AppState, AppState,
logic::{NapPlayer, gm_util},
session::GameSession,
}; };
use tokio::sync::Mutex; use tokio::sync::Mutex;
use tracing::{debug, info, warn}; use tracing::{debug, info, warn};

View file

@ -1,5 +1,5 @@
use trigger_encoding::Encodeable; use trigger_encoding::Encodeable;
use trigger_protocol::{util::ProtocolUnit, ClientCmdID}; use trigger_protocol::{ClientCmdID, util::ProtocolUnit};
use super::GameSession; use super::GameSession;
use crate::AppState; use crate::AppState;

View file

@ -15,7 +15,7 @@ use trigger_sv::{
net::{ServerNetworkManager, ServerType}, net::{ServerNetworkManager, ServerType},
}; };
use crate::logic::{scene::ServerlessStateData, scene_util, NapPlayer}; use crate::logic::{NapPlayer, scene::ServerlessStateData, scene_util};
pub mod message; pub mod message;

View file

@ -12,10 +12,10 @@ use trigger_sv::{
}; };
use crate::{ use crate::{
AppState,
net::{Connection, NetPacket}, net::{Connection, NetPacket},
session::SessionState, session::SessionState,
util::BinExt, util::BinExt,
AppState,
}; };
pub async fn handle_message(connection: &Connection, state: &'static AppState, packet: NetPacket) { pub async fn handle_message(connection: &Connection, state: &'static AppState, packet: NetPacket) {
@ -41,20 +41,33 @@ pub async fn handle_message(connection: &Connection, state: &'static AppState, p
on_keep_alive( on_keep_alive(
connection, connection,
state, state,
KeepAliveNotify::decode(&*packet.body).unwrap_or_default() KeepAliveNotify::decode(&*packet.body).unwrap_or_default(),
).await )
.await
} }
cmd_id if connection.session.is_logged_in() => { cmd_id if connection.session.is_logged_in() => {
match trigger_protobuf::pb_to_common_protocol_unit(cmd_id, &packet.body) { match trigger_protobuf::pb_to_common_protocol_unit(cmd_id, &packet.body) {
Ok(Some(unit)) => state.network_mgr.send_to(ServerType::GameServer, 0, ForwardClientProtocolMessage { Ok(Some(unit)) => {
session_id: connection.session.id, state
request_id: head.packet_id, .network_mgr
message: unit, .send_to(
}).await, ServerType::GameServer,
0,
ForwardClientProtocolMessage {
session_id: connection.session.id,
request_id: head.packet_id,
message: unit,
},
)
.await
}
Ok(None) => warn!("ignoring message with unknown cmd_id: {cmd_id}"), Ok(None) => warn!("ignoring message with unknown cmd_id: {cmd_id}"),
Err(err) => error!( Err(err) => error!(
"failed to decode a message with cmd_id: {} from {} (player_uid: {}), error: {}", "failed to decode a message with cmd_id: {} from {} (player_uid: {}), error: {}",
cmd_id, connection.addr(), connection.session.player_uid(), err cmd_id,
connection.addr(),
connection.session.player_uid(),
err
), ),
} }
} }

View file

@ -1,7 +1,7 @@
use tokio::sync::mpsc; use tokio::sync::mpsc;
use tracing::warn; use tracing::warn;
use crate::{net::NetPacket, AppState}; use crate::{AppState, net::NetPacket};
#[derive(Clone)] #[derive(Clone)]
pub struct MessageHandler(mpsc::UnboundedSender<(u64, NetPacket)>); pub struct MessageHandler(mpsc::UnboundedSender<(u64, NetPacket)>);

View file

@ -2,8 +2,8 @@ use std::{
io, io,
net::SocketAddr, net::SocketAddr,
sync::{ sync::{
atomic::{AtomicU32, Ordering::SeqCst},
Arc, OnceLock, Arc, OnceLock,
atomic::{AtomicU32, Ordering::SeqCst},
}, },
time::Duration, time::Duration,
}; };

View file

@ -1,6 +1,6 @@
use std::io::{Cursor, Write}; use std::io::{Cursor, Write};
use byteorder::{WriteBytesExt, BE}; use byteorder::{BE, WriteBytesExt};
use trigger_protobuf::PacketHead; use trigger_protobuf::PacketHead;
pub struct NetPacket { pub struct NetPacket {

View file

@ -3,7 +3,7 @@ use std::{io, net::SocketAddr};
use tokio::net::TcpListener; use tokio::net::TcpListener;
use tracing::info; use tracing::info;
use crate::{message_handler::MessageHandler, AppState}; use crate::{AppState, message_handler::MessageHandler};
pub async fn serve( pub async fn serve(
addr: SocketAddr, addr: SocketAddr,

View file

@ -1,6 +1,6 @@
use std::sync::{ use std::sync::{
atomic::{AtomicI64, Ordering::SeqCst},
OnceLock, OnceLock,
atomic::{AtomicI64, Ordering::SeqCst},
}; };
use atomic_enum::atomic_enum; use atomic_enum::atomic_enum;

View file

@ -107,6 +107,6 @@ use trigger_protocol::{
}; };
use trigger_sv::message::GameStateCallback; use trigger_sv::message::GameStateCallback;
use crate::logic::{message::RunEventGraphEvent, GameStateListener}; use crate::logic::{GameStateListener, message::RunEventGraphEvent};
use super::scene_unit::{InteractContainer, SceneUnitTag}; use super::scene_unit::{InteractContainer, SceneUnitTag};

View file

@ -1,6 +1,6 @@
use bevy_ecs::{prelude::*, query::QueryData}; use bevy_ecs::{prelude::*, query::QueryData};
use tracing::warn; use tracing::warn;
use trigger_fileconfig::{main_city_script::MainCityConfig, NapFileCfg}; use trigger_fileconfig::{NapFileCfg, main_city_script::MainCityConfig};
use crate::logic::save::HallSceneSaveData; use crate::logic::save::HallSceneSaveData;

View file

@ -3,13 +3,13 @@ use tracing::{debug, warn};
use trigger_protocol::InteractWithUnitScRsp; use trigger_protocol::InteractWithUnitScRsp;
use trigger_sv::message::GameStateCallback; use trigger_sv::message::GameStateCallback;
use crate::logic::{message::InteractWithUnitEvent, GameStateListener}; use crate::logic::{GameStateListener, message::InteractWithUnitEvent};
use super::{ use super::{
NapResources,
event_graph::{ActionChangeInteractCfgEvent, EventGraph, GraphEvent}, event_graph::{ActionChangeInteractCfgEvent, EventGraph, GraphEvent},
hall::MainCitySection, hall::MainCitySection,
scene_unit::{InteractContainer, SceneUnitTag}, scene_unit::{InteractContainer, SceneUnitTag},
NapResources,
}; };
pub fn tick_change_interact( pub fn tick_change_interact(

View file

@ -8,11 +8,11 @@ use scene::PlayerEnterScene;
use trigger_fileconfig::main_city_script::MainCityConfig; use trigger_fileconfig::main_city_script::MainCityConfig;
use super::{ use super::{
GameStateListener,
message::{ message::{
EnterSectionEvent, InteractWithUnitEvent, PlayerMoveEvent, RunEventGraphEvent, EnterSectionEvent, InteractWithUnitEvent, PlayerMoveEvent, RunEventGraphEvent,
SwitchRoleEvent, SwitchRoleEvent,
}, },
GameStateListener,
}; };
pub mod event_graph; pub mod event_graph;

View file

@ -1,8 +1,8 @@
use bevy_ecs::prelude::*; use bevy_ecs::prelude::*;
use crate::logic::{ use crate::logic::{
save::{HallSceneSaveData, MainCityPositionSave},
GameStateListener, GameStateListener,
save::{HallSceneSaveData, MainCityPositionSave},
}; };
use super::{ use super::{

View file

@ -1,6 +1,6 @@
use bevy_ecs::system::Resource; use bevy_ecs::system::Resource;
use trigger_encoding::Encodeable; use trigger_encoding::Encodeable;
use trigger_protocol::{util::ProtocolUnit, ClientCmdID}; use trigger_protocol::{ClientCmdID, util::ProtocolUnit};
use trigger_sv::{ use trigger_sv::{
message::{GameStateCallback, GameStateCallbackMessage}, message::{GameStateCallback, GameStateCallbackMessage},
net::{ServerNetworkManager, ServerType}, net::{ServerNetworkManager, ServerType},

View file

@ -2,8 +2,8 @@ use bevy_ecs::event::Event;
use trigger_encoding::Decodeable; use trigger_encoding::Decodeable;
use trigger_logic::scene::Transform; use trigger_logic::scene::Transform;
use trigger_protocol::{ use trigger_protocol::{
util::ProtocolUnit, ClientCmdID, EnterSectionCsReq, InteractWithUnitCsReq, RunEventGraphCsReq, ClientCmdID, EnterSectionCsReq, InteractWithUnitCsReq, RunEventGraphCsReq,
SavePosInMainCityCsReq, SwitchRoleCsReq, SavePosInMainCityCsReq, SwitchRoleCsReq, util::ProtocolUnit,
}; };
use super::ecs::NapEcs; use super::ecs::NapEcs;

View file

@ -1,6 +1,6 @@
use std::{collections::HashMap, sync::mpsc, thread}; use std::{collections::HashMap, sync::mpsc, thread};
use ecs::{scene::PlayerEnterScene, NapEcs}; use ecs::{NapEcs, scene::PlayerEnterScene};
use message::ProtocolEventHandler; use message::ProtocolEventHandler;
use tracing::debug; use tracing::debug;
use trigger_protocol::util::ProtocolUnit; use trigger_protocol::util::ProtocolUnit;
@ -11,8 +11,8 @@ mod listener;
mod message; mod message;
pub mod save; pub mod save;
pub use ecs::hall::HallInitData;
pub use ecs::NapResources; pub use ecs::NapResources;
pub use ecs::hall::HallInitData;
pub use listener::GameStateListener; pub use listener::GameStateListener;
#[derive(Clone)] #[derive(Clone)]

View file

@ -8,9 +8,9 @@ use dashmap::DashMap;
use logic::{GameRunner, NapResources}; use logic::{GameRunner, NapResources};
use session::HallSession; use session::HallSession;
use tracing::{error, info}; use tracing::{error, info};
use trigger_fileconfig::{main_city_script::MainCityConfig, NapFileCfg}; use trigger_fileconfig::{NapFileCfg, main_city_script::MainCityConfig};
use trigger_sv::{ use trigger_sv::{
config::{load_json_config, ServerEnvironmentConfiguration, TomlConfig}, config::{ServerEnvironmentConfiguration, TomlConfig, load_json_config},
die, logging, die, logging,
net::{ServerNetworkManager, ServerType}, net::{ServerNetworkManager, ServerType},
print_banner, print_banner,

View file

@ -5,9 +5,9 @@ use trigger_sv::message::{
}; };
use crate::{ use crate::{
AppState,
logic::{GameStateListener, HallInitData}, logic::{GameStateListener, HallInitData},
session::HallSession, session::HallSession,
AppState,
}; };
pub async fn handle_message(state: &'static AppState, packet: trigger_sv::message::NetworkPacket) { pub async fn handle_message(state: &'static AppState, packet: trigger_sv::message::NetworkPacket) {

View file

@ -1,9 +1,9 @@
use std::borrow::Cow; use std::borrow::Cow;
use axum::{ use axum::{
Json, Router,
extract::{Query, State}, extract::{Query, State},
routing::get, routing::get,
Json, Router,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::net::TcpListener; use tokio::net::TcpListener;
@ -64,7 +64,7 @@ async fn gm_api(
return Json(Response { return Json(Response {
retcode: 2, retcode: 2,
message: Some(Cow::Owned(format!("invalid command format: {err}"))), message: Some(Cow::Owned(format!("invalid command format: {err}"))),
}) });
} }
}; };

View file

@ -1,8 +1,8 @@
use proc_macro2::TokenStream; use proc_macro2::TokenStream;
use quote::quote; use quote::quote;
use syn::{ use syn::{
parse_macro_input, Data, DeriveInput, Field, Fields, GenericArgument, PathArguments, Type, Data, DeriveInput, Field, Fields, GenericArgument, PathArguments, Type, TypePath,
TypePath, parse_macro_input,
}; };
pub fn impl_gm_input(input: proc_macro::TokenStream) -> proc_macro::TokenStream { pub fn impl_gm_input(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
@ -114,7 +114,7 @@ pub fn impl_gm_input(input: proc_macro::TokenStream) -> proc_macro::TokenStream
fn from_str(input: &str) -> Result<Self, GMInputParseError> { fn from_str(input: &str) -> Result<Self, GMInputParseError> {
use GMInputParseError::*; use GMInputParseError::*;
static CMD_TYPE_MAP: ::std::sync::LazyLock<::std::collections::HashMap<&'static str, #internal_enum_name>> = static CMD_TYPE_MAP: ::std::sync::LazyLock<::std::collections::HashMap<&'static str, #internal_enum_name>> =
::std::sync::LazyLock::new(|| ::std::collections::HashMap::from([#internal_enum_mapping])); ::std::sync::LazyLock::new(|| ::std::collections::HashMap::from([#internal_enum_mapping]));
let mut data = input.split(' '); let mut data = input.split(' ');
@ -165,4 +165,3 @@ fn get_field_sub_type(field: &Field) -> String {
_ => panic!("Unsupported field type"), _ => panic!("Unsupported field type"),
} }
} }

View file

@ -1,6 +1,6 @@
use proc_macro2::TokenStream; use proc_macro2::TokenStream;
use quote::quote; use quote::quote;
use syn::{parse_macro_input, Data, DeriveInput, Fields, Ident}; use syn::{Data, DeriveInput, Fields, Ident, parse_macro_input};
pub fn impl_decodeable(item: proc_macro::TokenStream) -> proc_macro::TokenStream { pub fn impl_decodeable(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = parse_macro_input!(item as DeriveInput); let input = parse_macro_input!(item as DeriveInput);

View file

@ -1,6 +1,6 @@
use proc_macro2::TokenStream; use proc_macro2::TokenStream;
use quote::quote; use quote::quote;
use syn::{parse_macro_input, Data, DeriveInput, Fields, Ident}; use syn::{Data, DeriveInput, Fields, Ident, parse_macro_input};
pub fn impl_encodeable(item: proc_macro::TokenStream) -> proc_macro::TokenStream { pub fn impl_encodeable(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = parse_macro_input!(item as DeriveInput); let input = parse_macro_input!(item as DeriveInput);

View file

@ -1,6 +1,6 @@
use proc_macro2::TokenStream; use proc_macro2::TokenStream;
use quote::{quote, ToTokens}; use quote::{ToTokens, quote};
use syn::{parse_macro_input, FnArg, Item, ItemMod, ReturnType}; use syn::{FnArg, Item, ItemMod, ReturnType, parse_macro_input};
pub fn imp(input: proc_macro::TokenStream) -> proc_macro::TokenStream { pub fn imp(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
const INVALID_FUNCTION_SIGNATURE_MSG: &str = "functions in message handler module should have following signature: fn(&mut MessageContext<'_>, CsReq) -> ScRsp"; const INVALID_FUNCTION_SIGNATURE_MSG: &str = "functions in message handler module should have following signature: fn(&mut MessageContext<'_>, CsReq) -> ScRsp";

View file

@ -1,6 +1,6 @@
use proc_macro::TokenStream; use proc_macro::TokenStream;
use quote::{quote, ToTokens}; use quote::{ToTokens, quote};
use syn::{parse_macro_input, DeriveInput, Meta, MetaList}; use syn::{DeriveInput, Meta, MetaList, parse_macro_input};
mod commands; mod commands;
mod decodeable; mod decodeable;

View file

@ -1,7 +1,7 @@
#![allow(unused)] #![allow(unused)]
use super::tables::{ use super::tables::{
LOOKUP_G11, LOOKUP_G13, LOOKUP_G14, LOOKUP_G2, LOOKUP_G3, LOOKUP_G9, LOOKUP_RCON, LOOKUP_SBOX, LOOKUP_G2, LOOKUP_G3, LOOKUP_G9, LOOKUP_G11, LOOKUP_G13, LOOKUP_G14, LOOKUP_RCON, LOOKUP_SBOX,
LOOKUP_SBOX_INV, SHIFT_ROWS_TABLE, SHIFT_ROWS_TABLE_INV, LOOKUP_SBOX_INV, SHIFT_ROWS_TABLE, SHIFT_ROWS_TABLE_INV,
}; };

View file

@ -1,6 +1,6 @@
use rsa::{ use rsa::{
pkcs1v15::SigningKey, sha2::Sha256, signature::RandomizedSigner, Pkcs1v15Encrypt, Pkcs1v15Encrypt, RsaPrivateKey, RsaPublicKey, pkcs1v15::SigningKey, sha2::Sha256,
RsaPrivateKey, RsaPublicKey, signature::RandomizedSigner,
}; };
const RSA_CHUNK_SIZE: usize = 117; const RSA_CHUNK_SIZE: usize = 117;

View file

@ -10,10 +10,10 @@ pub use sea_orm::DbErr;
use tracing::error; use tracing::error;
pub mod prelude { pub mod prelude {
pub use sea_orm::entity::prelude::*;
pub use sea_orm::entity::ActiveValue::*;
pub use sea_orm::query::Condition;
pub use sea_orm::TransactionTrait; pub use sea_orm::TransactionTrait;
pub use sea_orm::entity::ActiveValue::*;
pub use sea_orm::entity::prelude::*;
pub use sea_orm::query::Condition;
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]

View file

@ -1,4 +1,4 @@
use byteorder::{ReadBytesExt, WriteBytesExt, BE}; use byteorder::{BE, ReadBytesExt, WriteBytesExt};
use std::collections::HashMap; use std::collections::HashMap;
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};

View file

@ -7,5 +7,6 @@ fn main() {
inputs: &[Path::new("fbs/tables.fbs")], inputs: &[Path::new("fbs/tables.fbs")],
out_dir: Path::new("gen_flatbuffers"), out_dir: Path::new("gen_flatbuffers"),
..Default::default() ..Default::default()
}).expect("Couldn't compile tables.fbs"); })
.expect("Couldn't compile tables.fbs");
} }

File diff suppressed because it is too large Load diff

View file

@ -87,4 +87,4 @@ pub enum EPropertyType {
HpMaxAdvance = 9999_111_1, HpMaxAdvance = 9999_111_1,
AtkAdvance = 9999_121_1, AtkAdvance = 9999_121_1,
DefAdvance = 9999_131_1, DefAdvance = 9999_131_1,
} }

View file

@ -4,4 +4,4 @@ pub mod item;
pub mod quest; pub mod quest;
pub mod scene; pub mod scene;
pub mod skill; pub mod skill;
pub mod template_ext; pub mod template_ext;

View file

@ -5,7 +5,7 @@ use std::{
path::Path, path::Path,
}; };
use quote::{quote, ToTokens}; use quote::{ToTokens, quote};
use syn::{Field, GenericArgument, Item, PathArguments, Type, TypePath}; use syn::{Field, GenericArgument, Item, PathArguments, Type, TypePath};
fn main() { fn main() {

View file

@ -1,4 +1,4 @@
use serde::{de::DeserializeOwned, Deserialize, Deserializer}; use serde::{Deserialize, Deserializer, de::DeserializeOwned};
use std::net::SocketAddr; use std::net::SocketAddr;
use tracing::error; use tracing::error;
use trigger_database::DatabaseSetting; use trigger_database::DatabaseSetting;

View file

@ -1,6 +1,6 @@
use crate::message::opcode; use crate::message::opcode;
use trigger_codegen::{Decodeable, Encodeable}; use trigger_codegen::{Decodeable, Encodeable};
use trigger_protocol::{util::ProtocolUnit, DungeonEquipInfo}; use trigger_protocol::{DungeonEquipInfo, util::ProtocolUnit};
#[derive(Debug, Encodeable, Decodeable)] #[derive(Debug, Encodeable, Decodeable)]
pub struct BindClientSessionMessage { pub struct BindClientSessionMessage {

View file

@ -4,7 +4,7 @@ use futures::future::BoxFuture;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use tracing::warn; use tracing::warn;
use trigger_encoding::Decodeable; use trigger_encoding::Decodeable;
use zeromq::{prelude::*, PullSocket, ZmqError}; use zeromq::{PullSocket, ZmqError, prelude::*};
use crate::message::NetworkPacket; use crate::message::NetworkPacket;

View file

@ -3,7 +3,7 @@ mod socket;
use std::{collections::HashMap, io::Cursor, net::SocketAddr}; use std::{collections::HashMap, io::Cursor, net::SocketAddr};
pub use listener::{listen, RecvCallback}; pub use listener::{RecvCallback, listen};
use num_enum::{IntoPrimitive, TryFromPrimitive}; use num_enum::{IntoPrimitive, TryFromPrimitive};
pub use socket::ServerSocket; pub use socket::ServerSocket;

View file

@ -5,8 +5,8 @@ use std::time::Duration;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use tracing::warn; use tracing::warn;
use trigger_encoding::Encodeable; use trigger_encoding::Encodeable;
use zeromq::prelude::*;
use zeromq::PushSocket; use zeromq::PushSocket;
use zeromq::prelude::*;
use crate::message::NetworkPacket; use crate::message::NetworkPacket;