Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge XPEvo fixed/changes into main repository #317

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4bb9894
Merge XPEvo repo without ContactAdmin, ServerSync and Toornament modules
Chris92de Oct 22, 2024
7cb9c3c
Re-enable SmallScoresTable default visibility
Chris92de Oct 22, 2024
01fe467
Update example docker-compose.yml and README.md
Chris92de Oct 22, 2024
a25b27b
Fix RoundRankingModule test
Chris92de Oct 22, 2024
61b1069
Typo
araszka Oct 27, 2024
d8a4954
Remove debug controller
araszka Oct 27, 2024
448d130
Add display winner during teams mode in RoundRankingModule
araszka Nov 2, 2024
70d71d3
Update `docker/docker-compose.yml` to add build parameter
Chris92de Nov 5, 2024
88b401f
Update src/Modules/RoundRankingModule/Config/IRoundRankingSettings.cs
araszka Nov 9, 2024
baaadb1
Add doc comments to CheckpointData
araszka Nov 9, 2024
ed5524e
Use ConcurrentDictionary instead of default dictionary with mutex
araszka Nov 9, 2024
826ff13
Update doc comment
araszka Nov 9, 2024
0aebb70
Add CheckpointsRepository doc comments
araszka Nov 9, 2024
edc2c04
Add PointsRepartition doc comments
araszka Nov 9, 2024
2b3822d
Remove empty continuation line from Dockerfile
araszka Nov 9, 2024
0f53789
Merge remote-tracking branch 'origin/316-merge-xpevo-fixes-into-main-…
araszka Nov 9, 2024
d3fd641
Make ConcurrentDictionary thread safe
araszka Nov 9, 2024
041b00e
Improve concurrent property access in RoundRankingService
araszka Nov 9, 2024
bc80da3
Move utility methods from service to own class
araszka Nov 9, 2024
5e0321b
Add helper methods to CheckpointData for cleaner widget templates
araszka Nov 9, 2024
6dec31e
Add CheckpointData tests
araszka Nov 17, 2024
e03896a
Add round ranking controller tests
araszka Nov 17, 2024
b67347a
Add checkpoint repository tests
araszka Nov 17, 2024
d3f7de8
Add points repartition tests
araszka Nov 17, 2024
0975589
Add rank ranking utils tests
araszka Nov 17, 2024
301b9dc
Add round ranking service tests
araszka Nov 17, 2024
4e6f848
Add ScoreboardNicknameUtils and outsource utility methods from main s…
araszka Nov 30, 2024
e3a5ef7
Add ScoreboardStateService and outsource methods from ScoreboardService
araszka Nov 30, 2024
0fc9c43
Replace usage of volatile in RoundRankingService with locks
araszka Nov 30, 2024
699c66c
Replace decimal numbers in templates with float values
araszka Nov 30, 2024
712e7fb
Revert "Replace decimal numbers in templates with float values"
araszka Nov 30, 2024
26141b0
Move large maniascripts to separate file
araszka Nov 30, 2024
54d4b14
Improve code maintainability
araszka Dec 1, 2024
cf2fb60
Fix round ranking row template
araszka Dec 1, 2024
75130f5
Replace whole decimal numbers with f annotation
araszka Dec 1, 2024
84d79b8
Use style class for textsize where applicable in scoreboard templates
araszka Dec 1, 2024
29de2ea
Merge branch 'master' into 316-merge-xpevo-fixes-into-main-repository
araszka Dec 1, 2024
7e4a718
Add ScoreboardNicknameServiceTests
araszka Dec 1, 2024
aca38fb
Merge remote-tracking branch 'origin/316-merge-xpevo-fixes-into-main-…
araszka Dec 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ COPY . .

RUN dotnet publish "src/EvoSC/EvoSC.csproj" -r linux-musl-x64 --self-contained true -c Release -o /publish

# Set user & permissions
FROM alpine:latest as run-chown

WORKDIR /app
COPY --from=build /publish .
RUN true \
&& chown 9999:9999 -R /app \
&& true

# Create the image
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine3.20 as create-image

Expand All @@ -35,12 +26,21 @@ LABEL org.opencontainers.image.title="EvoSC#" \
org.opencontainers.image.revision=${REVISION}

