mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-16 20:14:35 +01:00
* Deleted TestCommand.cs No longer needed. * Update AbyssCommand.cs Added a command to adjust the player's bracket at will. * Update User.cs Added Abyss Group Value * Update Command.cs Added Examples[] to the constructor and handler. * Update HelpCommand.cs Made the Help command more helpful! * Update AbyssCommand.cs Added Help Examples * Update GiveCommand.cs Added help examples, handles negative inputs again, added more aliases, can add or remove materials by ID, can now for add all skipped characters with `give avatars-scuffed` * Update AbyssCommand.cs missed a quote * Update UltraEndlessGetMainDataReqHandler.cs Bracket can now be set with commands. Need to unscuff the fight cycle. * Update GiveCommand.cs Cheeky give gold command * Further refined the Help Command --------- Co-authored-by: TerminalAide0017 <Sucks@code>
115 lines
4.0 KiB
C#
115 lines
4.0 KiB
C#
using MongoDB.Bson;
|
|
using Common.Resources.Proto;
|
|
using MongoDB.Driver;
|
|
using Common.Utils.ExcelReader;
|
|
|
|
namespace Common.Database
|
|
{
|
|
public class User
|
|
{
|
|
public static readonly IMongoCollection<UserScheme> collection = Global.db.GetCollection<UserScheme>("Users");
|
|
|
|
public static UserScheme Create(string name)
|
|
{
|
|
UserScheme? tryUser = collection.AsQueryable().Where(d => d.Name == name).FirstOrDefault();
|
|
if (tryUser != null) { return tryUser; }
|
|
|
|
UserScheme user = new()
|
|
{
|
|
Name = name,
|
|
Uid = (uint)AutoIncrement.GetNextNumber("UID", 1000),
|
|
Nick = "",
|
|
Exp = 0,
|
|
Hcoin = 0,
|
|
Stamina = 80,
|
|
SelfDesc = "",
|
|
IsFirstLogin = true,
|
|
Token = Guid.NewGuid().ToString(),
|
|
WarshipId = 0,
|
|
WarshipAvatar = new WarshipAvatarData()
|
|
{
|
|
WarshipFirstAvatarId = 101,
|
|
WarshipSecondAvatarId = 0
|
|
},
|
|
CustomHeadId = 161001,
|
|
FrameId = 200001,
|
|
AssistantAvatarId = 101,
|
|
BirthDate = 0,
|
|
AbyssDynamicHard = 100,
|
|
AbyssGroupLevel = 8,
|
|
AvatarTeamList = new List<AvatarTeam> { new AvatarTeam { AvatarIdLists = new uint[] { 101 }, StageType = ((uint)StageType.StageStory) } },
|
|
CustomAvatarTeamList = new List<CustomAvatarTeam> { }
|
|
};
|
|
|
|
collection.InsertOne(user);
|
|
|
|
return user;
|
|
}
|
|
|
|
public static UserScheme FromName(string name)
|
|
{
|
|
UserScheme? user = collection.AsQueryable().Where(d => d.Name == name).FirstOrDefault();
|
|
return user ?? Create(name);
|
|
}
|
|
|
|
public static UserScheme? FromToken(string token)
|
|
{
|
|
UserScheme? user = collection.AsQueryable().Where(d => d.Token == token).FirstOrDefault();
|
|
return user;
|
|
}
|
|
|
|
public static UserScheme? FromUid(uint uid)
|
|
{
|
|
UserScheme? user = collection.AsQueryable().Where(d => d.Uid == uid).FirstOrDefault();
|
|
return user;
|
|
}
|
|
|
|
}
|
|
|
|
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
|
public class UserScheme
|
|
{
|
|
public ObjectId Id { get; set; }
|
|
public string Name { get; set; }
|
|
public uint Uid { get; set; }
|
|
public string Nick { get; set; }
|
|
public int Exp { get; set; }
|
|
public int Hcoin { get; set; }
|
|
public int Stamina { get; set; }
|
|
public string SelfDesc { get; set; }
|
|
public bool IsFirstLogin { get; set; }
|
|
public string Token { get; set; }
|
|
public int CustomHeadId { get; set; }
|
|
public int FrameId { get; set; }
|
|
public int WarshipId { get; set; }
|
|
public WarshipAvatarData WarshipAvatar { get; set; }
|
|
public int AssistantAvatarId { get; set; }
|
|
public int BirthDate { get; set; }
|
|
public uint AbyssDynamicHard { get; set; }
|
|
public uint AbyssGroupLevel { get; set; }
|
|
public List<AvatarTeam> AvatarTeamList { get; set; }
|
|
public List<CustomAvatarTeam> CustomAvatarTeamList { get; set; }
|
|
|
|
public void Save()
|
|
{
|
|
User.collection.ReplaceOne(Builders<UserScheme>.Filter.Eq(user => user.Id, Id), this);
|
|
}
|
|
|
|
public uint GetCreationTime()
|
|
{
|
|
return (uint)((DateTimeOffset)Id.CreationTime).ToUnixTimeSeconds();
|
|
}
|
|
|
|
public void AddExp(int exp)
|
|
{
|
|
Exp += exp;
|
|
if (Exp > PlayerLevelData.GetInstance().GetMaxPossibleExp())
|
|
{
|
|
Exp = PlayerLevelData.GetInstance().GetMaxPossibleExp();
|
|
}
|
|
}
|
|
}
|
|
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
|
|
|
}
|