rng sleeps + shit + ideas
This commit is contained in:
parent
39364e6403
commit
69fab9980c
7
IDEAS
Normal file
7
IDEAS
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
make this fuckin lib async so I can sleep in between shit
|
||||||
|
,titlefight where looser gets 5k'd
|
||||||
|
@acidvegas │ 1000 chat lines = increased attack
|
||||||
|
@acidvegas │ 24 hour idling makes you WEAKER
|
||||||
|
@acidvegas │ > fighter of the week every friday night
|
||||||
|
@acidvegas │ > loser of the week (most deaths)
|
||||||
|
taunting on ,challenge
|
128
src/main.rs
128
src/main.rs
@ -107,6 +107,7 @@ const COLORS: &'static [&'static Color] = &[
|
|||||||
&Color::Teal,
|
&Color::Teal,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
struct Fighter {
|
struct Fighter {
|
||||||
nick: String,
|
nick: String,
|
||||||
health: f32,
|
health: f32,
|
||||||
@ -241,7 +242,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.await
|
.await
|
||||||
.add_resource(HallOfFame::load(SAVE_LOC).unwrap())
|
.add_resource(HallOfFame::load(SAVE_LOC).unwrap())
|
||||||
.await
|
.await
|
||||||
.add_interval_task(Duration::from_secs(1), fight)
|
.add_interval_task(Duration::from_millis(10), fight)
|
||||||
.await
|
.await
|
||||||
.add_event_system(IrcCommand::RPL_WHOREPLY, whoreply)
|
.add_event_system(IrcCommand::RPL_WHOREPLY, whoreply)
|
||||||
.await
|
.await
|
||||||
@ -292,6 +293,7 @@ fn fight(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if fight.status != FightStatus::Happening {
|
if fight.status != FightStatus::Happening {
|
||||||
|
std::thread::sleep(Duration::from_millis(500));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,38 +315,49 @@ fn fight(
|
|||||||
.filter(|f| f.team_idx == team_idx)
|
.filter(|f| f.team_idx == team_idx)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let mut lines = vec![];
|
|
||||||
|
|
||||||
if fight.fighters.len() == 1 {
|
if fight.fighters.len() == 1 {
|
||||||
lines.push(
|
ctx.privmsg(
|
||||||
Msg::new()
|
&fight.channel,
|
||||||
|
&Msg::new()
|
||||||
.color(Color::Yellow)
|
.color(Color::Yellow)
|
||||||
.text("We have a winner! -> ")
|
.text("We have a winner! -> ")
|
||||||
.color(winners[0].color)
|
.color(winners[0].color)
|
||||||
.text(&winners[0].nick)
|
.text(&winners[0].nick)
|
||||||
.color(Color::Yellow)
|
.color(Color::Yellow)
|
||||||
.text(" <- !"),
|
.text(" <- !")
|
||||||
|
.to_string(),
|
||||||
);
|
);
|
||||||
hall_of_fame.add_winner(&winners[0].nick);
|
hall_of_fame.add_winner(&winners[0].nick);
|
||||||
} else {
|
} else {
|
||||||
lines.push(Msg::new().color(Color::Yellow).text("We have winners!"));
|
ctx.privmsg(
|
||||||
|
&fight.channel,
|
||||||
|
&Msg::new()
|
||||||
|
.color(Color::Yellow)
|
||||||
|
.text("We have winners!")
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
|
|
||||||
for w in &winners {
|
for w in &winners {
|
||||||
lines.push(
|
ctx.privmsg(
|
||||||
Msg::new()
|
&fight.channel,
|
||||||
|
&Msg::new()
|
||||||
.color(Color::Yellow)
|
.color(Color::Yellow)
|
||||||
.text("-> ")
|
.text("-> ")
|
||||||
.color(w.color)
|
.color(w.color)
|
||||||
.text(&w.nick)
|
.text(&w.nick)
|
||||||
.color(Color::Yellow)
|
.color(Color::Yellow)
|
||||||
.text(" <-"),
|
.text(" <-")
|
||||||
|
.to_string(),
|
||||||
);
|
);
|
||||||
|
|
||||||
hall_of_fame.add_winner(&w.nick);
|
hall_of_fame.add_winner(&w.nick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for w in &winners {
|
for w in &winners {
|
||||||
lines.push(Msg::new().text("!beer ").text(&w.nick));
|
ctx.privmsg(
|
||||||
|
&fight.channel,
|
||||||
|
&Msg::new().text("!beer ").text(&w.nick).to_string(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.mode(
|
ctx.mode(
|
||||||
@ -358,68 +371,59 @@ fn fight(
|
|||||||
|
|
||||||
fight.fighters = vec![];
|
fight.fighters = vec![];
|
||||||
hall_of_fame.save(SAVE_LOC).unwrap();
|
hall_of_fame.save(SAVE_LOC).unwrap();
|
||||||
|
|
||||||
for line in lines {
|
|
||||||
ctx.privmsg(&fight.channel, &line.to_string())
|
|
||||||
}
|
|
||||||
fight.channel = "".to_owned();
|
fight.channel = "".to_owned();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut lines = vec![];
|
|
||||||
|
|
||||||
let body_part = BODYPARTS.choose(&mut *rng).unwrap();
|
let body_part = BODYPARTS.choose(&mut *rng).unwrap();
|
||||||
let action = ACTIONS.choose(&mut *rng).unwrap();
|
let action = ACTIONS.choose(&mut *rng).unwrap();
|
||||||
let damage = rng.gen::<f32>() * 80.;
|
let damage = rng.gen::<f32>() * 75.;
|
||||||
|
|
||||||
let victim_idx = rng.gen_range(0..fight.fighters.len());
|
let attacker = fight.fighters.choose(&mut *rng).unwrap().clone();
|
||||||
let mut fucking_victim = fight.fighters.get_mut(victim_idx).unwrap();
|
let chan = fight.channel.clone();
|
||||||
|
|
||||||
if fucking_victim.nick == "wrk" {
|
let fucking_victim = if fight
|
||||||
// ;)
|
|
||||||
fucking_victim = fight.fighters.get_mut(victim_idx).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
fucking_victim.health -= damage;
|
|
||||||
|
|
||||||
let fucking_victim = fight.fighters.get(victim_idx).unwrap();
|
|
||||||
|
|
||||||
let attacker = if fight
|
|
||||||
.fighters
|
.fighters
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|f| f.team_idx == fucking_victim.team_idx && f.nick != fucking_victim.nick)
|
.filter(|f| f.team_idx == attacker.team_idx && f.nick != attacker.nick)
|
||||||
.count()
|
.count()
|
||||||
!= 0
|
!= 0
|
||||||
&& rng.gen_bool(1. / 4.)
|
&& rng.gen_bool(1. / 4.)
|
||||||
{
|
{
|
||||||
let attacker = fight
|
let victim = fight
|
||||||
.fighters
|
.fighters
|
||||||
.iter()
|
.iter_mut()
|
||||||
.filter(|f| f.team_idx == fucking_victim.team_idx && f.nick != fucking_victim.nick)
|
.filter(|f| f.team_idx == attacker.team_idx && f.nick != attacker.nick)
|
||||||
.choose(&mut *rng)
|
.choose(&mut *rng)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
lines.push(
|
ctx.privmsg(
|
||||||
Msg::new()
|
&chan,
|
||||||
|
&Msg::new()
|
||||||
.color(Color::Yellow)
|
.color(Color::Yellow)
|
||||||
.text("Oh no! ")
|
.text("Oh no! ")
|
||||||
.color(attacker.color)
|
.color(attacker.color)
|
||||||
.text(&attacker.nick)
|
.text(&attacker.nick)
|
||||||
.color(Color::Yellow)
|
.color(Color::Yellow)
|
||||||
.text(&format!(" is fucking retarded and is attacking his mate!")),
|
.text(&format!(" is fucking retarded and is attacking his mate!"))
|
||||||
|
.to_string(),
|
||||||
);
|
);
|
||||||
attacker
|
victim
|
||||||
} else {
|
} else {
|
||||||
fight
|
fight
|
||||||
.fighters
|
.fighters
|
||||||
.iter()
|
.iter_mut()
|
||||||
.filter(|f| f.team_idx != fucking_victim.team_idx)
|
.filter(|f| f.team_idx != attacker.team_idx)
|
||||||
.choose(&mut *rng)
|
.choose(&mut *rng)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
lines.push(
|
fucking_victim.health -= damage;
|
||||||
Msg::new()
|
let fucking_victim = fucking_victim.clone();
|
||||||
|
|
||||||
|
ctx.privmsg(
|
||||||
|
&fight.channel,
|
||||||
|
&Msg::new()
|
||||||
.color(attacker.color)
|
.color(attacker.color)
|
||||||
.text(&attacker.nick)
|
.text(&attacker.nick)
|
||||||
.reset()
|
.reset()
|
||||||
@ -427,33 +431,35 @@ fn fight(
|
|||||||
.color(fucking_victim.color)
|
.color(fucking_victim.color)
|
||||||
.text(&fucking_victim.nick)
|
.text(&fucking_victim.nick)
|
||||||
.reset()
|
.reset()
|
||||||
.text(&format!("'s {}! (-{:.2} hp)", body_part, damage)),
|
.text(&format!("'s {}! (-{:.2} hp)", body_part, damage))
|
||||||
|
.to_string(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if fucking_victim.health <= 0. {
|
if fucking_victim.health <= 0. {
|
||||||
lines.push(
|
ctx.privmsg(
|
||||||
Msg::new()
|
&fight.channel,
|
||||||
|
&Msg::new()
|
||||||
.color(fucking_victim.color)
|
.color(fucking_victim.color)
|
||||||
.text(&fucking_victim.nick)
|
.text(&fucking_victim.nick)
|
||||||
.color(Color::Yellow)
|
.color(Color::Yellow)
|
||||||
.text(" is lying dead!"),
|
.text(" is lying dead!")
|
||||||
|
.to_string(),
|
||||||
);
|
);
|
||||||
hall_of_fame.add_fucking_looser(&fucking_victim.nick);
|
hall_of_fame.add_fucking_looser(&fucking_victim.nick);
|
||||||
ctx.mode(&fight.channel, &format!("-v {}", fucking_victim.nick));
|
ctx.mode(&fight.channel, &format!("-v {}", fucking_victim.nick));
|
||||||
|
|
||||||
if fight.kind == FightKind::DeathMatch {
|
if fight.kind == FightKind::DeathMatch {
|
||||||
ctx.kick(
|
ctx.privmsg(
|
||||||
&fight.channel,
|
"ChanServ",
|
||||||
&fucking_victim.nick,
|
&format!(
|
||||||
Some("You fucking suck"),
|
"KICK {} {} {}",
|
||||||
|
fight.channel, fucking_victim.nick, "You fucking looser"
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
fight.fighters.remove(victim_idx);
|
fight.fighters.retain(|f| f.nick != fucking_victim.nick);
|
||||||
}
|
|
||||||
|
|
||||||
for line in lines {
|
|
||||||
ctx.privmsg(&fight.channel, &line.to_string())
|
|
||||||
}
|
}
|
||||||
|
std::thread::sleep(Duration::from_millis(rng.gen_range(200..800)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_fight(
|
fn new_fight(
|
||||||
@ -672,18 +678,12 @@ fn whoreply(
|
|||||||
&Msg::new()
|
&Msg::new()
|
||||||
.color(Color::Yellow)
|
.color(Color::Yellow)
|
||||||
.text(format!(
|
.text(format!(
|
||||||
"{} you have been challenged to a deathmatch.",
|
"{} challenges {} to a deathmatch! you have 30s to ,accept or YOURE A BITCH",
|
||||||
|
fight.fighters[0].nick,
|
||||||
arguments[5]
|
arguments[5]
|
||||||
))
|
))
|
||||||
.to_string(),
|
.to_string(),
|
||||||
);
|
);
|
||||||
ctx.privmsg(
|
|
||||||
&fight.channel,
|
|
||||||
&Msg::new()
|
|
||||||
.color(Color::Yellow)
|
|
||||||
.text("you have 30s to accept or pussy out like the little bitch that you are.")
|
|
||||||
.to_string(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
FightKind::RoyalRumble => {
|
FightKind::RoyalRumble => {
|
||||||
let color = COLORS.iter().choose(&mut *rng).unwrap();
|
let color = COLORS.iter().choose(&mut *rng).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user