-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathProgram.cs
70 lines (63 loc) · 2.59 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using FluentMigrator.Runner;
using FluentMigrator.Runner.Initialization;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using Serilog.Events;
using Vint.Core.Battles;
using Vint.Core.ChatCommands;
using Vint.Core.Config;
using Vint.Core.Database;
using Vint.Core.Database.Migrations;
using Vint.Core.Discord;
using Vint.Core.Quests;
using Vint.Core.Server;
using Vint.Core.Server.API;
using Vint.Core.Server.Game;
using Vint.Core.Server.Game.Protocol;
using Vint.Core.Server.Static;
using Vint.Core.Utils;
namespace Vint;
abstract class Program {
static async Task Main() {
LoggerUtils.Initialize(LogEventLevel.Information);
Log.Logger
.ForType<Program>()
.Information("Welcome to Vint!");
DatabaseConfig.Initialize();
await Task.WhenAll(Task.Run(ConfigManager.InitializeCache),
ConfigManager.InitializeMapInfos(),
ConfigManager.InitializeChatCensorship(),
Task.Run(async () => {
await ConfigManager.InitializeNodes();
await ConfigManager.InitializeConfigs();
await ConfigManager.InitializeGlobalEntities();
}));
IServiceProvider serviceProvider = new ServiceCollection()
.AddLogging(builder => builder.AddSerilog())
.AddFluentMigratorCore()
.ConfigureRunner(builder => builder
.AddMySql8()
.WithGlobalConnectionString(DatabaseConfig.Get().ConnectionString)
.ScanIn(typeof(Initial).Assembly).For.Migrations()
)
.Configure<RunnerOptions>(opt => opt.AllowBreakingChange = false) // SET TO TRUE ONLY IF YOU'RE SURE THAT YOU WANT TO ALLOW BREAKING CHANGES TO THE DATABASE!
.AddSingleton<ApiServer>()
.AddSingleton<StaticServer>()
.AddSingleton<GameServer>()
.AddSingleton<DiscordBot>()
.AddSingleton<Runner>()
.AddSingleton<Protocol>()
.AddSingleton<QuestManager>()
.AddSingleton<IBattleProcessor, BattleProcessor>()
.AddSingleton<IArcadeProcessor, ArcadeProcessor>()
.AddSingleton<IMatchmakingProcessor, MatchmakingProcessor>()
.AddSingleton<IChatCommandProcessor>(serviceProvider => {
ChatCommandProcessor chatCommandProcessor = new(serviceProvider);
chatCommandProcessor.RegisterCommands();
return chatCommandProcessor;
})
.BuildServiceProvider();
Runner runner = serviceProvider.GetRequiredService<Runner>();
await runner.Run();
}
}