Balanced lil fren and added command to give medicine
+ clippy + fmt
This commit is contained in:
parent
e9c10bc34f
commit
d25a907ae6
@ -11,7 +11,7 @@ use serenity::model::misc::EmojiIdentifier;
|
||||
use serenity::utils::MessageBuilder;
|
||||
|
||||
#[group]
|
||||
#[commands(adopt, checkup, feed, give_water, play)]
|
||||
#[commands(adopt, checkup, feed, give_water, play, give_medicine)]
|
||||
pub struct Buddy;
|
||||
|
||||
#[command]
|
||||
@ -186,7 +186,7 @@ async fn play(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
|
||||
if let Some(mut lil_fren) = lil_fren {
|
||||
if lil_fren.is_alive() == AliveState::Alive {
|
||||
lil_fren.entertainment =
|
||||
(lil_fren.entertainment + thread_rng().gen_range(-0.10..1.0)).clamp(-1.0, 1.0);
|
||||
(lil_fren.entertainment + thread_rng().gen_range(0.10..1.0)).clamp(-1.0, 1.0);
|
||||
let guild = msg.guild_id.unwrap();
|
||||
|
||||
let lil_fren_emoji = guild.emoji(&ctx.http, lil_fren.emoji).await?;
|
||||
@ -206,3 +206,40 @@ async fn play(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[command]
|
||||
#[description("Help heal buddy")]
|
||||
async fn give_medicine(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
|
||||
let mut data = ctx.data.write().await;
|
||||
let global_data = data.get_mut::<GlobalData>().unwrap();
|
||||
|
||||
let lil_fren = LilFren::get_lil_fren(&global_data.db)?;
|
||||
|
||||
if let Some(mut lil_fren) = lil_fren {
|
||||
if lil_fren.is_alive() == AliveState::Alive {
|
||||
let guild = msg.guild_id.unwrap();
|
||||
|
||||
let reply = if lil_fren.state == LilFrenState::Sick {
|
||||
lil_fren.state = LilFrenState::Standing;
|
||||
"Little buddy feels better now!"
|
||||
} else {
|
||||
"Little buddy is now addicted to cough drops, I hope you are happy"
|
||||
};
|
||||
|
||||
let lil_fren_emoji = guild.emoji(&ctx.http, lil_fren.emoji).await?;
|
||||
|
||||
global_data.db.insert(lil_fren)?;
|
||||
|
||||
msg.reply(&ctx.http, reply).await?;
|
||||
msg.reply(&ctx.http, lil_fren::draw_feed(&lil_fren_emoji, ":pill:"))
|
||||
.await?;
|
||||
} else {
|
||||
msg.reply(&ctx.http, "You may want to check on your buddy...")
|
||||
.await?;
|
||||
}
|
||||
} else {
|
||||
msg.reply(&ctx.http, "Sorry no little buddy found!").await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ impl LilFren {
|
||||
entertainment: 1.0,
|
||||
state: LilFrenState::Standing,
|
||||
smarts: thread_rng().gen_range(0.0..0.5),
|
||||
metabolism: thread_rng().gen_range(0.0..0.5),
|
||||
metabolism: thread_rng().gen_range(0.2..0.75),
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,16 +202,17 @@ impl LilFren {
|
||||
}
|
||||
|
||||
let (hunger_diff, thirst_diff, entertainment_diff) = match lil_fren.state {
|
||||
LilFrenState::Standing => (-0.01, -0.02, -0.01),
|
||||
LilFrenState::TaxFraud => (-0.01, -0.02, 0.01),
|
||||
LilFrenState::Sick => (-0.1, -0.15, -0.01),
|
||||
LilFrenState::Dancing => (-0.05, -0.8, 0.05),
|
||||
LilFrenState::Sleep => (-0.005, -0.01, 0.00),
|
||||
LilFrenState::Standing => (-0.002, -0.002, -0.001),
|
||||
LilFrenState::TaxFraud => (-0.002, -0.002, 0.001),
|
||||
LilFrenState::Sick => (-0.005, -0.005, -0.001),
|
||||
LilFrenState::Dancing => (-0.005, -0.008, 0.01),
|
||||
LilFrenState::Sleep => (-0.001, -0.002, 0.00),
|
||||
};
|
||||
|
||||
lil_fren.hunger = (lil_fren.hunger + hunger_diff * self.metabolism).clamp(-1.0, 1.0);
|
||||
lil_fren.thirst = (lil_fren.thirst + thirst_diff * self.metabolism).clamp(-1.0, 1.0);
|
||||
lil_fren.thirst = (lil_fren.entertainment + entertainment_diff * self.smarts).clamp(-1.0, 1.0);
|
||||
lil_fren.thirst =
|
||||
(lil_fren.entertainment + entertainment_diff * self.smarts).clamp(-1.0, 1.0);
|
||||
|
||||
if thread_rng().gen_bool(0.75) {
|
||||
println!("fren is now {:?}", self.state);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user