add: 8 achievements add: larger text setting fix: small infinite
timeline bugs
This commit is contained in:
parent
b860f74124
commit
5dd9fa01cb
19 changed files with 241 additions and 123 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "tetratto-core"
|
||||
version = "9.0.0"
|
||||
version = "10.0.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
|
|
@ -712,7 +712,7 @@ impl DataManager {
|
|||
/// Add an achievement to a user.
|
||||
///
|
||||
/// Still returns `Ok` if the user already has the achievement.
|
||||
pub async fn add_achievement(&self, user: &User, achievement: Achievement) -> Result<()> {
|
||||
pub async fn add_achievement(&self, user: &mut User, achievement: Achievement) -> Result<()> {
|
||||
if user
|
||||
.achievements
|
||||
.iter()
|
||||
|
@ -734,9 +734,8 @@ impl DataManager {
|
|||
.await?;
|
||||
|
||||
// add achievement
|
||||
let mut user = user.clone();
|
||||
user.achievements.push(achievement);
|
||||
self.update_user_achievements(user.id, user.achievements)
|
||||
self.update_user_achievements(user.id, user.achievements.to_owned())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use oiseau::cache::Cache;
|
||||
use crate::model::{
|
||||
Error, Result,
|
||||
auth::{Notification, User},
|
||||
auth::{AchievementName, Notification, User},
|
||||
permissions::FinePermission,
|
||||
reactions::{AssetType, Reaction},
|
||||
Error, Result,
|
||||
};
|
||||
use crate::{auto_method, DataManager};
|
||||
|
||||
|
@ -148,6 +148,33 @@ impl DataManager {
|
|||
{
|
||||
return Err(Error::NotAllowed);
|
||||
}
|
||||
|
||||
// achievements
|
||||
if user.id != post.owner {
|
||||
let mut owner = self.get_user_by_id(post.owner).await?;
|
||||
self.add_achievement(&mut owner, AchievementName::Get1Like.into())
|
||||
.await?;
|
||||
|
||||
if post.likes >= 9 {
|
||||
self.add_achievement(&mut owner, AchievementName::Get10Likes.into())
|
||||
.await?;
|
||||
}
|
||||
|
||||
if post.likes >= 49 {
|
||||
self.add_achievement(&mut owner, AchievementName::Get50Likes.into())
|
||||
.await?;
|
||||
}
|
||||
|
||||
if post.likes >= 99 {
|
||||
self.add_achievement(&mut owner, AchievementName::Get100Likes.into())
|
||||
.await?;
|
||||
}
|
||||
|
||||
if post.dislikes >= 24 {
|
||||
self.add_achievement(&mut owner, AchievementName::Get25Dislikes.into())
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
} else if data.asset_type == AssetType::Question {
|
||||
let question = self.get_question_by_id(data.asset).await?;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use oiseau::cache::Cache;
|
||||
use crate::model::auth::FollowResult;
|
||||
use crate::model::auth::{AchievementName, FollowResult};
|
||||
use crate::model::requests::{ActionRequest, ActionType};
|
||||
use crate::model::{Error, Result, auth::User, auth::UserFollow, permissions::FinePermission};
|
||||
use crate::{auto_method, DataManager};
|
||||
|
@ -238,9 +238,14 @@ impl DataManager {
|
|||
/// # Arguments
|
||||
/// * `data` - a mock [`UserFollow`] object to insert
|
||||
/// * `force` - if we should skip the request stage
|
||||
pub async fn create_userfollow(&self, data: UserFollow, force: bool) -> Result<FollowResult> {
|
||||
pub async fn create_userfollow(
|
||||
&self,
|
||||
data: UserFollow,
|
||||
initiator: &User,
|
||||
force: bool,
|
||||
) -> Result<FollowResult> {
|
||||
if !force {
|
||||
let other_user = self.get_user_by_id(data.receiver).await?;
|
||||
let mut other_user = self.get_user_by_id(data.receiver).await?;
|
||||
|
||||
if other_user.settings.private_profile {
|
||||
// send follow request instead
|
||||
|
@ -254,6 +259,12 @@ impl DataManager {
|
|||
|
||||
return Ok(FollowResult::Requested);
|
||||
}
|
||||
|
||||
// check if we're staff
|
||||
if initiator.permissions.check(FinePermission::STAFF_BADGE) {
|
||||
self.add_achievement(&mut other_user, AchievementName::FollowedByStaff.into())
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
// ...
|
||||
|
|
|
@ -258,6 +258,9 @@ pub struct UserSettings {
|
|||
/// Automatically clear all notifications when notifications are viewed.
|
||||
#[serde(default)]
|
||||
pub auto_clear_notifs: bool,
|
||||
/// Increase the text size of buttons and paragraphs.
|
||||
#[serde(default)]
|
||||
pub large_text: bool,
|
||||
}
|
||||
|
||||
fn mime_avif() -> String {
|
||||
|
@ -475,26 +478,26 @@ pub struct ExternalConnectionData {
|
|||
}
|
||||
|
||||
/// The total number of achievements needed to 100% Tetratto!
|
||||
pub const ACHIEVEMENTS: usize = 8;
|
||||
pub const ACHIEVEMENTS: usize = 16;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum AchievementName {
|
||||
/// Create your first post.
|
||||
CreatePost,
|
||||
/// Follow somebody.
|
||||
FollowUser,
|
||||
/// Create your 50th post.
|
||||
Create50Posts,
|
||||
/// Create your 100th post.
|
||||
Create100Posts,
|
||||
/// Create your 1000th post.
|
||||
Create1000Posts,
|
||||
/// Ask your first question.
|
||||
CreateQuestion,
|
||||
/// Edit your settings.
|
||||
EditSettings,
|
||||
/// Create your first journal.
|
||||
CreateJournal,
|
||||
FollowedByStaff,
|
||||
CreateDrawing,
|
||||
OpenAchievements,
|
||||
Get1Like,
|
||||
Get10Likes,
|
||||
Get50Likes,
|
||||
Get100Likes,
|
||||
Get25Dislikes,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
|
@ -515,6 +518,14 @@ impl AchievementName {
|
|||
Self::CreateQuestion => "Big questions...",
|
||||
Self::EditSettings => "Just how I like it!",
|
||||
Self::CreateJournal => "Dear diary...",
|
||||
Self::FollowedByStaff => "Big Shrimpin'",
|
||||
Self::CreateDrawing => "Modern art",
|
||||
Self::OpenAchievements => "Welcome!",
|
||||
Self::Get1Like => "Baby steps!",
|
||||
Self::Get10Likes => "WOW! 10 LIKES!",
|
||||
Self::Get50Likes => "banger post follow for more",
|
||||
Self::Get100Likes => "everyone liked that",
|
||||
Self::Get25Dislikes => "Sorry...",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -528,19 +539,37 @@ impl AchievementName {
|
|||
Self::CreateQuestion => "Ask your first question!",
|
||||
Self::EditSettings => "Edit your settings.",
|
||||
Self::CreateJournal => "Create your first journal.",
|
||||
Self::FollowedByStaff => "Get followed by a staff member!",
|
||||
Self::CreateDrawing => "Include a drawing in a question.",
|
||||
Self::OpenAchievements => "Open the achievements page.",
|
||||
Self::Get1Like => "Get 1 like on a post! Good job!",
|
||||
Self::Get10Likes => "Get 10 likes on one post.",
|
||||
Self::Get50Likes => "Get 50 likes on one post.",
|
||||
Self::Get100Likes => "Get 100 likes on one post.",
|
||||
Self::Get25Dislikes => "Get 25 dislikes on one post... :(",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rarity(&self) -> AchievementRarity {
|
||||
// i don't want to write that long ass type name everywhere
|
||||
use AchievementRarity::*;
|
||||
match self {
|
||||
Self::CreatePost => AchievementRarity::Common,
|
||||
Self::FollowUser => AchievementRarity::Common,
|
||||
Self::Create50Posts => AchievementRarity::Uncommon,
|
||||
Self::Create100Posts => AchievementRarity::Uncommon,
|
||||
Self::Create1000Posts => AchievementRarity::Rare,
|
||||
Self::CreateQuestion => AchievementRarity::Common,
|
||||
Self::EditSettings => AchievementRarity::Common,
|
||||
Self::CreateJournal => AchievementRarity::Uncommon,
|
||||
Self::CreatePost => Common,
|
||||
Self::FollowUser => Common,
|
||||
Self::Create50Posts => Uncommon,
|
||||
Self::Create100Posts => Uncommon,
|
||||
Self::Create1000Posts => Rare,
|
||||
Self::CreateQuestion => Common,
|
||||
Self::EditSettings => Common,
|
||||
Self::CreateJournal => Uncommon,
|
||||
Self::FollowedByStaff => Rare,
|
||||
Self::CreateDrawing => Common,
|
||||
Self::OpenAchievements => Common,
|
||||
Self::Get1Like => Common,
|
||||
Self::Get10Likes => Common,
|
||||
Self::Get50Likes => Uncommon,
|
||||
Self::Get100Likes => Rare,
|
||||
Self::Get25Dislikes => Uncommon,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue