• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

samsmithnz / SatisfactoryTree / 17631712519

11 Sep 2025 01:58AM UTC coverage: 90.507% (+37.6%) from 52.88%
17631712519

push

github

web-flow
Merge pull request #284 from samsmithnz/ReworkingLogicToHandleImportsAndExports

Reworking logic to handle imports and exports

298 of 344 branches covered (86.63%)

Branch coverage included in aggregate %.

951 of 1036 new or added lines in 28 files covered. (91.8%)

951 of 1036 relevant lines covered (91.8%)

861.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.98
/src/SatisfactoryTree.Logic/Extraction/Common.cs
1
using System.Text.RegularExpressions;
2

3
namespace SatisfactoryTree.Logic.Extraction
4
{
5
    public class Common
6
    {
7
        // Blacklist for excluding items produced by the Build Gun
8
        public static readonly List<string> Blacklist = new List<string>
1✔
9
        {
1✔
10
            "(\"/Game/FactoryGame/Equipment/BuildGun/BP_BuildGun.BP_BuildGun_C\")",
1✔
11
            "(\"/Script/FactoryGame.FGBuildGun\")",
1✔
12
            "(\"/Game/FactoryGame/Buildable/-Shared/WorkBench/BP_WorkshopComponent.BP_WorkshopComponent_C\")"
1✔
13
        };
1✔
14

15
        public static readonly List<string> Whitelist = new List<string>
1✔
16
        {
1✔
17
            // Nuclear Waste is not produced by any buildings - it's a byproduct of Nuclear Power Plants
1✔
18
            "Desc_NuclearWaste_C",
1✔
19
            "Desc_PlutoniumWaste_C",
1✔
20
            // These are collectible items, not produced by buildings
1✔
21
            "Desc_Leaves_C",
1✔
22
            "Desc_Wood_C",
1✔
23
            "Desc_Mycelia_C",
1✔
24
            "Desc_HogParts_C",
1✔
25
            "Desc_SpitterParts_C",
1✔
26
            "Desc_StingerParts_C",
1✔
27
            "Desc_HatcherParts_C",
1✔
28
            "Desc_DissolvedSilica_C",
1✔
29
            "Desc_Crystal_C",
1✔
30
            "Desc_Crystal_mk2_C",
1✔
31
            "Desc_Crystal_mk3_C",
1✔
32
            // Liquid Oil can be produced by oil extractors and oil wells
1✔
33
            "Desc_LiquidOil_C",
1✔
34
            // FICSMAS items
1✔
35
            "Desc_Gift_C",
1✔
36
            "Desc_Snow_C",
1✔
37
            // SAM Ore is mined, but for some reason doesn't have a produced in property
1✔
38
            "Desc_SAM_C",
1✔
39
            // Special items 
1✔
40
            "Desc_CrystalShard_C",
1✔
41
            "BP_ItemDescriptorPortableMiner_C"
1✔
42
        };
1✔
43

44
        // Helper function to check if a recipe is likely to be liquid based on building type and amount
45
        public static bool IsFluid(string productName)
46
        {
1,087✔
47
            var liquidProducts = new HashSet<string>
1,087✔
48
            {
1,087✔
49
                "water", "liquidoil", "heavyoilresidue", "liquidfuel", "liquidturbofuel", "liquidbiofuel",
1,087✔
50
                "aluminasolution", "sulfuricacid", "nitricacid", "dissolvedsilica"
1,087✔
51
            };
1,087✔
52

53
            var gasProducts = new HashSet<string>
1,087✔
54
            {
1,087✔
55
                "nitrogengas", "rocketfuel", "ionizedfuel", "quantumenergy", "darkenergy"
1,087✔
56
            };
1,087✔
57

58
            productName = productName.ToLower();
1,087✔
59

60
            return liquidProducts.Contains(productName) || gasProducts.Contains(productName);
1,087✔
61
        }
1,087✔
62

63
        public static bool IsFicsmas(string? displayName)
64
        {
459✔
65
            if (displayName == null)
459!
NEW
66
            {
×
NEW
67
                return false;
×
68
            }
69
            return displayName.Contains("FICSMAS", StringComparison.OrdinalIgnoreCase) ||
459✔
70
                   displayName.Contains("Gift", StringComparison.OrdinalIgnoreCase) ||
459✔
71
                   displayName.Contains("Snow", StringComparison.OrdinalIgnoreCase) ||
459✔
72
                   displayName.Contains("Candy", StringComparison.OrdinalIgnoreCase) ||
459✔
73
                   displayName.Contains("Fireworks", StringComparison.OrdinalIgnoreCase);
459✔
74
        }
459✔
75

76
        public static string GetRecipeName(string name)
77
        {
291✔
78
            //return name.Replace(oldValue: "Build_", "").Replace("_C", "");
79
            name = Regex.Replace(name, @"_C$", ""); // Replace _C only at the end of the string
291✔
80
            name = name.Replace("Recipe_", "");
291✔
81
            return name;
291✔
82
        }
291✔
83

84
        public static string GetPowerGenerationRecipeName(string name)
85
        {
17✔
86
            //return name.Replace(oldValue: "Build_", "").Replace("_C", "");
87
            name = Regex.Replace(name, @"_C$", ""); // Replace _C only at the end of the string
17✔
88
            name = name.Replace("Build_", "");
17✔
89
            return name;
17✔
90
        } 
17✔
91

92
        public static string GetBuildingName(string name)
93
        {
292✔
94
            //name = name.Replace("Build_", "").Replace("_C", "");
95
            name = Regex.Replace(name, @"_C$", ""); // Replace _C only at the end of the string
292✔
96
            name = name.Replace("Build_", "");
292✔
97
            return name;
292✔
98
        }
292✔
99
        
100
        public static string GetPowerBuildingName(string name)
101
        {
2,820✔
102
            Match match = Regex.Match(name, @"Build_(\w+)_");
2,820✔
103
            if (match.Success)
2,820✔
104
            {
535✔
105
                string buildingName = match.Groups[1].Value.ToLower();
535✔
106
                // If contains _automated, remove it
107
                return buildingName.Replace("_automated", "");
535✔
108
            }
109
            return "";
2,285✔
110
        }
2,820✔
111

112

113

114
        public static string GetPartName(string name)
115
        {
2,871✔
116
            if (name == "BP_ItemDescriptorPortableMiner_C")
2,871✔
117
            {
1✔
118
                return "PortableMiner";
1✔
119
            }
120
            //name = name.Replace("Desc_", "").Replace("_C", "");
121
            name = Regex.Replace(name, @"_C$", ""); // Replace _C only at the end of the string
2,870✔
122
            name = name.Replace("Desc_", "");
2,870✔
123
            return name;
2,870✔
124
        }
2,871✔
125

126
        public static string GetFriendlyName(string? name)
NEW
127
        {
×
NEW
128
            if (name == null)
×
NEW
129
            {
×
NEW
130
                return "";
×
131
            }
132
            // Remove any text within brackets, including the brackets themselves
NEW
133
            return Regex.Replace(name, @"\s*\(.*?\)", "");
×
NEW
134
        }
×
135

136
        // Example: Build_GeneratorBiomass_Automated_C
137
        // Change into "generatorbiomas"
138
        public static string GetPowerProducerBuildingName(string className)
139
        {
70✔
140
            var match = Regex.Match(className, @"Build_(\w+)_");
70✔
141
            if (match.Success)
70✔
142
            {
68✔
143
                var buildingName = match.Groups[1].Value.ToLower();
68✔
144
                // If contains _automated, remove it
145
                return buildingName.Replace("_automated", "");
68✔
146
            }
147

148
            return "";
2✔
149
        }
70✔
150

151

152
    }
153
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc