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,4 +1,5 @@
|
|||
use squad_quest::{account::Account, config::Config};
|
||||
use poise::serenity_prelude::UserId;
|
||||
use squad_quest::{account::Account, config::Config, map::Map};
|
||||
|
||||
pub fn fetch_or_init_account(conf: &Config, id: String) -> Account {
|
||||
let accounts = conf.load_accounts();
|
||||
|
|
@ -10,3 +11,23 @@ pub fn fetch_or_init_account(conf: &Config, id: String) -> Account {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub 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()
|
||||
}
|
||||
|
||||
pub fn account_full_balance(account: &Account, map: &Map) -> u32 {
|
||||
let rooms_value = account_rooms_value(account, map);
|
||||
account.balance + rooms_value
|
||||
}
|
||||
|
||||
pub fn account_user_id(account: &Account) -> UserId {
|
||||
UserId::new(account.id.clone().parse::<u64>().expect("automatically inserted"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue