forked from NewEriduPubSec/JaneDoe-ZS
62 lines
1.8 KiB
Rust
62 lines
1.8 KiB
Rust
use proto::{BasicDataModelBin, PlayerBasicInfo};
|
|
|
|
pub struct BasicDataModel {
|
|
pub level: u32,
|
|
pub exp: u32,
|
|
pub profile_icon: u32,
|
|
pub nick_name: Option<String>,
|
|
pub frontend_avatar_id: i32,
|
|
pub beginner_procedure_id: i32,
|
|
}
|
|
|
|
impl Default for BasicDataModel {
|
|
fn default() -> Self {
|
|
Self {
|
|
level: 1,
|
|
exp: 0,
|
|
profile_icon: 3200000,
|
|
nick_name: None,
|
|
frontend_avatar_id: 0,
|
|
beginner_procedure_id: 1,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl BasicDataModel {
|
|
pub fn player_basic_info(&self) -> PlayerBasicInfo {
|
|
PlayerBasicInfo {
|
|
nick_name: self.nick_name.clone().unwrap_or_default(),
|
|
exp: self.exp,
|
|
level: self.level,
|
|
avatar_id: self.frontend_avatar_id as u32,
|
|
frontend_avatar_id: self.frontend_avatar_id as u32,
|
|
kbjleelonfe: self.profile_icon,
|
|
..Default::default()
|
|
}
|
|
}
|
|
|
|
pub fn from_bin(bin: BasicDataModelBin) -> Self {
|
|
Self {
|
|
level: bin.level,
|
|
exp: bin.exp,
|
|
profile_icon: bin.profile_icon,
|
|
frontend_avatar_id: bin.frontend_avatar_id,
|
|
beginner_procedure_id: bin.beginner_procedure_id,
|
|
nick_name: match bin.nick_name.is_empty() {
|
|
true => None,
|
|
false => Some(bin.nick_name),
|
|
},
|
|
}
|
|
}
|
|
|
|
pub fn to_bin(&self) -> BasicDataModelBin {
|
|
BasicDataModelBin {
|
|
level: self.level,
|
|
exp: self.exp,
|
|
profile_icon: self.profile_icon,
|
|
frontend_avatar_id: self.frontend_avatar_id,
|
|
nick_name: self.nick_name.clone().unwrap_or_default(),
|
|
beginner_procedure_id: self.beginner_procedure_id,
|
|
}
|
|
}
|
|
}
|