WORKDIR /app
COPY --from=run-chown /app .

RUN true \
&& set -eux \
&& addgroup -g 9999 evosc \
&& adduser -u 9999 -Hh /app -G evosc -s /sbin/nologin -D evosc \
&& install -d -o evosc -g evosc -m 775 /app \
&& apk add --no-cache icu-libs \
&& adduser --disabled-password --home /app -u 9999 evosc \
&& true \
&& true

RUN true \
&& chown evosc:evosc -Rf /app \
&& true

COPY --from=build --chown=evosc:evosc /publish /app

USER evosc
ENTRYPOINT ["./EvoSC", "run"]

ENTRYPOINT ["./EvoSC", "run"]
23 changes: 22 additions & 1 deletion EvoSC.sln
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatchTrackerModule", "src\M
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatchReadyModule", "src\Modules\MatchReadyModule\MatchReadyModule.csproj", "{0538B9AB-B556-45BF-8230-53087BA9D353}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scoreboard", "src\Modules\Scoreboard\Scoreboard.csproj", "{CD032D37-3BC8-4DE8-8C5B-45A0DE36932E}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScoreboardModule", "src\Modules\ScoreboardModule\ScoreboardModule.csproj", "{CD032D37-3BC8-4DE8-8C5B-45A0DE36932E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NextMapModule", "src\Modules\NextMapModule\NextMapModule.csproj", "{64688FA7-136C-4BB9-B716-4E96DD0AA82F}"
EndProject
Expand Down Expand Up @@ -148,6 +148,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpectatorCamModeModule", "s
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpectatorCamModeModule.Tests", "tests\Modules\SpectatorCamModeModule.Tests\SpectatorCamModeModule.Tests.csproj", "{09A88256-8008-4085-A8E6-CA6DEFAC63E3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RoundRankingModule", "src\Modules\RoundRankingModule\RoundRankingModule.csproj", "{41FD20E7-5064-425F-B110-CEBD53F80ECA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RoundRankingModule.Tests", "tests\Modules\RoundRankingModule.Tests\RoundRankingModule.Tests.csproj", "{2623A6E2-125F-49B5-B8E1-5883B6E36C1A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScoreboardModule.Tests", "tests\Modules\ScoreboardModule.Tests\ScoreboardModule.Tests.csproj", "{99C2D889-4F35-41D7-8CAB-7F3760D811FD}"
EndProject



Expand Down Expand Up @@ -447,6 +453,18 @@ Global
{09A88256-8008-4085-A8E6-CA6DEFAC63E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{09A88256-8008-4085-A8E6-CA6DEFAC63E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{09A88256-8008-4085-A8E6-CA6DEFAC63E3}.Release|Any CPU.Build.0 = Release|Any CPU
{41FD20E7-5064-425F-B110-CEBD53F80ECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41FD20E7-5064-425F-B110-CEBD53F80ECA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41FD20E7-5064-425F-B110-CEBD53F80ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41FD20E7-5064-425F-B110-CEBD53F80ECA}.Release|Any CPU.Build.0 = Release|Any CPU
{2623A6E2-125F-49B5-B8E1-5883B6E36C1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2623A6E2-125F-49B5-B8E1-5883B6E36C1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2623A6E2-125F-49B5-B8E1-5883B6E36C1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2623A6E2-125F-49B5-B8E1-5883B6E36C1A}.Release|Any CPU.Build.0 = Release|Any CPU
{99C2D889-4F35-41D7-8CAB-7F3760D811FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99C2D889-4F35-41D7-8CAB-7F3760D811FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99C2D889-4F35-41D7-8CAB-7F3760D811FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99C2D889-4F35-41D7-8CAB-7F3760D811FD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -517,5 +535,8 @@ Global
{E4BF17BE-A517-4D3C-8DCA-DA99A100EBFE} = {6D75D6A2-6ECD-4DE4-96C5-CAD7D134407A}
{E9806703-6E24-4F05-A728-A04F7EB31749} = {DC47658A-F421-4BA4-B617-090A7DFB3900}
{09A88256-8008-4085-A8E6-CA6DEFAC63E3} = {6D75D6A2-6ECD-4DE4-96C5-CAD7D134407A}
{41FD20E7-5064-425F-B110-CEBD53F80ECA} = {DC47658A-F421-4BA4-B617-090A7DFB3900}
{2623A6E2-125F-49B5-B8E1-5883B6E36C1A} = {6D75D6A2-6ECD-4DE4-96C5-CAD7D134407A}
{99C2D889-4F35-41D7-8CAB-7F3760D811FD} = {6D75D6A2-6ECD-4DE4-96C5-CAD7D134407A}
EndGlobalSection
EndGlobal
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,21 @@ For a roadmap of planned features and what we're currently working on, have a lo
* **DO NOT USE IN A PRODUCTION SCENARIO, THE SOFTWARE IS STILL HEAVILY IN DEVELOPMENT.**
* **DO NOT ASK FOR ASSISTANCE IN USING THE SOFTWARE IN ITS UNFINISHED STATE.**

## Installation with Docker

> [!WARNING]
> EvoSC# is pre-release software. It is not recommended to be used in production environments yet.
>
> Please continue only if you know what you're doing.

Refer to our example [docker-compose.yml](https://github.com/EvoEsports/EvoSC-sharp/blob/master/docker/docker-compose.yml) file.
An (incomplete) list of available environment variables can be found [here](https://github.com/EvoEsports/EvoSC-sharp/blob/master/docker/evosc.env.example).

## Developing for EvoSC#

> [!WARNING]
> The setup below is strictly meant for development purposes and does not reflect best practices on how to use EvoSC# in a production setting.

To setup a development environment for EvoSC#, we recommend having Docker installed and using the following Docker Compose template.
It sets up a TM2020 dedicated server for you as well as all the required other services.

Expand All @@ -46,9 +59,9 @@ services:
- 2350:2350/tcp
- "5001:5000/tcp" # Be careful opening XMLRPC! Only if you really need to.
environment:
MASTER_LOGIN: "CHANGEME :)" # Create server credentials at https://www.trackmania.com/player/dedicated-servers
MASTER_PASSWORD: "CHANGEME :)" # Create server credentials at https://www.trackmania.com/player/dedicated-servers
XMLRPC_ALLOWREMOTE: "True"
TM_MASTERSERVER_LOGIN: "CHANGEME :)" # Create server credentials at https://www.trackmania.com/player/dedicated-servers
TM_MASTERSERVER_PASSWORD: "CHANGEME :)" # Create server credentials at https://www.trackmania.com/player/dedicated-servers
TM_SYSTEM_XMLRPC_ALLOWREMOTE: "True"
volumes:
- UserData:/server/UserData
db:
Expand Down
14 changes: 9 additions & 5 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ services:
- 2350:2350/udp
- 2350:2350/tcp
environment:
- MASTER_LOGIN=
- MASTER_PASSWORD=
- XMLRPC_ALLOWREMOTE=True
- TM_MASTERSERVER_LOGIN=
- TM_MASTERSERVER_PASSWORD=
- TM_SYSTEM_XMLRPC_ALLOWREMOTE=True
volumes:
- UserData:/server/UserData

Expand All @@ -19,9 +19,12 @@ services:
- POSTGRES_PASSWORD=evosc_sharp
- POSTGRES_USER=evosc_sharp
- POSTGRES_DB=evosc_sharp

evosc_sharp:
image: evoscsharp:latest
image: evoscsharp
build:
context: .
dockerfile: ../Dockerfile
restart: always
depends_on:
- trackmania
Expand All @@ -32,6 +35,7 @@ services:
- EVOSC_DATABASE_USERNAME=evosc_sharp
- EVOSC_DATABASE_PASSWORD=evosc_sharp
- EVOSC_SERVER_HOST=trackmania
- EVOSC_PATH_MAPS=/server/UserData/Maps
volumes:
- UserData:/server/UserData

Expand Down
33 changes: 12 additions & 21 deletions src/EvoSC/EvoSC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,37 @@
<ProjectReference Include="..\EvoSC.CLI\EvoSC.CLI.csproj" />
<ProjectReference Include="..\EvoSC.Manialinks\EvoSC.Manialinks.csproj" />
<ProjectReference Include="..\EvoSC.Modules\EvoSC.Modules.csproj" />
<ProjectReference Include="..\Modules\ASayModule\ASayModule.csproj" />
<ProjectReference Include="..\Modules\CurrentMapModule\CurrentMapModule.csproj" />
<ProjectReference Include="..\Modules\ExampleModule\ExampleModule.csproj" />
<ProjectReference Include="..\Modules\FastestCpModule\FastestCpModule.csproj" />
<ProjectReference Include="..\Modules\ForceTeamModule\ForceTeamModule.csproj" />
<ProjectReference Include="..\Modules\GameModeUiModule\GameModeUiModule.csproj" />
<ProjectReference Include="..\Modules\LiveRankingModule\LiveRankingModule.csproj" />
<ProjectReference Include="..\Modules\LocalRecordsModule\LocalRecordsModule.csproj" />
<ProjectReference Include="..\Modules\MapListModule\MapListModule.csproj" />
<ProjectReference Include="..\Modules\MapQueueModule\MapQueueModule.csproj" />
<ProjectReference Include="..\Modules\MatchRankingModule\MatchRankingModule.csproj" />
<ProjectReference Include="..\Modules\MatchReadyModule\MatchReadyModule.csproj" />
<ProjectReference Include="..\Modules\MatchTrackerModule\MatchTrackerModule.csproj" />
<ProjectReference Include="..\Modules\NextMapModule\NextMapModule.csproj" />
<ProjectReference Include="..\Modules\Scoreboard\Scoreboard.csproj" />
<ProjectReference Include="..\Modules\MapsModule\MapsModule.csproj" />
<ProjectReference Include="..\Modules\MatchManagerModule\MatchManagerModule.csproj" />
<ProjectReference Include="..\Modules\MatchReadyModule\MatchReadyModule.csproj" />
<ProjectReference Include="..\Modules\MatchTrackerModule\MatchTrackerModule.csproj" />
<ProjectReference Include="..\Modules\LiveRankingModule\LiveRankingModule.csproj" />
<ProjectReference Include="..\Modules\MatchRankingModule\MatchRankingModule.csproj" />
<ProjectReference Include="..\Modules\MatchReadyModule\MatchReadyModule.csproj" />
<ProjectReference Include="..\Modules\MatchTrackerModule\MatchTrackerModule.csproj" />
<ProjectReference Include="..\Modules\ModuleManagerModule\ModuleManagerModule.csproj" />
<ProjectReference Include="..\Modules\MotdModule\MotdModule.csproj" />
<ProjectReference Include="..\Modules\NextMapModule\NextMapModule.csproj" />
<ProjectReference Include="..\Modules\Scoreboard\Scoreboard.csproj" />
<ProjectReference Include="..\Modules\MapsModule\MapsModule.csproj" />
<ProjectReference Include="..\Modules\MatchManagerModule\MatchManagerModule.csproj" />
<ProjectReference Include="..\Modules\ASayModule\ASayModule.csproj" />
<ProjectReference Include="..\Modules\OpenPlanetModule\OpenPlanetModule.csproj" />
<ProjectReference Include="..\Modules\Player\Player.csproj" />
<ProjectReference Include="..\Modules\PlayerRecords\PlayerRecords.csproj" />
<ProjectReference Include="..\Modules\RoundRankingModule\RoundRankingModule.csproj" />
<ProjectReference Include="..\Modules\ScoreboardModule\ScoreboardModule.csproj" />
<ProjectReference Include="..\Modules\ServerManagementModule\ServerManagementModule.csproj" />
<ProjectReference Include="..\Modules\SetName\SetName.csproj" />
<ProjectReference Include="..\Modules\SpectatorCamModeModule\SpectatorCamModeModule.csproj" />
<ProjectReference Include="..\Modules\SpectatorTargetInfoModule\SpectatorTargetInfoModule.csproj" />
<ProjectReference Include="..\Modules\TeamChatModule\TeamChatModule.csproj" />
<ProjectReference Include="..\Modules\TeamInfoModule\TeamInfoModule.csproj" />
<ProjectReference Include="..\Modules\TeamSettingsModule\TeamSettingsModule.csproj" />
<ProjectReference Include="..\Modules\GameModeUiModule\GameModeUiModule.csproj" />
<ProjectReference Include="..\Modules\WorldRecordModule\WorldRecordModule.csproj" />
<ProjectReference Include="..\Modules\MotdModule\MotdModule.csproj" />
<ProjectReference Include="..\Modules\Player\Player.csproj" />
<ProjectReference Include="..\Modules\PlayerRecords\PlayerRecords.csproj" />
<ProjectReference Include="..\Modules\SetName\SetName.csproj" />
<ProjectReference Include="..\Modules\FastestCpModule\FastestCpModule.csproj" />
<ProjectReference Include="..\Modules\CurrentMapModule\CurrentMapModule.csproj" />
<ProjectReference Include="..\Modules\OpenPlanetModule\OpenPlanetModule.csproj" />
<ProjectReference Include="..\Modules\ModuleManagerModule\ModuleManagerModule.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/EvoSC/InternalModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
using EvoSC.Modules.Official.OpenPlanetModule;
using EvoSC.Modules.Official.Player;
using EvoSC.Modules.Official.PlayerRecords;
using EvoSC.Modules.Official.Scoreboard;
using EvoSC.Modules.Official.RoundRankingModule;
using EvoSC.Modules.Official.ScoreboardModule;
using EvoSC.Modules.Official.ServerManagementModule;
using EvoSC.Modules.Official.SetName;
using EvoSC.Modules.Official.SpectatorCamModeModule;
Expand Down Expand Up @@ -65,7 +66,8 @@ public static class InternalModules
typeof(TeamSettingsModule),
typeof(ServerManagementModule),
typeof(TeamInfoModule),
typeof(TeamChatModule)
typeof(TeamChatModule),
typeof(RoundRankingModule)
];

/// <summary>
Expand Down
15 changes: 15 additions & 0 deletions src/Modules/GameModeUiModule/Config/IGameModeUiModuleSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ public interface IGameModeUiModuleSettings

[Option(DefaultValue = 1.0), Description("The scale of the ScoresTable module.")]
public double ScoresTableScale { get; set; }

/*
* Settings for Race_SmallScoresTable
*/
[Option(DefaultValue = true), Description("The visibility of the SmallScoresTable module.")]
public bool SmallScoresTableVisible { get; set; }

[Option(DefaultValue = -160.0), Description("The x position of the SmallScoresTable module.")]
public double SmallScoresTableX { get; set; }

[Option(DefaultValue = 10.0), Description("The y position of the SmallScoresTable module.")]
public double SmallScoresTableY { get; set; }

[Option(DefaultValue = 1.0), Description("The scale of the SmallScoresTable module.")]
public double SmallScoresTableScale { get; set; }

/*
* Settings for Race_DisplayMessage
Expand Down
1 change: 1 addition & 0 deletions src/Modules/GameModeUiModule/Enums/GameModeUiComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public static class GameModeUiComponents
public static readonly string LapsCounter = "Race_LapsCounter";
public static readonly string TimeGap = "Race_TimeGap";
public static readonly string ScoresTable = "Race_ScoresTable";
public static readonly string SmallScoresTable = "Rounds_SmallScoresTable";
public static readonly string DisplayMessage = "Race_DisplayMessage";
public static readonly string Countdown = "Race_Countdown";
public static readonly string SpectatorBaseName = "Race_SpectatorBase_Name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ public List<GameModeUiComponentSettings> GetDefaultSettings()
settings.ScoresTableY,
settings.ScoresTableScale
),
new GameModeUiComponentSettings(
GameModeUiComponents.SmallScoresTable,
settings.SmallScoresTableVisible,
settings.SmallScoresTableX,
settings.SmallScoresTableY,
settings.SmallScoresTableScale
),
new GameModeUiComponentSettings(
GameModeUiComponents.DisplayMessage,
settings.DisplayMessageVisible,
Expand Down
28 changes: 28 additions & 0 deletions src/Modules/RoundRankingModule/Config/IRoundRankingSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.ComponentModel;
using Config.Net;
using EvoSC.Common.Util.Manialinks;
using EvoSC.Modules.Attributes;

namespace EvoSC.Modules.Official.RoundRankingModule.Config;

[Settings]
public interface IRoundRankingSettings
{
[Option(DefaultValue = WidgetPosition.Left)]
[Description("Specifies on which side the widget is displayed. Valid values are Left | Right.")]
public WidgetPosition Position { get; set; }

[Option(DefaultValue = 15.0), Description("Defines the Y position of the widget.")]
public double Y { get; set; }

[Option(DefaultValue = 8), Description("Limits the rows shown in the widget.")]
public int MaxRows { get; set; }

[Option(DefaultValue = false),
Description("Shows the time difference to the leading player instead of individual times.")]
public bool DisplayTimeDifference { get; set; }

[Option(DefaultValue = true),
Description("Shows the gained points once a player crosses the finish line.")]
public bool DisplayGainedPoints { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using EvoSC.Common.Controllers;
using EvoSC.Common.Controllers.Attributes;
using EvoSC.Common.Events.Attributes;
using EvoSC.Common.Interfaces.Controllers;
using EvoSC.Common.Remote;
using EvoSC.Common.Remote.EventArgsModels;
using EvoSC.Modules.Official.RoundRankingModule.Interfaces;

namespace EvoSC.Modules.Official.RoundRankingModule.Controllers;

[Controller]
public class RoundRankingEventController(IRoundRankingService roundRankingService)
: EvoScController<IEventControllerContext>
{
[Subscribe(ModeScriptEvent.WayPoint)]
public async Task OnWaypointAsync(object sender, WayPointEventArgs args)
{
await roundRankingService.ConsumeCheckpointAsync(
args.AccountId,
args.CheckpointInLap,
args.LapTime,
args.IsEndLap,
false
);
}

[Subscribe(ModeScriptEvent.GiveUp)]
public Task OnPlayerGiveUpAsync(object sender, PlayerUpdateEventArgs args) =>
roundRankingService.ConsumeDnfAsync(args.AccountId);

[Subscribe(ModeScriptEvent.EndRoundEnd)]
public Task OnEndRoundAsync(object sender, EventArgs args) =>
roundRankingService.ClearCheckpointDataAsync();

[Subscribe(ModeScriptEvent.WarmUpEndRound)]
public Task OnWarmUpEndRoundAsync(object sender, WarmUpRoundEventArgs args) =>
roundRankingService.ClearCheckpointDataAsync();

[Subscribe(ModeScriptEvent.StartMatchStart)]
public Task OnStartMatchAsync(object sender, MatchEventArgs args) =>
roundRankingService.ClearCheckpointDataAsync();

[Subscribe(ModeScriptEvent.StartLine)]
public Task OnStartLineAsync(object sender, PlayerUpdateEventArgs args) =>
roundRankingService.RemovePlayerCheckpointDataAsync(args.AccountId);

[Subscribe(ModeScriptEvent.Respawn)]
public Task OnRespawnAsync(object sender, PlayerUpdateEventArgs args) =>
roundRankingService.RemovePlayerCheckpointDataAsync(args.AccountId);

[Subscribe(ModeScriptEvent.PodiumStart)]
public Task OnPodiumStartAsync(object sender, EventArgs args) =>
roundRankingService.HideRoundRankingWidgetAsync();

[Subscribe(GbxRemoteEvent.BeginMap)]
public async Task OnStartMapAsync(object sender, EventArgs args)
{
await roundRankingService.DetectIsTeamsModeAsync();
await roundRankingService.FetchAndCacheTeamInfoAsync();
await roundRankingService.LoadPointsRepartitionFromSettingsAsync();
await roundRankingService.ClearCheckpointDataAsync();
}

[Subscribe(ModeScriptEvent.WarmUpStart)]
public Task OnWarmUpStartAsync(object sender, EventArgs args) =>
roundRankingService.SetIsTimeAttackModeAsync(true);

[Subscribe(ModeScriptEvent.WarmUpEnd)]
public Task OnWarmUpEndAsync(object sender, EventArgs args) =>
roundRankingService.SetIsTimeAttackModeAsync(false);
}
Loading
Loading