diff options
| author | 1992414357@qq.com <1992414357@qq.com> | 2025-06-11 19:14:04 +0800 |
|---|---|---|
| committer | 1992414357@qq.com <1992414357@qq.com> | 2025-06-11 19:14:04 +0800 |
| commit | 9e48af01ae56fe813869ada24de291ab98b361e2 (patch) | |
| tree | 82b56adecbeb260ebbf2c512d78fe2d63805eb36 /core/src/data/player | |
| parent | aa326e69b18a4390ffbc97268eaec4793761f083 (diff) | |
组合模块中 structs.rs 和 implements.rs 文件
Diffstat (limited to 'core/src/data/player')
| -rw-r--r-- | core/src/data/player/mod.rs | 3 | ||||
| -rw-r--r-- | core/src/data/player/player_data.rs (renamed from core/src/data/player/implements.rs) | 45 | ||||
| -rw-r--r-- | core/src/data/player/structs.rs | 45 |
3 files changed, 45 insertions, 48 deletions
diff --git a/core/src/data/player/mod.rs b/core/src/data/player/mod.rs index 7e8fe28..ff6ae85 100644 --- a/core/src/data/player/mod.rs +++ b/core/src/data/player/mod.rs @@ -1,4 +1,3 @@ -pub mod implements; -pub mod structs; +pub mod player_data; pub const ACCOUNT_HASH_SALT : &str = env!("TEST_PLAYER_ACCOUNT");
\ No newline at end of file diff --git a/core/src/data/player/implements.rs b/core/src/data/player/player_data.rs index bbaefc4..1fe5ff0 100644 --- a/core/src/data/player/implements.rs +++ b/core/src/data/player/player_data.rs @@ -1,11 +1,54 @@ -use crate::data::player::structs::{Account, Customize, Player}; use crate::data::player::ACCOUNT_HASH_SALT; use hex::encode; use sha1::{Digest, Sha1}; use std::fmt::{Display, Formatter}; use std::hash::{Hash, Hasher}; +use bincode::{Decode, Encode}; +use serde::{Deserialize, Serialize}; use nogamepads::string_utils::process_id_text; +/// Player information +/// Describes a player's specific details, which are frequently exchanged between the controller and game pad_client. +#[derive(Default, Clone, Encode, Decode, Serialize, Deserialize, Debug)] +pub struct Player { + + /// Account information + pub account: Account, + + /// Custom information (Optional) + pub customize: Option<Customize> +} + +/// Account information +/// Essential data for verifying player uniqueness, including the player's hash value and account ID. +#[derive(Default, Clone, Encode, Decode, Serialize, Deserialize, Eq, Hash, PartialEq, Debug)] +pub struct Account { + + /// Player name stored in data, allowing only lowercase letters and underscores + pub id: String, + + /// Player hash value proving player uniqueness + pub player_hash: String +} + +/// Custom information +/// Describes personalized player details displayed in-game, such as name, color, or other customizations. +#[derive(Default, Clone, Encode, Decode, Serialize, Deserialize, PartialEq, Debug)] +pub struct Customize { + + /// Player name displayed in the game + pub nickname: String, + + /// HSV Color - Hue (Range: 0 - 360) + pub color_hue: i32, + + /// HSV Color - Saturation (Range: 0 - 1) + pub color_saturation: f64, + + /// HSV Color - Value (Range: 0 - 1) + pub color_value: f64 +} + impl Player { /// Create new player information using a username and password diff --git a/core/src/data/player/structs.rs b/core/src/data/player/structs.rs deleted file mode 100644 index cc3d7c9..0000000 --- a/core/src/data/player/structs.rs +++ /dev/null @@ -1,45 +0,0 @@ -use bincode::{Decode, Encode}; -use serde::{Deserialize, Serialize}; -use std::hash::{Hash}; - -/// Player information -/// Describes a player's specific details, which are frequently exchanged between the controller and game pad_client. -#[derive(Default, Clone, Encode, Decode, Serialize, Deserialize, Debug)] -pub struct Player { - - /// Account information - pub account: Account, - - /// Custom information (Optional) - pub customize: Option<Customize> -} - -/// Account information -/// Essential data for verifying player uniqueness, including the player's hash value and account ID. -#[derive(Default, Clone, Encode, Decode, Serialize, Deserialize, Eq, Hash, PartialEq, Debug)] -pub struct Account { - - /// Player name stored in data, allowing only lowercase letters and underscores - pub id: String, - - /// Player hash value proving player uniqueness - pub player_hash: String -} - -/// Custom information -/// Describes personalized player details displayed in-game, such as name, color, or other customizations. -#[derive(Default, Clone, Encode, Decode, Serialize, Deserialize, PartialEq, Debug)] -pub struct Customize { - - /// Player name displayed in the game - pub nickname: String, - - /// HSV Color - Hue (Range: 0 - 360) - pub color_hue: i32, - - /// HSV Color - Saturation (Range: 0 - 1) - pub color_saturation: f64, - - /// HSV Color - Value (Range: 0 - 1) - pub color_value: f64 -}
\ No newline at end of file |
