From 48957df3cdb76806c4a3bb07396f3deae33c8d09 Mon Sep 17 00:00:00 2001 From: wrk Date: Fri, 9 Jun 2023 02:00:32 +0200 Subject: [PATCH] Using new ircie version --- src/main.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index d4ae32f..af34c62 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ use std::{ use ircie::{ format::{Color, Msg}, system::IntoResponse, - system_params::{AnyArguments, Res, ResMut}, + system_params::{AnyArguments, Channel, Context, Res, ResMut}, Irc, }; use itertools::Itertools; @@ -208,6 +208,7 @@ enum FightStatus { #[derive(Default)] struct Fight { status: FightStatus, + channel: String, kind: FightKind, fighters: Vec, } @@ -240,13 +241,14 @@ async fn main() -> std::io::Result<()> { } fn fight( + mut ctx: Context, mut fight: ResMut, mut rng: ResMut, mut hall_of_fame: ResMut, -) -> impl IntoResponse { +) { if fight.status == FightStatus::Idle { std::thread::sleep(Duration::from_millis(50)); - return None; + return; } let teams_remaining: Vec<_> = fight @@ -304,7 +306,11 @@ fn fight( fight.fighters = vec![]; hall_of_fame.save(SAVE_LOC).unwrap(); - return Some((false, lines)); + for line in lines { + ctx.privmsg(&fight.channel, &line.to_string()) + } + fight.channel = "".to_owned(); + return; } let mut lines = vec![]; @@ -383,11 +389,14 @@ fn fight( fight.fighters.remove(victim_idx); } - Some((false, lines)) + for line in lines { + ctx.privmsg(&fight.channel, &line.to_string()) + } } fn new_fight( arguments: AnyArguments, + channel: Channel, mut fight: ResMut, mut rng: ResMut, ) -> impl IntoResponse { @@ -442,6 +451,8 @@ fn new_fight( fight.status = FightStatus::Happening; + fight.channel = channel.to_owned(); + let mut init_msg = vec![Msg::new() .color(Color::Yellow) .text("THE FIGHT IS ABOUT TO BEGIN! TAKE YOUR BETS!")];