This commit is contained in:
shenjack 2024-05-04 20:28:27 +08:00
parent 1d2dc42b0a
commit 0a22586273
Signed by: shenjack
GPG Key ID: 7B1134A979775551
4 changed files with 45 additions and 17 deletions

View File

@ -1,8 +1,8 @@
pub const PROFILE_START: u32 = 33554431; pub const PROFILE_START: u32 = 33554431;
pub mod runners { pub mod runners {
use crate::name::Player; use crate::name::Player;
use crate::rc4::RC4;
pub struct PlayerGroup { pub struct PlayerGroup {
players: Vec<Player>, players: Vec<Player>,
@ -10,12 +10,12 @@ pub mod runners {
pub struct Runner { pub struct Runner {
/// 应该是一个 Rc4 实例类似物 /// 应该是一个 Rc4 实例类似物
seed: u32, randomer: RC4,
/// 所有玩家 (包括 boss) /// 所有玩家 (包括 boss)
players: Vec<PlayerGroup>, players: Vec<PlayerGroup>,
/// 赢家 /// 赢家
/// ///
/// 也应该是一个队伍 /// 也应该是一个队伍
winner: Option<PlayerGroup> winner: Option<PlayerGroup>,
} }
} }

View File

@ -1,7 +1,7 @@
/// 万里长征, 始于足下
mod player;
mod engine; mod engine;
mod name; mod name;
/// 万里长征, 始于足下
mod player;
mod rc4; mod rc4;
fn main() { fn main() {

View File

@ -1,28 +1,61 @@
pub mod skills; pub mod skills;
use std::fmt::Display;
use crate::rc4::RC4; use crate::rc4::RC4;
pub struct PlayerStatus { pub struct PlayerStatus {
/// 是否被冻结
frozen: bool, frozen: bool,
/// 是否存活
alive: bool,
/// 血量
hp: u32,
/// 分数
point: u32,
} }
impl Default for PlayerStatus { impl Default for PlayerStatus {
fn default() -> Self { fn default() -> Self {
PlayerStatus { frozen: false } PlayerStatus {
frozen: false,
alive: true,
hp: 0,
point: 0,
}
}
}
impl Display for PlayerStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"PlayerStatus{{{},{} hp: {}, point: {} }}",
// 冻结/正常
// 存活/死亡
if self.frozen { "冻结" } else { "正常" },
if self.alive { "存货" } else { "死亡" },
self.hp,
self.point
)
} }
} }
pub struct Player { pub struct Player {
/// 队伍
team: String, team: String,
/// 玩家名
name: String, name: String,
weapon: String, /// 武器
weapon: Option<String>,
/// 玩家类型
player_type: PlayerType, player_type: PlayerType,
/// skl id /// skl id
skil_id: Vec<u32>, skil_id: Vec<u32>,
/// skl prop /// skl prop
skil_prop: Vec<u32>, skil_prop: Vec<u32>,
/// 玩家状态 /// 玩家状态
/// ///
/// 主要是我懒得加一大堆字段 /// 主要是我懒得加一大堆字段
status: PlayerStatus, status: PlayerStatus,
} }
@ -65,7 +98,7 @@ pub enum PlayerType {
} }
impl Player { impl Player {
pub fn new(team: String, name: String, weapon: String) -> Self { pub fn new(team: String, name: String, weapon: Option<String>) -> Self {
let player_type = { let player_type = {
match team.as_str() { match team.as_str() {
"!" => { "!" => {
@ -100,7 +133,5 @@ impl Player {
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) {}
}
} }

View File

@ -1,4 +1 @@
pub enum Skills {}
pub enum Skills {
}