diff --git a/Common/Common.csproj b/Common/Common.csproj
index 50d105f..4ccc41d 100644
--- a/Common/Common.csproj
+++ b/Common/Common.csproj
@@ -9,6 +9,7 @@
+
diff --git a/Common/Database/AutoIncrement.cs b/Common/Database/AutoIncrement.cs
new file mode 100644
index 0000000..f01dab3
--- /dev/null
+++ b/Common/Database/AutoIncrement.cs
@@ -0,0 +1,28 @@
+using Common.Resources.Proto;
+using MongoDB.Bson.Serialization.Attributes;
+using MongoDB.Bson;
+using MongoDB.Driver;
+
+namespace Common.Database
+{
+ public class AutoIncrement
+ {
+ public static readonly IMongoCollection collection = Global.db.GetCollection("AutoIncrements");
+
+ public static int GetNextNumber(string name, int starting = 100)
+ {
+ AI AutoIncrement = collection.FindOneAndUpdate(Builders.Filter.Eq("Name", name), Builders.Update.SetOnInsert("Count", starting), new FindOneAndUpdateOptions { IsUpsert = true, ReturnDocument = ReturnDocument.After });
+ collection.UpdateOne(Builders.Filter.Eq("Name", AutoIncrement.Name), Builders.Update.Inc("Count", 1));
+ return AutoIncrement.Count + 1;
+ }
+
+#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+ public class AI
+ {
+ public ObjectId Id { get; set; }
+ public string Name { get; set; }
+ public int Count { get; set; }
+ }
+#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+ }
+}
diff --git a/Common/Database/User.cs b/Common/Database/User.cs
index c146adc..52c1b1d 100644
--- a/Common/Database/User.cs
+++ b/Common/Database/User.cs
@@ -14,14 +14,14 @@ namespace Common.Database
UserScheme user = new()
{
Name = name,
- Uid = 1001,
+ Uid = (uint)AutoIncrement.GetNextNumber("UID", 1000),
Nick = "",
Exp = 0,
Hcoin = 0,
Stamina = 80,
SelfDesc = "",
IsFirstLogin = true,
- Token = Guid.NewGuid(),
+ Token = Guid.NewGuid().ToString(),
WarshipId = 0,
WarshipAvatar = new WarshipAvatarData()
{
@@ -39,6 +39,18 @@ namespace Common.Database
return user;
}
+ public static UserScheme FromName(string name)
+ {
+ UserScheme? user = collection.AsQueryable().Where(d => d.Name == name).FirstOrDefault();
+ return user ?? CreateUser(name);
+ }
+
+ public static UserScheme? FromToken(string token)
+ {
+ UserScheme? user = collection.AsQueryable().Where(d => d.Token == token).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
{
@@ -51,9 +63,7 @@ namespace Common.Database
public int Stamina { get; set; }
public string SelfDesc { get; set; }
public bool IsFirstLogin { get; set; }
-
- [BsonGuidRepresentation(GuidRepresentation.Standard)]
- public Guid Token { get; set; }
+ public string Token { get; set; }
public int WarshipId { get; set; }
public WarshipAvatarData WarshipAvatar { get; set; }
public int AssistantAvatarId { get; set; }
diff --git a/Common/Program.cs b/Common/Program.cs
index c6568fc..a367ad5 100644
--- a/Common/Program.cs
+++ b/Common/Program.cs
@@ -19,7 +19,10 @@ namespace Common
[Option(DefaultValue = false)]
bool UseLocalCache { get; }
-
+
+ [Option(DefaultValue = true)]
+ bool CreateAccountOnLoginAttempt { get; }
+
[Option(DefaultValue = "mongodb://localhost:27017/PemukulPaku")]
string DatabaseUri { get; }
@@ -32,7 +35,7 @@ namespace Common
public interface IGameserver
{
[Option(DefaultValue = "127.0.0.1")]
- public string Host { get; }
+ public string Host { get; set; }
[Option(DefaultValue = (uint)(16100))]
public uint Port { get; }
diff --git a/HttpServer/Controllers/AccountController.cs b/HttpServer/Controllers/AccountController.cs
new file mode 100644
index 0000000..ec28b64
--- /dev/null
+++ b/HttpServer/Controllers/AccountController.cs
@@ -0,0 +1,170 @@
+using Newtonsoft.Json;
+using HttpServer.Models;
+using Common.Database;
+using Newtonsoft.Json.Linq;
+
+namespace HttpServer.Controllers
+{
+ public class AccountController
+ {
+ public static void AddHandlers(WebApplication app)
+ {
+ app.Map("/account/risky/api/check", (HttpContext ctx) =>
+ {
+ RiskyCheck rsp = new()
+ {
+ Retcode = 0,
+ Message = "",
+ Data = new RiskyCheck.DataScheme()
+ {
+ Id = "",
+ Action = "ACTION_NONE",
+ Geetest = null
+ }
+ };
+
+ ctx.Response.Headers.Add("Content-Type", "application/json");
+
+ return ctx.Response.WriteAsync(JsonConvert.SerializeObject(rsp));
+ });
+
+#pragma warning disable CS8600, CS8602 // Converting null literal or possible null value to non-nullable type.
+ app.MapPost("/{game_biz}/combo/granter/login/v2/login", (ctx) =>
+ {
+ StreamReader Reader = new(ctx.Request.Body);
+ GranterLoginBody Data = JsonConvert.DeserializeObject(Reader.ReadToEndAsync().Result);
+ GranterLoginBody.GranterLoginBodyData GranterLoginData = JsonConvert.DeserializeObject(Data.Data);
+
+
+ return ctx.Response.WriteAsJsonAsync(new
+ {
+ retcode = 0,
+ message = "OK",
+ data = new {
+ combo_id = "0",
+ open_id = GranterLoginData.Uid,
+ combo_token = GranterLoginData.Token,
+ data = JsonConvert.SerializeObject(new
+ {
+ guest = GranterLoginData.Guest
+ }),
+ heartbeat = false,
+ account_type = 1,
+ }
+ });
+ });
+
+ app.MapPost("/{game_biz}/mdk/shield/api/verify", (ctx) =>
+ {
+ StreamReader Reader = new(ctx.Request.Body);
+ ShieldVerifyBody Data = JsonConvert.DeserializeObject(Reader.ReadToEndAsync().Result);
+ User.UserScheme? user = User.FromToken(Data.Token);
+
+ ShieldLoginResponse rsp = new()
+ {
+ Retcode = 0,
+ Message = "OK",
+ Data = new()
+ {
+ Account = null
+ }
+ };
+
+ if (user != null)
+ {
+ rsp.Data = new()
+ {
+ Account = new()
+ {
+ Uid = user.Uid,
+ Name = user.Name,
+ Email = "",
+ Mobile = "",
+ IsEmailVerify = "0",
+ Realname = "",
+ IdentityCard = "",
+ Token = user.Token.ToString(),
+ SafeMobile = "",
+ FacebookName = "",
+ GoogleName = "",
+ TwitterName = "",
+ GameCenterName = "",
+ AppleName = "",
+ SonyName = "",
+ TapName = "",
+ Country = "SG",
+ ReactivateTicket = "",
+ AreaCode = "**",
+ DeviceGrantTicket = "",
+ SteamName = "",
+ UnmaskedEmail = "",
+ UnmaskedEmailType = 0
+ },
+ DeviceGrantRequired = false,
+ SafeMoblieRequired = false,
+ RealpersonRequired = false,
+ ReactivateRequired = false,
+ RealnameOperation = "None"
+ };
+ }
+
+ ctx.Response.Headers.Add("Content-Type", "application/json");
+
+ return ctx.Response.WriteAsync(JsonConvert.SerializeObject(rsp));
+ });
+
+ app.MapPost("/{game_biz}/mdk/shield/api/login", (ctx) =>
+ {
+ StreamReader Reader = new(ctx.Request.Body);
+ ShieldLoginBody Data = JsonConvert.DeserializeObject(Reader.ReadToEndAsync().Result);
+
+ User.UserScheme user = User.FromName(Data.Account);
+
+ ShieldLoginResponse rsp = new()
+ {
+ Retcode = 0,
+ Message = "OK",
+ Data = new()
+ {
+ Account = new()
+ {
+ Uid = user.Uid,
+ Name = user.Name,
+ Email = "",
+ Mobile = "",
+ IsEmailVerify = "0",
+ Realname = "",
+ IdentityCard = "",
+ Token = user.Token.ToString(),
+ SafeMobile = "",
+ FacebookName = "",
+ GoogleName = "",
+ TwitterName = "",
+ GameCenterName = "",
+ AppleName = "",
+ SonyName = "",
+ TapName = "",
+ Country = "**",
+ ReactivateTicket = "",
+ AreaCode = "**",
+ DeviceGrantTicket = "",
+ SteamName = "",
+ UnmaskedEmail = "",
+ UnmaskedEmailType = 0
+ },
+ DeviceGrantRequired = false,
+ SafeMoblieRequired = false,
+ RealpersonRequired = false,
+ ReactivateRequired = false,
+ RealnameOperation = "None"
+ }
+ };
+
+ ctx.Response.Headers.Add("Content-Type", "application/json");
+
+ return ctx.Response.WriteAsync(JsonConvert.SerializeObject(rsp));
+ });
+#pragma warning restore CS8600, CS8602 // Converting null literal or possible null value to non-nullable type.
+ }
+ }
+}
diff --git a/HttpServer/Controllers/ConfigController.cs b/HttpServer/Controllers/ConfigController.cs
new file mode 100644
index 0000000..08cf991
--- /dev/null
+++ b/HttpServer/Controllers/ConfigController.cs
@@ -0,0 +1,226 @@
+using Common;
+using HttpServer.Models;
+using Newtonsoft.Json;
+
+namespace HttpServer.Controllers
+{
+ public class ConfigController
+ {
+ public static void AddHandlers(WebApplication app)
+ {
+ app.Map("/{game_biz}/mdk/agreement/api/getAgreementInfos", (HttpContext ctx) =>
+ {
+ return ctx.Response.WriteAsJsonAsync(new { retcode = 0, message = "OK", data = new { marketing_agreements = Array.Empty