More improvements!

This commit is contained in:
Joey Hines 2025-11-15 15:05:39 -07:00
parent 2b5182a876
commit 19d80030c9
Signed by: joeyahines
GPG Key ID: 38BA6F25C94C9382
4 changed files with 110 additions and 3 deletions

View File

@ -71,3 +71,68 @@ pub async fn buy_improvement(
Ok(())
}
/// View Friendship Tower and all its glory!!!
#[poise::command(prefix_command, guild_only, category = "Improvements")]
pub async fn friendship_tower(ctx: Context<'_>) -> Result<(), Error> {
if let Some(tower) =
Improvements::get_improvement(&ctx.data().db, ImprovementType::FriendshipTower)?
{
let buffer = 2;
let pic_height = tower.level as usize + buffer + 1;
let width = 5;
let pic_width = width + buffer * 2;
let tower_level = tower.level as usize + buffer;
let mut msg_builder = MessageBuilder::new();
msg_builder.push_line("BEHOLD ALL ITS GLORY. MY FINEST CREATION, THE THING THAT WILL BRING US ALL SALVATION!!!!");
msg_builder.push_line("");
for row in 0..pic_height {
let line = if row < buffer {
"🟦".repeat(pic_width)
} else if row < tower_level {
"🟦🟦⬛⬛⬛⬛⬛🟦🟦".to_string()
} else {
"🟩".repeat(pic_width)
};
msg_builder.push_line(line);
}
ctx.reply(msg_builder.build()).await?;
} else {
ctx.reply("This is where I would put my tower, IF I HAD ONE!!!!")
.await?;
}
Ok(())
}
/// See how big Jotchua's college fund is!
#[poise::command(prefix_command, guild_only, category = "Improvements")]
pub async fn jotchua_college_fund(ctx: Context<'_>) -> Result<(), Error> {
let funds_level = if let Some(fund) =
Improvements::get_improvement(&ctx.data().db, ImprovementType::JotchuaCollegeFund)?
{
fund.level
} else {
0
};
let college_savings = funds_level as u64 * ImprovementType::JotchuaCollegeFund.price();
let jotch = match college_savings {
0..30_000 => ":VoidJotch:",
30_000..120_000 => ":Jotch:",
120_000.. => ":AscendedJotch:",
};
ctx.reply(format!(
"{jotch} has {} FC in the bank for his college fund!",
college_savings
))
.await?;
Ok(())
}

View File

@ -359,6 +359,8 @@ pub async fn run_bot(global_data: GlobalData) {
image::edit_img(),
improvements::improvements(),
improvements::buy_improvement(),
improvements::friendship_tower(),
improvements::jotchua_college_fund(),
movie::add_movie(),
movie::list_movies(),
movie::rate_movie(),

View File

@ -28,6 +28,9 @@ impl std::error::Error for ImprovementError {}
#[derive(Debug, Deserialize, Serialize, Clone, Hash, Eq, PartialEq, Copy, EnumIter)]
pub enum ImprovementType {
GogurtNightMarket,
LilBuddyAutoFeeder,
FriendshipTower,
JotchuaCollegeFund,
}
impl ImprovementType {
@ -36,28 +39,48 @@ impl ImprovementType {
ImprovementType::GogurtNightMarket => {
"Keep the Gogurt Market open until 11 PM NST".to_string()
}
ImprovementType::LilBuddyAutoFeeder => {
"Buy an auto-feeder for Lil Buddy to keep them fed!".to_string()
}
ImprovementType::FriendshipTower => "Make the Friendship Tower taller!!".to_string(),
ImprovementType::JotchuaCollegeFund => {
"Contribute to Jotchua's college fund!".to_string()
}
}
}
pub fn price(&self) -> u64 {
match self {
ImprovementType::GogurtNightMarket => 200_000,
ImprovementType::LilBuddyAutoFeeder => 150_000,
ImprovementType::FriendshipTower => 50_000,
ImprovementType::JotchuaCollegeFund => 1_000,
}
}
pub fn has_levels(&self) -> bool {
false
#[allow(clippy::match_like_matches_macro)]
match self {
ImprovementType::FriendshipTower => true,
_ => false,
}
}
pub fn name(&self) -> String {
match self {
ImprovementType::GogurtNightMarket => "Gogurt Night Market".to_string(),
ImprovementType::LilBuddyAutoFeeder => "Autofeeder".to_string(),
ImprovementType::FriendshipTower => "Friendship Tower".to_string(),
ImprovementType::JotchuaCollegeFund => "Jotchua College Fund".to_string(),
}
}
pub fn post_buy_description(&self) -> String {
match self {
ImprovementType::GogurtNightMarket => "Congrats on investing in the night market. The first day of night trading will start tomorrow!".to_string()
ImprovementType::GogurtNightMarket => "Congrats on investing in the night market. The first day of night trading will start tomorrow!".to_string(),
ImprovementType::LilBuddyAutoFeeder => "Very kind of you, Lil Buddy will never starve again.".to_string(),
ImprovementType::FriendshipTower => "ANOTHER GLORIOUS FLOOR FOR THE TOWER, MAY IT EVER GET CLOSER TO GOD".to_string(),
ImprovementType::JotchuaCollegeFund => "Jotchua thanks you!!!".to_string()
}
}
}
@ -70,6 +93,9 @@ impl FromStr for ImprovementType {
match name.as_str() {
"gogurt night market" => Ok(Self::GogurtNightMarket),
"autofeeder" => Ok(Self::LilBuddyAutoFeeder),
"friendship tower" => Ok(Self::FriendshipTower),
"jotchua college fund" => Ok(Self::JotchuaCollegeFund),
_ => Err(ImprovementError::UnknownImprovement),
}
}
@ -119,6 +145,13 @@ impl Improvements {
Ok(entry.level)
}
pub fn has_improvement(
db: &Database,
improvement_type: ImprovementType,
) -> Result<bool, Error> {
Ok(Self::get_improvement(db, improvement_type)?.is_some())
}
}
impl JdbModel for Improvements {

View File

@ -1,6 +1,7 @@
use crate::config::GlobalData;
use crate::discord::Context;
use crate::error::Error;
use crate::models::improvements::{ImprovementType, Improvements};
use j_db::database::Database;
use j_db::model::JdbModel;
use log::{debug, info};
@ -185,7 +186,7 @@ pub fn draw_mugging(emoji: &Emoji) -> String {
msg.push_line(":blue_square::blue_square::blue_square::blue_square::blue_square:");
msg.push(":blue_square::blue_square:");
msg.emoji(emoji);
msg.push_line(":GunPoint: :man_standing:");
msg.push_line(":Gunpoint: :man_standing:");
msg.push_line(":green_square::green_square::green_square::green_square::green_square:");
msg.build()
@ -336,6 +337,12 @@ impl LilFren {
info!("fren is now {:?}", self.state);
}
if lil_fren.hunger < 0.25
&& Improvements::has_improvement(db, ImprovementType::LilBuddyAutoFeeder)?
{
lil_fren.hunger = 0.25;
}
db.insert(lil_fren)?;
}