update!

This commit is contained in:
shenjack 2024-05-06 21:57:24 +08:00
parent 0a22586273
commit 30ac84a915
Signed by: shenjack
GPG Key ID: 7B1134A979775551
4 changed files with 60 additions and 7 deletions

View File

@ -1,13 +1,33 @@
pub const PROFILE_START: u32 = 33554431; pub const PROFILE_START: u32 = 33554431;
pub mod runners { pub mod runners {
use crate::name::Player; use crate::player::Player;
use crate::rc4::RC4; use crate::rc4::RC4;
pub struct PlayerGroup { pub struct PlayerGroup {
players: Vec<Player>, players: Vec<Player>,
} }
impl PlayerGroup {
/// 从一个 名竞的原始输入 中创建一个 PlayerGroup
///
/// # 要求
/// 会默认整个输入是同一个队伍的
/// 也就是会忽略所有 \n\n 的队伍分割
pub fn new_from_namerena_raw(raw_input: String) -> PlayerGroup {
// 首先以 \n 分割
let raw_input = raw_input.split("\n");
// 然后直接 map 生成 Player
let players: Vec<Player> = raw_input.map(|raw_name| {
Player::new_from_namerena_raw(raw_name.to_string())
}).collect();
PlayerGroup {
players,
}
}
}
pub struct Runner { pub struct Runner {
/// 应该是一个 Rc4 实例类似物 /// 应该是一个 Rc4 实例类似物
randomer: RC4, randomer: RC4,
@ -18,4 +38,15 @@ pub mod runners {
/// 也应该是一个队伍 /// 也应该是一个队伍
winner: Option<PlayerGroup>, winner: Option<PlayerGroup>,
} }
impl Runner {
/// 从一个 名竞的原始输入 中创建一个 Runner
///
/// 其实就是解析名竞的输入格式
pub fn new_from_namerena_raw(raw_input: String) {
// 首先以 \n\n 分割
let mut raw_input = raw_input.split("\n\n");
}
}
} }

View File

@ -1,5 +1,4 @@
mod engine; mod engine;
mod name;
/// 万里长征, 始于足下 /// 万里长征, 始于足下
mod player; mod player;
mod rc4; mod rc4;

View File

@ -1,5 +0,0 @@
pub struct Player {
team: String,
name: String,
weapon: String,
}

View File

@ -131,6 +131,34 @@ impl Player {
} }
} }
/// 直接从一个名竞的原始输入创建一个 Player
///
/// # 要求
/// 不许有 \n
///
/// 可能的输入格式:
/// - <name>
/// - <name>@<team>
/// - <name>+<weapon>
/// - <name>+<weapon>+diy{xxxxx}
/// - <name>@<team>+<weapon>
/// - <name>@<team>+<weapon>+diy{xxxxx}
pub fn new_from_namerena_raw(raw_name: String) -> Self {
// 先判断是否有 + 和 @
if !raw_name.contains("@") && !raw_name.contains("+") {
return Player::new(raw_name.clone(), raw_name.clone(), None);
}
// 区分队伍名
let name: &str;
let mut team: &str;
let weapon: Option<&str>;
if raw_name.contains("@") {
(name, team) = raw_name.split_once("@").unwrap();
}
todo!()
}
pub fn update_player(&mut self) {} pub fn update_player(&mut self) {}
pub fn step(&mut self, randomer: &mut RC4) {} pub fn step(&mut self, randomer: &mut RC4) {}