update!
This commit is contained in:
parent
0a22586273
commit
30ac84a915
@ -1,13 +1,33 @@
|
||||
pub const PROFILE_START: u32 = 33554431;
|
||||
|
||||
pub mod runners {
|
||||
use crate::name::Player;
|
||||
use crate::player::Player;
|
||||
use crate::rc4::RC4;
|
||||
|
||||
pub struct PlayerGroup {
|
||||
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 {
|
||||
/// 应该是一个 Rc4 实例类似物
|
||||
randomer: RC4,
|
||||
@ -18,4 +38,15 @@ pub mod runners {
|
||||
/// 也应该是一个队伍
|
||||
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");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
mod engine;
|
||||
mod name;
|
||||
/// 万里长征, 始于足下
|
||||
mod player;
|
||||
mod rc4;
|
||||
|
@ -1,5 +0,0 @@
|
||||
pub struct Player {
|
||||
team: String,
|
||||
name: String,
|
||||
weapon: String,
|
||||
}
|
@ -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 step(&mut self, randomer: &mut RC4) {}
|
||||
|
Loading…
Reference in New Issue
Block a user