Skip to content

Commit

Permalink
Initial work on LR
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS committed Feb 9, 2024
1 parent 0b40f00 commit abf85fe
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Jailbreak.sln
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jailbreak.Logs", "mod\Jailb
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jailbreak.Debug", "mod\Jailbreak.Debug\Jailbreak.Debug.csproj", "{4F10E2B5-E8BB-4253-9BE6-9187575ADB13}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jailbreak.LastRequest", "mod\Jailbreak.LastRequest\Jailbreak.LastRequest.csproj", "{5D222C0F-65AC-4663-AD73-06E6BA4A470F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -74,6 +76,10 @@ Global
{4F10E2B5-E8BB-4253-9BE6-9187575ADB13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F10E2B5-E8BB-4253-9BE6-9187575ADB13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4F10E2B5-E8BB-4253-9BE6-9187575ADB13}.Release|Any CPU.Build.0 = Release|Any CPU
{5D222C0F-65AC-4663-AD73-06E6BA4A470F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5D222C0F-65AC-4663-AD73-06E6BA4A470F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D222C0F-65AC-4663-AD73-06E6BA4A470F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D222C0F-65AC-4663-AD73-06E6BA4A470F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9135CCC9-66C5-4A9C-AE3C-91475B5F0437} = {177DA48D-8306-4102-918D-992569878581}
Expand All @@ -86,5 +92,6 @@ Global
{CB2391A1-6CDD-496F-B8D6-674FD6268038} = {36BA84C0-291C-4930-A7C6-97CDF8F7F0D7}
{CE6EC648-E7F9-4CE7-B28F-8C7995830F35} = {36BA84C0-291C-4930-A7C6-97CDF8F7F0D7}
{4F10E2B5-E8BB-4253-9BE6-9187575ADB13} = {36BA84C0-291C-4930-A7C6-97CDF8F7F0D7}
{5D222C0F-65AC-4663-AD73-06E6BA4A470F} = {36BA84C0-291C-4930-A7C6-97CDF8F7F0D7}
EndGlobalSection
EndGlobal
13 changes: 13 additions & 0 deletions mod/Jailbreak.LastRequest/Jailbreak.LastRequest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\public\Jailbreak.Public\Jailbreak.Public.csproj" />
</ItemGroup>

</Project>
27 changes: 27 additions & 0 deletions mod/Jailbreak.LastRequest/LastRequestService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using CounterStrikeSharp.API.Core;
using Jailbreak.Public.Mod.LastRequest;

namespace Jailbreak.LastRequest;

public class LastRequestService : ILastRequestService
{
public bool IsLastRequestActive()
{
throw new NotImplementedException();
}

public bool SetLastRequestActive(bool lastRequest)
{
throw new NotImplementedException();
}

public AbstractLastRequest? GetLastRequest(CCSPlayerController player)
{
throw new NotImplementedException();
}

public bool SetLastRequest(CCSPlayerController player, AbstractLastRequest lastRequest)
{
throw new NotImplementedException();
}
}
12 changes: 12 additions & 0 deletions mod/Jailbreak.LastRequest/LastRequestServiceExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Jailbreak.Public.Mod.LastRequest;
using Microsoft.Extensions.DependencyInjection;

namespace Jailbreak.LastRequest;

public static class LastRequestServiceExtension
{
public static void AddJailbreakLastRequest(this IServiceCollection services)
{
services.AddPluginBehavior<ILastRequestService, LastRequestService>();

Check failure on line 10 in mod/Jailbreak.LastRequest/LastRequestServiceExtension.cs

View workflow job for this annotation

GitHub Actions / build

'IServiceCollection' does not contain a definition for 'AddPluginBehavior' and no accessible extension method 'AddPluginBehavior' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in mod/Jailbreak.LastRequest/LastRequestServiceExtension.cs

View workflow job for this annotation

GitHub Actions / build

'IServiceCollection' does not contain a definition for 'AddPluginBehavior' and no accessible extension method 'AddPluginBehavior' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)
}
}
15 changes: 15 additions & 0 deletions mod/Jailbreak.LastRequest/LastRequests/OneOnOne/WeaponFight.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using CounterStrikeSharp.API.Core;
using Jailbreak.Public.Mod.LastRequest;

namespace Jailbreak.LastRequest.LastRequests.OneOnOne;

public class WeaponFight : AbstractLastRequest
{
public WeaponFight(BasePlugin plugin, CCSPlayerController prisoner, CCSPlayerController guard) : base(plugin, prisoner, guard)
{
}
protected override void OnStart()
{
throw new NotImplementedException();
}
}
50 changes: 50 additions & 0 deletions public/Jailbreak.Public/Mod/LastRequest/AbstractLastRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;

namespace Jailbreak.Public.Mod.LastRequest;

