From 0a22586273bb633a3eb3b65b821ded83b9ecb4d4 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 4 May 2024 20:28:27 +0800 Subject: [PATCH] ruaaa --- namerena-runner/src/engine.rs | 8 ++--- namerena-runner/src/main.rs | 4 +-- namerena-runner/src/player.rs | 45 +++++++++++++++++++++++----- namerena-runner/src/player/skills.rs | 5 +--- 4 files changed, 45 insertions(+), 17 deletions(-) diff --git a/namerena-runner/src/engine.rs b/namerena-runner/src/engine.rs index dd562b3..2a72250 100644 --- a/namerena-runner/src/engine.rs +++ b/namerena-runner/src/engine.rs @@ -1,8 +1,8 @@ - pub const PROFILE_START: u32 = 33554431; pub mod runners { use crate::name::Player; + use crate::rc4::RC4; pub struct PlayerGroup { players: Vec, @@ -10,12 +10,12 @@ pub mod runners { pub struct Runner { /// 应该是一个 Rc4 实例类似物 - seed: u32, + randomer: RC4, /// 所有玩家 (包括 boss) players: Vec, /// 赢家 - /// + /// /// 也应该是一个队伍 - winner: Option + winner: Option, } } diff --git a/namerena-runner/src/main.rs b/namerena-runner/src/main.rs index d8b61cd..770f2f7 100644 --- a/namerena-runner/src/main.rs +++ b/namerena-runner/src/main.rs @@ -1,7 +1,7 @@ -/// 万里长征, 始于足下 -mod player; mod engine; mod name; +/// 万里长征, 始于足下 +mod player; mod rc4; fn main() { diff --git a/namerena-runner/src/player.rs b/namerena-runner/src/player.rs index 90cd06e..10494d6 100644 --- a/namerena-runner/src/player.rs +++ b/namerena-runner/src/player.rs @@ -1,28 +1,61 @@ pub mod skills; +use std::fmt::Display; + use crate::rc4::RC4; pub struct PlayerStatus { + /// 是否被冻结 frozen: bool, + /// 是否存活 + alive: bool, + /// 血量 + hp: u32, + /// 分数 + point: u32, } impl Default for PlayerStatus { 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 { + /// 队伍 team: String, + /// 玩家名 name: String, - weapon: String, + /// 武器 + weapon: Option, + /// 玩家类型 player_type: PlayerType, /// skl id skil_id: Vec, /// skl prop skil_prop: Vec, /// 玩家状态 - /// + /// /// 主要是我懒得加一大堆字段 status: PlayerStatus, } @@ -65,7 +98,7 @@ pub enum PlayerType { } impl Player { - pub fn new(team: String, name: String, weapon: String) -> Self { + pub fn new(team: String, name: String, weapon: Option) -> Self { let player_type = { match team.as_str() { "!" => { @@ -100,7 +133,5 @@ impl Player { pub fn update_player(&mut self) {} - pub fn step(&mut self, randomer: &mut RC4) { - - } + pub fn step(&mut self, randomer: &mut RC4) {} } diff --git a/namerena-runner/src/player/skills.rs b/namerena-runner/src/player/skills.rs index 7973316..81bae49 100644 --- a/namerena-runner/src/player/skills.rs +++ b/namerena-runner/src/player/skills.rs @@ -1,4 +1 @@ - -pub enum Skills { - -} +pub enum Skills {}