Skip to content

Commit

Permalink
Dev (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS authored Mar 25, 2024
2 parents 402ee13 + 4fbe210 commit 2a48394
Show file tree
Hide file tree
Showing 47 changed files with 1,931 additions and 21 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", "{D8952626-7B8D-4ABB-A3AE-FC81C688787B}"
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
{D8952626-7B8D-4ABB-A3AE-FC81C688787B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8952626-7B8D-4ABB-A3AE-FC81C688787B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8952626-7B8D-4ABB-A3AE-FC81C688787B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8952626-7B8D-4ABB-A3AE-FC81C688787B}.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}
{D8952626-7B8D-4ABB-A3AE-FC81C688787B} = {36BA84C0-291C-4930-A7C6-97CDF8F7F0D7}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Jailbreak.English.Generic;
public class GenericCommandNotifications : IGenericCommandNotifications, ILanguage<Formatting.Languages.English>
{
public static FormatObject PREFIX =
new HiddenFormatObject($" {ChatColors.Darkred}[{ChatColors.LightRed}JB{ChatColors.Darkred}]")
new HiddenFormatObject($" {ChatColors.DarkRed}[{ChatColors.LightRed}JB{ChatColors.DarkRed}]")
{
// Hide in panorama and center text
Plain = false,
Expand Down
89 changes: 89 additions & 0 deletions lang/Jailbreak.English/LastRequest/LastRequestMessages.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Base;
using Jailbreak.Formatting.Core;
using Jailbreak.Formatting.Logistics;
using Jailbreak.Formatting.Objects;
using Jailbreak.Formatting.Views;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;

namespace Jailbreak.English.LastRequest;

public class LastRequestMessages : ILastRequestMessages, ILanguage<Formatting.Languages.English>
{
public static FormatObject PREFIX =
new HiddenFormatObject($" {ChatColors.DarkRed}[{ChatColors.LightRed}LR{ChatColors.DarkRed}]")
{
// Hide in panorama and center text
Plain = false,
Panorama = false,
Chat = true
};

public IView LastRequestEnabled() => new SimpleView()
{
{ PREFIX, "Last Request has been enabled." }
};

public IView LastRequestDisabled() => new SimpleView()
{
{ PREFIX, "Last Request has been disabled." }
};

public IView LastRequestNotEnabled() => new SimpleView()
{
{ PREFIX, "Last Request is not enabled." }
};

public IView InvalidLastRequest(string query)
{
return new SimpleView()
{
PREFIX,
"Invalid Last Request: ",
query
};
}

public IView InvalidPlayerChoice(CCSPlayerController player, string reason)
{
return new SimpleView()
{
PREFIX,
"Invalid player choice: ",
player,
" Reason: ",
reason
};
}

public IView InformLastRequest(AbstractLastRequest lr)
{
return new SimpleView()
{
PREFIX,
lr.prisoner, "is preparing a", lr.type.ToFriendlyString(),
"Last Request against", lr.guard
};
}

public IView AnnounceLastRequest(AbstractLastRequest lr)
{
return new SimpleView()
{
PREFIX,
lr.prisoner, "is doing a", lr.type.ToFriendlyString(),
"Last Request against", lr.guard
};
}

public IView LastRequestDecided(AbstractLastRequest lr, LRResult result)
{
return new SimpleView()
{
PREFIX,
result == LRResult.PrisonerWin ? lr.prisoner : lr.guard, "won the LR."
};
}
}
2 changes: 1 addition & 1 deletion lang/Jailbreak.English/Rebel/RebelNotifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Jailbreak.English.Rebel;

public class RebelNotifications : IRebelNotifications, ILanguage<Formatting.Languages.English>
{
public static FormatObject PREFIX = new HiddenFormatObject($" {ChatColors.Darkred}[{ChatColors.LightRed}Rebel{ChatColors.Darkred}]")
public static FormatObject PREFIX = new HiddenFormatObject($" {ChatColors.DarkRed}[{ChatColors.LightRed}Rebel{ChatColors.DarkRed}]")
{
// Hide in panorama and center text
Plain = false,
Expand Down
38 changes: 38 additions & 0 deletions lang/Jailbreak.English/Warden/SpecialTreatmentNotifications.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;

using Jailbreak.Formatting.Base;
using Jailbreak.Formatting.Core;
using Jailbreak.Formatting.Logistics;
using Jailbreak.Formatting.Objects;
using Jailbreak.Formatting.Views;

namespace Jailbreak.English.Warden;

public class SpecialTreatmentNotifications : ISpecialTreatmentNotifications, ILanguage<Formatting.Languages.English>
{
public static FormatObject PREFIX = new HiddenFormatObject( $" {ChatColors.Lime}[{ChatColors.Green}ST{ChatColors.Lime}]" )
{
// Hide in panorama and center text
Plain = false,
Panorama = false,
Chat = true,
};

public IView GRANTED =>
new SimpleView { PREFIX, "You now have special treatment!" };

public IView REVOKED =>
new SimpleView { PREFIX, "Your special treatment was removed" };

public IView GRANTED_TO(CCSPlayerController player)
{
return new SimpleView { PREFIX, player, "now has Special Treatment!" };
}

public IView REVOKED_FROM(CCSPlayerController player)
{
return new SimpleView { PREFIX, player, "no longer has Special Treatment." };
}

}
7 changes: 7 additions & 0 deletions mod/Jailbreak.Debug/DebugCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ namespace Jailbreak.Debug;
public class DebugCommand : IPluginBehavior
{
private readonly Dictionary<string, AbstractCommand> _commands = new();
private BasePlugin plugin;

public void Start(BasePlugin parent)
{
plugin = parent;
}

public DebugCommand(IServiceProvider serviceProvider)
{
_commands.Add("markrebel", new MarkRebel(serviceProvider));
_commands.Add("pardon", new Pardon(serviceProvider));
_commands.Add("lr", new Subcommands.LastRequest(serviceProvider, plugin));
}


Expand Down
1 change: 1 addition & 0 deletions mod/Jailbreak.Debug/Jailbreak.Debug.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ItemGroup>
<ProjectReference Include="..\..\public\Jailbreak.Formatting\Jailbreak.Formatting.csproj"/>
<ProjectReference Include="..\..\public\Jailbreak.Public\Jailbreak.Public.csproj"/>
<ProjectReference Include="..\Jailbreak.LastRequest\Jailbreak.LastRequest.csproj" />
</ItemGroup>

</Project>
81 changes: 81 additions & 0 deletions mod/Jailbreak.Debug/Subcommands/LastRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Menu;
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.LastRequest;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;
using Microsoft.Extensions.DependencyInjection;

namespace Jailbreak.Debug.Subcommands;

public class LastRequest : AbstractCommand
{
private ILastRequestManager manager;
private LastRequestPlayerSelector playerSelector;
private LastRequestMenuSelector menuSelector;
private ILastRequestMessages _messages;
private IGenericCommandNotifications _generic;

private BasePlugin plugin;

public LastRequest(IServiceProvider services, BasePlugin plugin) : base(services)
{
this.plugin = plugin;
manager = services.GetRequiredService<ILastRequestManager>();
playerSelector = new LastRequestPlayerSelector(manager, true);
menuSelector = new LastRequestMenuSelector(services.GetRequiredService<ILastRequestFactory>(),
(type) => "css_debug lastrequest " + type);
_messages = services.GetRequiredService<ILastRequestMessages>();
_generic = services.GetRequiredService<IGenericCommandNotifications>();
}

// css_lastrequest [lr] [player] <target>
public override void OnCommand(CCSPlayerController? executor, WrappedInfo info)
{
if (executor != null && !executor.IsReal())
return;

if (info.ArgCount == 1 && executor != null)
{
MenuManager.OpenCenterHtmlMenu(plugin, executor, menuSelector.GetMenu());
}

var type = LRTypeExtensions.FromString(info.GetArg(1));
if (type is null)
{
_messages.InvalidLastRequest(info.GetArg(1)).ToPlayerChat(executor);
return;
}

if (info.ArgCount == 2)
{
MenuManager.OpenCenterHtmlMenu(plugin, executor,
playerSelector.CreateMenu(executor, (str) => "css_debug lastrequest " + type + " #" + str));
return;
}

var fromPlayer = GetVulnerableTarget(info, 2);
if (fromPlayer == null)
return;

if (info.ArgCount == 3 && executor != null)
{
if (executor.Team == CsTeam.Terrorist)
manager.InitiateLastRequest(executor, fromPlayer.First(), type.Value);
else // They aren't necessarily on different teams, but this is debug so that's OK
manager.InitiateLastRequest(fromPlayer.First(), executor, type.Value);
return;
}

if (info.ArgCount == 4)
{
var targetPlayer = GetVulnerableTarget(info, 3);
if (targetPlayer == null)
return;
manager.InitiateLastRequest(fromPlayer.First(), targetPlayer.First(), type.Value);
}
}
}
4 changes: 2 additions & 2 deletions mod/Jailbreak.Debug/Subcommands/WrappedInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public string GetArg(int index)
return Info.GetArg(index + 1);
}

public void ReplyToCommand(string message, bool console = false)
public void ReplyToCommand(string message)
{
Info.ReplyToCommand(message, console);
Info.ReplyToCommand(message);
}
}
14 changes: 14 additions & 0 deletions mod/Jailbreak.LastRequest/Jailbreak.LastRequest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

</Project>
Loading

0 comments on commit 2a48394

Please sign in to comment.