]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add command for getting artifact point value (#13987)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sun, 12 Feb 2023 12:35:10 +0000 (07:35 -0500)
committerGitHub <noreply@github.com>
Sun, 12 Feb 2023 12:35:10 +0000 (12:35 +0000)
Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Commands.cs
Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs

index 1cdd6b6c935ae5d42ab33b86ab0d048942abe008..ddb1573b32d6d7d75858a829a3a832fe19b2c32a 100644 (file)
@@ -1,9 +1,7 @@
 using System.Linq;
 using Content.Server.Administration;
 using Content.Shared.Administration;
-using Content.Shared.Xenoarchaeology.XenoArtifacts;
 using Robust.Shared.Console;
-using Robust.Shared.Utility;
 
 namespace Content.Server.Xenoarchaeology.XenoArtifacts;
 
@@ -16,6 +14,9 @@ public partial class ArtifactSystem
         _conHost.RegisterCommand("forceartifactnode", "Forces an artifact to traverse to a given node", "forceartifacteffect <uid> <node ID>",
             ForceArtifactNode,
             ForceArtifactNodeCompletions);
+
+        _conHost.RegisterCommand("getartifactmaxvalue", "Reports the maximum research point value for a given artifact", "forceartifacteffect <uid>",
+            GetArtifactMaxValue);
     }
 
     [AdminCommand(AdminFlags.Fun)]
@@ -48,4 +49,20 @@ public partial class ArtifactSystem
 
         return CompletionResult.Empty;
     }
+
+    [AdminCommand(AdminFlags.Debug)]
+    private void GetArtifactMaxValue(IConsoleShell shell, string argstr, string[] args)
+    {
+        if (args.Length != 1)
+            shell.WriteError("Argument length must be 1");
+
+        if (!EntityUid.TryParse(args[0], out var uid))
+            return;
+
+        if (!TryComp<ArtifactComponent>(uid, out var artifact) || artifact.NodeTree == null)
+            return;
+
+        var pointSum = GetResearchPointValue(uid, artifact, true);
+        shell.WriteLine($"Max point value for {ToPrettyString(uid)} with {artifact.NodeTree.AllNodes.Count} nodes: {pointSum}");
+    }
 }
index a8fb10f3a92ca04afa35848f9d612079910ddd89..261c64b9a8ddf48e1900a6ff061123a4cbaa1dfe 100644 (file)
@@ -84,13 +84,13 @@ public sealed partial class ArtifactSystem : EntitySystem
     /// Medium should get you partway through a tree.
     /// Complex should get you through a full tree and then some.
     /// </remarks>
-    public int GetResearchPointValue(EntityUid uid, ArtifactComponent? component = null)
+    public int GetResearchPointValue(EntityUid uid, ArtifactComponent? component = null, bool getMaxPrice = false)
     {
         if (!Resolve(uid, ref component) || component.NodeTree == null)
             return 0;
 
-        var sumValue = component.NodeTree.AllNodes.Sum(n => GetNodePointValue(n, component));
-        var fullyExploredBonus = component.NodeTree.AllNodes.Any(x => !x.Triggered) ? 1 : 1.25f;
+        var sumValue = component.NodeTree.AllNodes.Sum(n => GetNodePointValue(n, component, getMaxPrice));
+        var fullyExploredBonus = component.NodeTree.AllNodes.All(x => x.Triggered) || getMaxPrice ? 1.25f : 1;
 
         var pointValue = (int) (sumValue * fullyExploredBonus);
         return pointValue;
@@ -99,12 +99,16 @@ public sealed partial class ArtifactSystem : EntitySystem
     /// <summary>
     /// Gets the point value for an individual node
     /// </summary>
-    private float GetNodePointValue(ArtifactNode node, ArtifactComponent component)
+    private float GetNodePointValue(ArtifactNode node, ArtifactComponent component, bool getMaxPrice = false)
     {
-        if (!node.Discovered)
-            return 0;
+        var valueDeduction = 1f;
+        if (!getMaxPrice)
+        {
+            if (!node.Discovered)
+                return 0;
 
-        var valueDeduction = !node.Triggered ? 0.25f : 1;
+            valueDeduction = !node.Triggered ? 0.25f : 1;
+        }
         var nodeDanger = (node.Depth + node.Effect.TargetDepth + node.Trigger.TargetDepth) / 3;
         return component.PointsPerNode * MathF.Pow(component.PointDangerMultiplier, nodeDanger) * valueDeduction;
     }