feat(discord)!: Added string formatter
- Added string formatter - Added Strings struct for passing strings from file - Refactored /info and /quest * to use formatter BREAKING CHANGE: Changed DiscordConfig fields
This commit is contained in:
parent
b6ea2d8958
commit
aec4ef8339
7 changed files with 386 additions and 84 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use poise::serenity_prelude::UserId;
|
||||
use squad_quest::{SquadObject, account::Account, map::Map};
|
||||
|
||||
use crate::{Context, Error, account::fetch_or_init_account};
|
||||
use crate::{Context, Error, account::{account_full_balance, account_rooms_value, account_user_id, fetch_or_init_account}};
|
||||
|
||||
async fn account_balance_string(ctx: &Context<'_>, account: &Account, map: &Map) -> String {
|
||||
let rooms_value = account_rooms_value(account, map);
|
||||
|
|
@ -20,26 +20,6 @@ async fn account_balance_string(ctx: &Context<'_>, account: &Account, map: &Map)
|
|||
)
|
||||
}
|
||||
|
||||
fn account_rooms_value(account: &Account, map: &Map) -> u32 {
|
||||
map.room.iter().filter_map(|r| {
|
||||
if account.rooms_unlocked.contains(&r.id) {
|
||||
Some(r.value)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.sum()
|
||||
}
|
||||
|
||||
fn account_full_balance(account: &Account, map: &Map) -> u32 {
|
||||
let rooms_value = account_rooms_value(account, map);
|
||||
account.balance + rooms_value
|
||||
}
|
||||
|
||||
fn account_user_id(account: &Account) -> UserId {
|
||||
UserId::new(account.id.clone().parse::<u64>().expect("automatically inserted"))
|
||||
}
|
||||
|
||||
#[poise::command(
|
||||
prefix_command,
|
||||
slash_command,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue