Skip to content

Commit fa4df20

Browse files
make descriptions of methods not nullable for reference resolving
1 parent 0e695c4 commit fa4df20

File tree

7 files changed

+21
-18
lines changed

7 files changed

+21
-18
lines changed
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
namespace SER.Code.MethodSystem.MethodDescriptors;
1+
using SER.Code.Helpers.Extensions;
2+
using SER.Code.MethodSystem.BaseMethods;
3+
4+
namespace SER.Code.MethodSystem.MethodDescriptors;
25

36
/// <summary>
47
/// A method which takes a reference as an input and returns information about it in a readable format.
58
/// </summary>
69
public interface IReferenceResolvingMethod
710
{
811
public Type ReferenceType { get; }
12+
13+
public static class Desc
14+
{
15+
public static string Get(IReferenceResolvingMethod method) => $"Extracts information from {method.ReferenceType.AccurateName} objects.";
16+
}
917
}

Code/MethodSystem/Methods/DoorMethods/DoorInfoMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class DoorInfoMethod : LiteralValueReturningMethod, IReferenceResolvingMe
1818
public Type ReferenceType => typeof(Door);
1919
public override Type[] LiteralReturnTypes => [typeof(TextValue), typeof(BoolValue), typeof(NumberValue)];
2020

21-
public override string Description => null!;
21+
public override string Description => IReferenceResolvingMethod.Desc.Get(this);
2222

2323
public override Argument[] ExpectedArguments { get; } =
2424
[

Code/MethodSystem/Methods/HealthMethods/DamageInfoMethod.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ namespace SER.Code.MethodSystem.Methods.HealthMethods;
1515
public class DamageInfoMethod : ReturningMethod, IReferenceResolvingMethod, IAdditionalDescription
1616
{
1717
public Type ReferenceType => typeof(DamageHandlerBase);
18+
1819
public override Type[] ReturnTypes => [typeof(TextValue), typeof(ReferenceValue)];
1920

20-
public override string Description => null!;
21+
public override string Description => IReferenceResolvingMethod.Desc.Get(this);
22+
23+
public string AdditionalDescription =>
24+
"A lot of options here might not be available depending on which DamageHandler is used in game. " +
25+
"It's advised you check every accessed value for 'none' before using it.";
2126

2227
public override Argument[] ExpectedArguments { get; } =
2328
[
@@ -45,8 +50,4 @@ public override void Execute()
4550
_ => throw new AndrzejFuckedUpException("out of range")
4651
};
4752
}
48-
49-
public string AdditionalDescription =>
50-
"A lot of options here might not be available depending on which DamageHandler is used in game. " +
51-
"It's advised you check every accessed value for 'none' before using it.";
5253
}

Code/MethodSystem/Methods/ItemMethods/ItemInfoMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace SER.Code.MethodSystem.Methods.ItemMethods;
1313
[UsedImplicitly]
1414
public class ItemInfoMethod : ReturningMethod, IReferenceResolvingMethod
1515
{
16-
public override string Description => null!;
16+
public override string Description => IReferenceResolvingMethod.Desc.Get(this);
1717

1818
public override Type[] ReturnTypes => [typeof(TextValue), typeof(PlayerValue), typeof(BoolValue)];
1919
public Type ReferenceType => typeof(Item);

Code/MethodSystem/Methods/RespawnMethods/RespawnWaveInfoMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class RespawnWaveInfoMethod : LiteralValueReturningMethod, IReferenceReso
1818

1919
public override Type[] LiteralReturnTypes => [typeof(NumberValue), typeof(TextValue)];
2020

21-
public override string Description => null!;
21+
public override string Description => IReferenceResolvingMethod.Desc.Get(this);
2222

2323
public override Argument[] ExpectedArguments { get; } =
2424
[

Code/MethodSystem/Methods/RoleMethods/RoleInfoMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class RoleInfoMethod : ReturningMethod<TextValue>, IReferenceResolvingMet
1515
{
1616
public Type ReferenceType => typeof(PlayerRoleBase);
1717

18-
public override string Description => null!;
18+
public override string Description => IReferenceResolvingMethod.Desc.Get(this);
1919

2020
public override Argument[] ExpectedArguments { get; } =
2121
[

Code/Plugin/Commands/HelpSystem/HelpCommand.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,8 @@ private static string GetVariableList()
478478
private static string GetMethodHelp(Method method)
479479
{
480480
var sb = new StringBuilder($"=== {method.Name} ===\n");
481-
if (method is IReferenceResolvingMethod refRes && method.Description is null)
482-
{
483-
sb.AppendLine($"> Extracts information from {refRes.ReferenceType.Name} objects.");
484-
}
485-
else
486-
{
487-
sb.AppendLine($"> {method.Description}");
488-
}
481+
482+
sb.AppendLine($"> {method.Description}");
489483

490484
if (method is IAdditionalDescription addDesc)
491485
{

0 commit comments

Comments
 (0)