From 8533513adf64ef82a4feda04d179edc2c44c5988 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sun, 12 May 2024 16:28:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8D=E5=8F=AF=E8=A7=81?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- namerena-runner/src/player.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/namerena-runner/src/player.rs b/namerena-runner/src/player.rs index d012b52..0b99bec 100644 --- a/namerena-runner/src/player.rs +++ b/namerena-runner/src/player.rs @@ -68,6 +68,13 @@ pub const BOSS_NAMES: [&str; 11] = [ // ["田一人", 18, "云剑狄卡敢", 25, "云剑穸跄祇", 35] pub const BOOST_NAMES: [&str; 3] = ["云剑狄卡敢", "云剑穸跄祇", "田一人"]; +/// 匹配字符的 Unicode 码点 +/// +/// 其实就是过滤一下不可见字符 +pub fn filter_char(s: char) -> bool { + matches!(s as u32 , 9..13 | 32 | 133 | 160 | 5760 | 8192..8202 | 8232..8233 | 8239 | 8287 | 12288 | 65279) +} + #[derive(Default, PartialEq, Eq, Debug)] pub enum PlayerType { #[default] @@ -140,10 +147,10 @@ impl Player { } /// 直接从一个名竞的原始输入创建一个 Player - /// + /// /// # 要求 /// 不许有 \n - /// + /// /// 可能的输入格式: /// - /// - @ @@ -193,7 +200,9 @@ impl Player { impl Display for Player { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "Player{{{}@{}{}, status: {}}}", + write!( + f, + "Player{{{}@{}{}, status: {}}}", self.name, self.team, if let Some(weapon) = &self.weapon { @@ -282,6 +291,5 @@ mod test { // boosted let player = Player::new_from_namerena_raw("云剑狄卡敢@!".to_string()); assert_eq!(player.player_type, PlayerType::Boost); - } }