mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-13 10:54:34 +01:00
Http w/ dispatch
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Config.Net" Version="5.1.5" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
|
||||
<PackageReference Include="protobuf-net" Version="3.2.16" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
67
Common/Database/User.cs
Normal file
67
Common/Database/User.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Bson;
|
||||
using Common.Resources.Proto;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace Common.Database
|
||||
{
|
||||
public class User
|
||||
{
|
||||
public static readonly IMongoCollection<UserScheme> collection = Global.db.GetCollection<UserScheme>("Users");
|
||||
|
||||
public static UserScheme CreateUser(string name)
|
||||
{
|
||||
UserScheme user = new()
|
||||
{
|
||||
Name = name,
|
||||
Uid = 1001,
|
||||
Nick = "",
|
||||
Exp = 0,
|
||||
Hcoin = 0,
|
||||
Stamina = 80,
|
||||
SelfDesc = "",
|
||||
IsFirstLogin = true,
|
||||
Token = Guid.NewGuid(),
|
||||
WarshipId = 0,
|
||||
WarshipAvatar = new WarshipAvatarData()
|
||||
{
|
||||
WarshipFirstAvatarId = 101,
|
||||
WarshipSecondAvatarId = 0
|
||||
},
|
||||
AssistantAvatarId = 101,
|
||||
BirthDate = 0,
|
||||
AvatarTeamList = new List<AvatarTeam> { new AvatarTeam { AvatarIdLists = new uint[] { 101 }, StageType = ((uint)StageType.StageStory) } },
|
||||
CustomAvatarTeamList = new List<CustomAvatarTeam> { }
|
||||
};
|
||||
|
||||
collection.InsertOne(user);
|
||||
|
||||
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; }
|
||||
|
||||
[BsonGuidRepresentation(GuidRepresentation.Standard)]
|
||||
public Guid Token { get; set; }
|
||||
public int WarshipId { get; set; }
|
||||
public WarshipAvatarData WarshipAvatar { get; set; }
|
||||
public int AssistantAvatarId { get; set; }
|
||||
public int BirthDate { get; set; }
|
||||
public List<AvatarTeam> AvatarTeamList { get; set; }
|
||||
public List<CustomAvatarTeam> CustomAvatarTeamList { get; set; }
|
||||
}
|
||||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +1,61 @@
|
||||
using Config.Net;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
public static class Global
|
||||
{
|
||||
public static IConfig config = new ConfigurationBuilder<IConfig>().UseJsonFile("config.json").Build();
|
||||
|
||||
public static MongoClient MongoClient = new MongoClient(config.DatabaseUri);
|
||||
public static IMongoDatabase db = MongoClient.GetDatabase("PemukulPaku");
|
||||
public static long GetUnixInSeconds() => ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds();
|
||||
}
|
||||
|
||||
public interface IConfig
|
||||
{
|
||||
[Option(DefaultValue = VerboseLevel.Normal)]
|
||||
[Option(DefaultValue = VerboseLevel.Warns)]
|
||||
VerboseLevel VerboseLevel { get; }
|
||||
|
||||
[Option(DefaultValue = "mongodb://localhost:27017/crepebh")]
|
||||
string DatabaseUri { get; }
|
||||
[Option(DefaultValue = false)]
|
||||
bool UseLocalCache { get; }
|
||||
|
||||
[Option(DefaultValue = "mongodb://localhost:27017/PemukulPaku")]
|
||||
string DatabaseUri { get; }
|
||||
|
||||
[Option]
|
||||
IGameserver Gameserver { get; }
|
||||
|
||||
[Option]
|
||||
IHttp Http { get; }
|
||||
|
||||
public interface IGameserver
|
||||
{
|
||||
[Option(DefaultValue = "127.0.0.1")]
|
||||
public string Host { get; }
|
||||
|
||||
[Option(DefaultValue = (uint)(16100))]
|
||||
public uint Port { get; }
|
||||
|
||||
[Option(DefaultValue = "overseas01")]
|
||||
public string RegionName { get; }
|
||||
}
|
||||
|
||||
public interface IHttp
|
||||
{
|
||||
|
||||
[Option(DefaultValue = (uint)(80))]
|
||||
public uint HttpPort { get; }
|
||||
|
||||
[Option(DefaultValue = (uint)(443))]
|
||||
public uint HttpsPort { get; }
|
||||
}
|
||||
}
|
||||
|
||||
public enum VerboseLevel
|
||||
{
|
||||
Normal = 0,
|
||||
Debug = 1
|
||||
Errors = 0,
|
||||
Warns = 1,
|
||||
Debug = 2
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user