Files
HokmPlay/server/src/Hokm.Server/Profiles/ProfileModels.cs
T

164 lines
5.8 KiB
C#
Raw Normal View History

using System.Text.Json;
using System.Text.Json.Serialization;
namespace Hokm.Server.Profiles;
public class StatsDto
{
public int Games { get; set; }
public int Wins { get; set; }
public int Losses { get; set; }
public int KotsFor { get; set; }
public int KotsAgainst { get; set; }
public int Tricks { get; set; }
public int BestWinStreak { get; set; }
public int CurrentWinStreak { get; set; }
public int ShutoutWins { get; set; }
public int HakemRounds { get; set; }
public int RoundsWon { get; set; }
}
/// <summary>Optional social-media handles a player chooses to share.</summary>
public class SocialLinksDto
{
public string? Instagram { get; set; }
public string? Telegram { get; set; }
public string? X { get; set; }
public string? Youtube { get; set; }
}
/// <summary>Mirrors the client UserProfile (camelCase JSON).</summary>
public class ProfileDto
{
public string Id { get; set; } = "";
public string Username { get; set; } = "";
public string DisplayName { get; set; } = "بازیکن";
public string Avatar { get; set; } = "a-fox";
public string? AvatarImage { get; set; }
public string? Phone { get; set; }
public string? Email { get; set; }
public string Plan { get; set; } = "free";
public long? PlanUntil { get; set; }
public int Level { get; set; } = 1;
public int Xp { get; set; }
public int Coins { get; set; } = 1000;
public int Rating { get; set; } = 1000;
public StatsDto Stats { get; set; } = new();
public List<string> OwnedAvatars { get; set; } = new() { "a-fox", "a-lion" };
public List<string> OwnedCardFronts { get; set; } = new() { "classic" };
public List<string> OwnedCardBacks { get; set; } = new() { "classic" };
public List<string> OwnedTitles { get; set; } = new() { "novice" };
public List<string> OwnedReactionPacks { get; set; } = new();
public List<string> OwnedStickerPacks { get; set; } = new();
public string? Title { get; set; } = "novice";
public string CardFront { get; set; } = "classic";
public string CardBack { get; set; } = "classic";
public Dictionary<string, int> Achievements { get; set; } = new();
public List<string> Unlocked { get; set; } = new();
public long CreatedAt { get; set; }
// social
public string Gender { get; set; } = ""; // "" | male | female | other
public string? City { get; set; } // selected city id (see client IRAN_CITIES)
public bool CityRewardClaimed { get; set; } // one-time "set your city" reward granted
public SocialLinksDto Socials { get; set; } = new();
public string SocialsVisibility { get; set; } = "public"; // public | friends | hidden
// daily reward streak
public int DailyDay { get; set; } = 1;
public string? DailyLastClaimed { get; set; } // yyyy-MM-dd
}
/// <summary>
/// Public-facing view of another player (no coins/phone/email). Mirrors the
/// client <c>PublicProfile</c>. Returned by <c>GET /api/profile/{id}/public</c>.
/// </summary>
public class PublicProfileDto
{
public string Id { get; set; } = "";
public string DisplayName { get; set; } = "";
public string Avatar { get; set; } = "a-fox";
public string? AvatarImage { get; set; }
public string Plan { get; set; } = "free";
public string? Title { get; set; }
public int Level { get; set; } = 1;
public int Rating { get; set; } = 1000;
public StatsDto Stats { get; set; } = new();
public Dictionary<string, int> Achievements { get; set; } = new();
public List<string> Unlocked { get; set; } = new();
public long CreatedAt { get; set; }
public string Gender { get; set; } = "";
/// <summary>Only populated when the viewer is allowed to see them (public / friend / self).</summary>
public SocialLinksDto? Socials { get; set; }
public bool IsFriend { get; set; }
public bool IsYou { get; set; }
public bool RequestSent { get; set; }
}
public class MatchSummaryDto
{
public bool Ranked { get; set; }
public int Stake { get; set; }
public bool Won { get; set; }
public bool KotFor { get; set; }
public bool KotAgainst { get; set; }
public int TricksWon { get; set; }
public int Rounds { get; set; }
public bool Shutout { get; set; }
public int HakemRounds { get; set; }
public int RoundsWon { get; set; }
public bool Forfeit { get; set; }
}
public class AchievementUnlockDto
{
public string Id { get; set; } = "";
public string NameFa { get; set; } = "";
public string NameEn { get; set; } = "";
public string Icon { get; set; } = "";
public int CoinReward { get; set; }
}
public class TitleUnlockDto
{
public string Id { get; set; } = "";
public string NameFa { get; set; } = "";
public string NameEn { get; set; } = "";
}
public class RewardResultDto
{
public int RatingBefore { get; set; }
public int RatingAfter { get; set; }
public int RatingDelta { get; set; }
public int CoinsBefore { get; set; }
public int CoinsAfter { get; set; }
public int CoinsDelta { get; set; }
public int XpGained { get; set; }
public int LevelBefore { get; set; }
public int LevelAfter { get; set; }
public bool LeveledUp { get; set; }
public List<AchievementUnlockDto> NewAchievements { get; set; } = new();
public List<TitleUnlockDto> NewTitles { get; set; } = new();
public bool Promoted { get; set; }
public bool Demoted { get; set; }
}
public class CoinPackDto
{
public string Id { get; set; } = "";
public int Coins { get; set; }
public int Bonus { get; set; }
public int PriceToman { get; set; }
public string? Tag { get; set; }
}
public static class JsonOpts
{
public static readonly JsonSerializerOptions Default = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
};
}