public abstract class AbstractLastRequest : IPluginBehavior
{
public string Name { get; }
public LastRequestState State { get; protected set; }
public LastRequestCategory Category { get; }

protected Dictionary<Type, LastRequestOptions> options = new ();

protected ISet<CCSPlayerController> members;
protected BasePlugin plugin;

protected AbstractLastRequest(BasePlugin plugin, CCSPlayerController prisoner, CCSPlayerController guard)

Check warning on line 19 in public/Jailbreak.Public/Mod/LastRequest/AbstractLastRequest.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
{
this.plugin = plugin;
members = new HashSet<CCSPlayerController> {prisoner, guard};
// options[GenericLastRequestOptions] = new GenericLastRequestOptions(this);
}

public void Start(long delay = 0)
{
plugin.AddTimer(delay, (() =>
{
OnStart();
}));
}

protected abstract void OnStart();

public ISet<CCSPlayerController> GetCTs()
{
return members.Where(x => x.GetTeam() == CsTeam.CounterTerrorist).ToHashSet();
}

public ISet<CCSPlayerController> GetTs()
{
return members.Where(x => x.GetTeam() == CsTeam.Terrorist).ToHashSet();
}

public CCSPlayerController GetT()
{
return GetTs().First();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Jailbreak.Public.Mod.LastRequest;

public class GenericLastRequestOptions : LastRequestOptions
{
public GenericLastRequestOptions(AbstractLastRequest baseRequest) : base(baseRequest)
{
}

public override void GetOptions()
{
}

public int GetMaxTime()
{
return 60;
}
}
18 changes: 18 additions & 0 deletions public/Jailbreak.Public/Mod/LastRequest/ILastRequestService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using CounterStrikeSharp.API.Core;

namespace Jailbreak.Public.Mod.LastRequest;

public interface ILastRequestService
{
bool IsLastRequestActive();
bool SetLastRequestActive(bool lastRequest);

bool IsInLastRequest(CCSPlayerController player)
{
return GetLastRequest(player) == null;
}

AbstractLastRequest? GetLastRequest(CCSPlayerController player);
bool SetLastRequest(CCSPlayerController player, AbstractLastRequest lastRequest);

}
10 changes: 10 additions & 0 deletions public/Jailbreak.Public/Mod/LastRequest/LastRequestCategory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Jailbreak.Public.Mod.LastRequest;

public enum LastRequestCategory
{
COMBAT,
RANDOM,
TECHNICAL,
KNOWLEDGE,
OTHER
}
13 changes: 13 additions & 0 deletions public/Jailbreak.Public/Mod/LastRequest/LastRequestOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Jailbreak.Public.Mod.LastRequest;

public abstract class LastRequestOptions
{
protected AbstractLastRequest baseRequest;

public LastRequestOptions(AbstractLastRequest baseRequest)
{
this.baseRequest = baseRequest;
}

public abstract void GetOptions();
}
10 changes: 10 additions & 0 deletions public/Jailbreak.Public/Mod/LastRequest/LastRequestState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Jailbreak.Public.Mod.LastRequest;

public enum LastRequestState
{
BEGINNING, // Last Request has been announced, players might be frozen or waiting for guns
PLAYING, // Last Request is currently in progress, players should be actively playing (throwing he nades, knife
// fights, etc)
RUSHING, // Last Request is taking too long, we need to speed things up
ENDED // Last Request has ended, one of the players should be dead
}
1 change: 1 addition & 0 deletions src/Jailbreak/Jailbreak.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<ItemGroup>
<ProjectReference Include="..\..\lang\Jailbreak.English\Jailbreak.English.csproj" />
<ProjectReference Include="..\..\mod\Jailbreak.Debug\Jailbreak.Debug.csproj" />
<ProjectReference Include="..\..\mod\Jailbreak.LastRequest\Jailbreak.LastRequest.csproj" />
<ProjectReference Include="..\..\mod\Jailbreak.Teams\Jailbreak.Teams.csproj" />
<ProjectReference Include="..\..\mod\Jailbreak.Warden\Jailbreak.Warden.csproj" />
<ProjectReference Include="..\..\mod\Jailbreak.Rebel\Jailbreak.Rebel.csproj" />
Expand Down
2 changes: 2 additions & 0 deletions src/Jailbreak/JailbreakServiceCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Jailbreak.English.Warden;
using Jailbreak.Formatting.Logistics;
using Jailbreak.Generic;
using Jailbreak.LastRequest;
using Jailbreak.Logs;
using Jailbreak.Public.Configuration;
using Jailbreak.Rebel;
Expand All @@ -33,6 +34,7 @@ public void ConfigureServices(IServiceCollection serviceCollection)

serviceCollection.AddJailbreakGeneric();
serviceCollection.AddJailbreakLogs();
serviceCollection.AddJailbreakLastRequest();
serviceCollection.AddJailbreakWarden();
serviceCollection.AddJailbreakTeams();
serviceCollection.AddJailbreakRebel();
Expand Down

0 comments on commit abf85fe

Please sign in to comment.