parent
406b52374c
commit
f93e0b2271
@ -0,0 +1,32 @@
|
|||||||
|
use valence::{
|
||||||
|
prelude::{Client, GameMode},
|
||||||
|
text::{Color, TextFormat},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::{game_state::GameState, CurrentGameState};
|
||||||
|
|
||||||
|
use super::Command;
|
||||||
|
|
||||||
|
pub fn advance_game_state(game_state: &mut CurrentGameState) {
|
||||||
|
match game_state.0 {
|
||||||
|
GameState::EarlyGame => {
|
||||||
|
game_state.0 = GameState::MidGame;
|
||||||
|
game_state.1 += 1;
|
||||||
|
}
|
||||||
|
GameState::MidGame => {
|
||||||
|
game_state.0 = GameState::LateGame;
|
||||||
|
game_state.1 += 1;
|
||||||
|
}
|
||||||
|
GameState::LateGame => {
|
||||||
|
game_state.1 += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn game_state(client: &mut Client, game_state: &CurrentGameState) {
|
||||||
|
client.send_message(match game_state.0 {
|
||||||
|
GameState::EarlyGame => "Early game".italic().color(Color::GRAY),
|
||||||
|
GameState::MidGame => "Mid game".italic().color(Color::GRAY),
|
||||||
|
GameState::LateGame => "Late game".italic().color(Color::GRAY),
|
||||||
|
})
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
use valence::prelude::*;
|
||||||
|
|
||||||
|
use crate::CurrentGameState;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub enum GameState {
|
||||||
|
EarlyGame,
|
||||||
|
MidGame,
|
||||||
|
LateGame,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn game_state_update(mut game_state: ResMut<CurrentGameState>) {
|
||||||
|
match game_state.0 {
|
||||||
|
GameState::EarlyGame => {
|
||||||
|
game_state.0 = GameState::MidGame;
|
||||||
|
game_state.1 += 1;
|
||||||
|
}
|
||||||
|
GameState::MidGame => {
|
||||||
|
game_state.0 = GameState::LateGame;
|
||||||
|
game_state.1 += 1;
|
||||||
|
}
|
||||||
|
GameState::LateGame => {
|
||||||
|
game_state.1 += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
use owo_colors::OwoColorize;
|
||||||
|
use std::fmt;
|
||||||
|
use tracing::Level;
|
||||||
|
use tracing_core::{Event, Subscriber};
|
||||||
|
use tracing_subscriber::fmt::{
|
||||||
|
format::{self, FormatEvent, FormatFields},
|
||||||
|
FmtContext,
|
||||||
|
};
|
||||||
|
use tracing_subscriber::registry::LookupSpan;
|
||||||
|
|
||||||
|
pub struct Formatter;
|
||||||
|
|
||||||
|
impl<S, N> FormatEvent<S, N> for Formatter
|
||||||
|
where
|
||||||
|
S: Subscriber + for<'a> LookupSpan<'a>,
|
||||||
|
N: for<'a> FormatFields<'a> + 'static,
|
||||||
|
{
|
||||||
|
fn format_event(
|
||||||
|
&self,
|
||||||
|
ctx: &FmtContext<'_, S, N>,
|
||||||
|
mut writer: format::Writer<'_>,
|
||||||
|
event: &Event<'_>,
|
||||||
|
) -> fmt::Result {
|
||||||
|
// Format values from the event's's metadata:
|
||||||
|
let metadata = event.metadata();
|
||||||
|
write!(
|
||||||
|
&mut writer,
|
||||||
|
"{} {}: ",
|
||||||
|
match *metadata.level() {
|
||||||
|
Level::ERROR => "ERROR".red().to_string(),
|
||||||
|
Level::WARN => "WARN".yellow().to_string(),
|
||||||
|
Level::INFO => "INFO".green().to_string(),
|
||||||
|
_ => "UNKN".white().to_string(),
|
||||||
|
},
|
||||||
|
metadata.target()
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Write fields on the event
|
||||||
|
ctx.field_format().format_fields(writer.by_ref(), event)?;
|
||||||
|
|
||||||
|
writeln!(writer)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue