Skip to main content

Zombie

Type Alias Zombie 

Source
pub type Zombie = Player;
Expand description

Represents a zombie player.

Aliased Type§

pub struct Zombie {
Show 24 fields pub id: String, pub name: String, pub surname: String, pub bio: String, pub pronouns: String, pub alias: String, pub niu: String, pub email: String, pub phone: String, pub faculty: String, pub isuab: bool, pub how_did_you_hear_about_us: String, pub social_media: Option<String>, pub password: String, pub player_number: i32, pub state: PlayerState, pub role: PlayerRole, pub birth_date: NaiveDate, pub accept_info_other_editions: bool, pub next_feeding: Option<CustomDateTime>, pub last_login: Option<NaiveDateTime>, pub checkpoint: Option<NaiveDateTime>, pub wants_to_be_zombie: i32, pub register_date: Option<NaiveDateTime>,
}

Fields§

§id: String§name: String§surname: String§bio: String§pronouns: String§alias: String§niu: String§email: String§phone: String§faculty: String§isuab: bool§how_did_you_hear_about_us: String§social_media: Option<String>§password: String§player_number: i32§state: PlayerState§role: PlayerRole§birth_date: NaiveDate§accept_info_other_editions: bool§next_feeding: Option<CustomDateTime>§last_login: Option<NaiveDateTime>§checkpoint: Option<NaiveDateTime>§wants_to_be_zombie: i32§register_date: Option<NaiveDateTime>

Implementations§

Source§

impl Zombie

Source

pub async fn get_next_feeding(&self) -> Result<Option<CustomDateTime>, String>

Calculates the next feeding time for a zombie player.

Returns None if the player is not a zombie.

§Errors

Returns an error if the player is not a zombie.

Source

pub async fn starvation( &self, ) -> Result<Vec<(String, Option<CustomDateTime>)>, String>

Gets the starvation status of all the zombies.

§Returns

A vector of tuples containing the player’s alias and their next feeding time.

§Errors

Returns an error if the player is not a zombie.

Source

pub async fn hunt( &self, target: &Player, feed1: Option<&Player>, feed2: Option<&Player>, ) -> Result<(), String>

Hunt a player and feed two other players.

§Arguments
  • target - The player to hunt.
  • feed1 - The first player to feed.
  • feed2 - The second player to feed.
§Errors

Returns an error if the player is not a zombie.

Source

pub async fn zombify(&self) -> Result<(), String>

Zombify a player

§Arguments
  • self - The player to zombify.
§Errors

Returns an error if the player is not a zombie.

Source

pub async fn feed( &self, amount: Option<i64>, ) -> Result<Option<CustomDateTime>, String>

Feed a player.

§Arguments
  • amount - The amount of time to feed the player in hours.
§Errors

Returns an error if the player is not a zombie.

Source

pub fn feeding_time_calc() -> Result<CustomDateTime, String>

Calculates the next feeding time for a zombie.

§Returns

The next feeding time as a NaiveDateTime.

Source

pub async fn monitor_zombie_death() -> !

Monitors the zombie death and updates the player state accordingly.

Every minute, it checks if the player’s next feeding time has passed. If so, it updates the player’s state to Corpse and sets the next feeding time to None.

§Errors

Returns an error if the player is not a zombie.