mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 07:29:00 -07:00
181 lines
3.0 KiB
C#
181 lines
3.0 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using RadicadeServer.RecNet.Enums.Moderation;
|
|
|
|
namespace RadicadeServer.RecNet.Moderation
|
|
{
|
|
public class Reputation
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public const int CheerBadgeThreshold = 5;
|
|
|
|
|
|
|
|
|
|
|
|
public const double DefaultReputation = 10.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public const double NoterietyPerCheer = 0.5;
|
|
public const double NoterietyPerSubscriber = 0.5;
|
|
|
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
|
public long AccountId { get; set; }
|
|
public double Noteriety { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public double ReputationScore { get; set; } = DefaultReputation;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int ReportCount { get; set; }
|
|
public int CheerGeneral { get; set; }
|
|
public int CheerHelpful { get; set; }
|
|
public int CheerCreative { get; set; }
|
|
public int CheerGreatHost { get; set; }
|
|
public int CheerSportsman { get; set; }
|
|
public int CheerCredit { get; set; }
|
|
public int SelectedCheer { get; set; }
|
|
public bool IsCheerful { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[NotMapped]
|
|
public int TotalCheers =>
|
|
CheerGeneral + CheerHelpful + CheerCreative + CheerGreatHost + CheerSportsman + CheerCredit;
|
|
|
|
|
|
|
|
|
|
|
|
[NotMapped]
|
|
public string Trust => ReputationScore switch
|
|
{
|
|
>= 8.0 => "Trusted",
|
|
>= 6.0 => "Neutral",
|
|
_ => "Not Trusted"
|
|
};
|
|
|
|
public int GetCheerCount(CheerCategory category) => category switch
|
|
{
|
|
CheerCategory.General => CheerGeneral,
|
|
CheerCategory.Helpful => CheerHelpful,
|
|
CheerCategory.Creative => CheerCreative,
|
|
CheerCategory.GreatHost => CheerGreatHost,
|
|
CheerCategory.Sportsman => CheerSportsman,
|
|
CheerCategory.Credit => CheerCredit,
|
|
_ => 0
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void AddCheer(CheerCategory category)
|
|
{
|
|
switch (category)
|
|
{
|
|
case CheerCategory.General: CheerGeneral++; break;
|
|
case CheerCategory.Helpful: CheerHelpful++; break;
|
|
case CheerCategory.Creative: CheerCreative++; break;
|
|
case CheerCategory.GreatHost: CheerGreatHost++; break;
|
|
case CheerCategory.Sportsman: CheerSportsman++; break;
|
|
case CheerCategory.Credit: CheerCredit++; break;
|
|
}
|
|
|
|
Noteriety += NoterietyPerCheer;
|
|
IsCheerful = CheerBadgeEarned;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddSubscriber()
|
|
{
|
|
Noteriety += NoterietyPerSubscriber;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void ApplyBanPenalty(bool permanent, bool cheating)
|
|
{
|
|
double penalty = permanent ? 4.0 : (cheating ? 1.0 : 0.5);
|
|
ReputationScore = Math.Max(0.0, ReputationScore - penalty);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Reputation ForClient()
|
|
{
|
|
return new Reputation
|
|
{
|
|
AccountId = AccountId,
|
|
Noteriety = Math.Min(0.05, Noteriety / 100.0),
|
|
ReputationScore = ReputationScore,
|
|
|
|
|
|
|
|
ReportCount = ReportCount,
|
|
CheerGeneral = CheerGeneral,
|
|
CheerHelpful = CheerHelpful,
|
|
CheerCreative = CheerCreative,
|
|
CheerGreatHost = CheerGreatHost,
|
|
CheerSportsman = CheerSportsman,
|
|
CheerCredit = CheerCredit,
|
|
SelectedCheer = SelectedCheer,
|
|
|
|
|
|
|
|
IsCheerful = CheerBadgeEarned
|
|
};
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[NotMapped]
|
|
public bool CheerBadgeEarned => TotalCheers >= CheerBadgeThreshold;
|
|
|
|
}
|
|
}
|