mirror of
https://github.com/ayywrk/hardfight.git
synced 2024-12-22 13:46:38 +00:00
Using new ircie version
This commit is contained in:
parent
14800c2ddc
commit
48957df3cd
21
src/main.rs
21
src/main.rs
@ -9,7 +9,7 @@ use std::{
|
|||||||
use ircie::{
|
use ircie::{
|
||||||
format::{Color, Msg},
|
format::{Color, Msg},
|
||||||
system::IntoResponse,
|
system::IntoResponse,
|
||||||
system_params::{AnyArguments, Res, ResMut},
|
system_params::{AnyArguments, Channel, Context, Res, ResMut},
|
||||||
Irc,
|
Irc,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
@ -208,6 +208,7 @@ enum FightStatus {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Fight {
|
struct Fight {
|
||||||
status: FightStatus,
|
status: FightStatus,
|
||||||
|
channel: String,
|
||||||
kind: FightKind,
|
kind: FightKind,
|
||||||
fighters: Vec<Fighter>,
|
fighters: Vec<Fighter>,
|
||||||
}
|
}
|
||||||
@ -240,13 +241,14 @@ async fn main() -> std::io::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fight(
|
fn fight(
|
||||||
|
mut ctx: Context,
|
||||||
mut fight: ResMut<Fight>,
|
mut fight: ResMut<Fight>,
|
||||||
mut rng: ResMut<StdRng>,
|
mut rng: ResMut<StdRng>,
|
||||||
mut hall_of_fame: ResMut<HallOfFame>,
|
mut hall_of_fame: ResMut<HallOfFame>,
|
||||||
) -> impl IntoResponse {
|
) {
|
||||||
if fight.status == FightStatus::Idle {
|
if fight.status == FightStatus::Idle {
|
||||||
std::thread::sleep(Duration::from_millis(50));
|
std::thread::sleep(Duration::from_millis(50));
|
||||||
return None;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let teams_remaining: Vec<_> = fight
|
let teams_remaining: Vec<_> = fight
|
||||||
@ -304,7 +306,11 @@ fn fight(
|
|||||||
fight.fighters = vec![];
|
fight.fighters = vec![];
|
||||||
hall_of_fame.save(SAVE_LOC).unwrap();
|
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![];
|
let mut lines = vec![];
|
||||||
@ -383,11 +389,14 @@ fn fight(
|
|||||||
fight.fighters.remove(victim_idx);
|
fight.fighters.remove(victim_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
Some((false, lines))
|
for line in lines {
|
||||||
|
ctx.privmsg(&fight.channel, &line.to_string())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_fight(
|
fn new_fight(
|
||||||
arguments: AnyArguments,
|
arguments: AnyArguments,
|
||||||
|
channel: Channel,
|
||||||
mut fight: ResMut<Fight>,
|
mut fight: ResMut<Fight>,
|
||||||
mut rng: ResMut<StdRng>,
|
mut rng: ResMut<StdRng>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
@ -442,6 +451,8 @@ fn new_fight(
|
|||||||
|
|
||||||
fight.status = FightStatus::Happening;
|
fight.status = FightStatus::Happening;
|
||||||
|
|
||||||
|
fight.channel = channel.to_owned();
|
||||||
|
|
||||||
let mut init_msg = vec![Msg::new()
|
let mut init_msg = vec![Msg::new()
|
||||||
.color(Color::Yellow)
|
.color(Color::Yellow)
|
||||||
.text("THE FIGHT IS ABOUT TO BEGIN! TAKE YOUR BETS!")];
|
.text("THE FIGHT IS ABOUT TO BEGIN! TAKE YOUR BETS!")];
|
||||||
|
Loading…
Reference in New Issue
Block a user