Files
Joshua Kidder 7a3ad79506 All camelCase (Brute|Burn|Fire|Tox|Oxy|Organ|Stamina)(Loss) procs now use snake_case. UNDERSCORES RULE! (#94111)
## About The Pull Request
It's just a partial cleanup of
anti-[STYLE](https://github.com/tgstation/tgstation/blob/master/.github/guides/STYLE.md)
code from /tg/'s ancient history. I compiled & tested with my helpful
assistant and damage is still working.

<img width="1920" height="1040" alt="image"
src="https://github.com/user-attachments/assets/26dabc17-088f-4008-b299-3ff4c27142c3"
/>


I'll upload the .cs script I used to do it shortly.

## Why It's Good For The Game
Just minor code cleanup.

Script used is located at https://metek.tech/camelTo-Snake.7z

EDIT 11/23/25: Updated the script to use multithreading and sequential
scan so it works a hell of a lot faster
```
/*
//
Copyright 2025 Joshua 'Joan Metekillot' Kidder

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
//
*/
using System.Text.RegularExpressions;
class Program
{
    static async Task Main(string[] args)
    {
        var readFile = new FileStreamOptions
        {
            Access = FileAccess.Read,
            Share = FileShare.ReadWrite,
            Options = FileOptions.Asynchronous | FileOptions.SequentialScan
        };
        FileStreamOptions writeFile = new FileStreamOptions
        {
            Share = FileShare.ReadWrite,
            Access = FileAccess.ReadWrite,
            Mode = FileMode.Truncate,
            Options = FileOptions.Asynchronous
        };
        RegexOptions regexOptions = RegexOptions.Multiline | RegexOptions.Compiled;
        Dictionary<string, int> changedProcs = new();
        string regexPattern = @"(?<=\P{L})([a-z]+)([A-Z]{1,2}[a-z]+)*(Brute|Burn|Fire|Tox|Oxy|Organ|Stamina)(Loss)([A-Z]{1,2}[a-z]+)*";
        Regex camelCaseProcRegex = new(regexPattern, regexOptions);

        string snakeify(Match matchingRegex)
        {
            var vals =
            matchingRegex.Groups.Cast<Group>().SelectMany(_ => _.Captures).Select(_ => _.Value).ToArray();
            var newVal = string.Join("_", vals.Skip(1).ToArray()).ToLower();
            string logString = $"{vals[0]} => {newVal}";
            if (changedProcs.TryGetValue(logString, out int value))
            {
                changedProcs[logString] = value + 1;
            }
            else
            {
                changedProcs.Add(logString, 1);
            }
            return newVal;
        }
        var dmFiles = Directory.EnumerateFiles(".", "*.dm", SearchOption.AllDirectories).ToAsyncEnumerable<string>();

        // uses default ParallelOptions
        // https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.paralleloptions?view=net-10.0#main
        await Parallel.ForEachAsync(dmFiles, async (filePath, UnusedCancellationToken) =>
        {
            var reader = new StreamReader(filePath, readFile);
            string oldContent = await reader.ReadToEndAsync();
            string newContent = camelCaseProcRegex.Replace(oldContent, new MatchEvaluator((Func<Match, string>)snakeify));
            if (oldContent != newContent)
            {
                var writer = new StreamWriter(filePath, writeFile);
                await writer.WriteAsync(newContent);
                await writer.DisposeAsync();
            }
            reader.Dispose();
        });
        var logToList = changedProcs.Cast<KeyValuePair<string, int>>().ToList();
        foreach (var pair in logToList)
        {
            Console.WriteLine($"{pair.Key}: {pair.Value} locations");
        }
    }
}

```

## Changelog
🆑 Bisar
code: All (Brute|Burn|Fire|Tox|Oxy|Organ|Stamina)(Loss) procs now use
snake_case, in-line with the STYLE guide. Underscores rule!
/🆑
2025-11-27 15:50:23 -05:00

117 lines
5.3 KiB
Plaintext

#define DAMAGE_AMOUNT 20
#define SECONDS_PER_TICK SSmobs.wait / 10
/datum/unit_test/liver
abstract_type = /datum/unit_test/liver
/datum/unit_test/liver/skeleton/Run()
// Pause natural mob life so it can be handled entirely by the test
SSmobs.pause()
var/mob/living/carbon/human/species/skeleton/mrbones = allocate(/mob/living/carbon/human/species/skeleton)
var/datum/reagent/toxin/bonehurtingjuice/bonehurting = /datum/reagent/toxin/bonehurtingjuice
var/datum/reagent/consumable/milk/calcium = /datum/reagent/consumable/milk
TEST_ASSERT(!isnull(mrbones.get_organ_by_type(/obj/item/organ/liver/bone)), "Skeleton does not have a bone liver")
TEST_ASSERT_EQUAL(mrbones.has_reagent(/datum/reagent/toxin/bonehurtingjuice), FALSE, "Skeleton somehow has bone hurting juice before drinking")
TEST_ASSERT_EQUAL(mrbones.has_reagent(/datum/reagent/consumable/milk), FALSE, "Skeleton somehow has milk before drinking")
// Test bone hurting juice reactions
mrbones.reagents.add_reagent(bonehurting, 40)
mrbones.Life(SSMOBS_DT)
var/expected_stamina_damage = (7.5 * REM * SECONDS_PER_TICK)
var/expected_brute_damage = (0.5 * REM * SECONDS_PER_TICK)
TEST_ASSERT_EQUAL(mrbones.get_stamina_loss(), expected_stamina_damage,
"Skeleton took [mrbones.get_stamina_loss() > expected_stamina_damage ? "more" : "less"] stamina damage than expected")
TEST_ASSERT_EQUAL(mrbones.get_brute_loss(), expected_brute_damage,
"Skeleton took [mrbones.get_brute_loss() > expected_brute_damage ? "more" : "less"] brute damage than expected")
mrbones.reagents.remove_all(mrbones.reagents.total_volume)
mrbones.fully_heal()
TEST_ASSERT_EQUAL(mrbones.get_stamina_loss(), 0, "Skeleton did not fully heal stamina damage")
TEST_ASSERT_EQUAL(mrbones.get_brute_loss(), 0, "Skeleton did not fully heal brute damage")
// Test milk reactions
mrbones.reagents.add_reagent(calcium, 51)
mrbones.Life(SSMOBS_DT)
TEST_ASSERT(mrbones.reagents.total_volume < 50, "Excess (>50u) milk did not leak out of skeleton")
mrbones.reagents.remove_all(mrbones.reagents.total_volume)
mrbones.apply_damage(DAMAGE_AMOUNT, def_zone = BODY_ZONE_CHEST)
var/list/obj/item/bodypart/damaged_parts = mrbones.get_damaged_bodyparts(brute = TRUE)
TEST_ASSERT(!isnull(damaged_parts), "Skeleton did not take any damage")
TEST_ASSERT(length(damaged_parts) == 1, "Skeleton took damage to more than one body part")
mrbones.reagents.add_reagent(calcium, 50)
mrbones.Life(SSMOBS_DT)
var/expected_remaining_damage = DAMAGE_AMOUNT - (2.5 * REM * SECONDS_PER_TICK)
// Milk also heals brute on its own, so we may be more healed than expected
TEST_ASSERT(damaged_parts[1].brute_dam <= expected_remaining_damage,
"Milk did not heal the expected amount of damage (expected at least [expected_remaining_damage], got [damaged_parts[1].brute_dam])")
/datum/unit_test/liver/skeleton/Destroy()
SSmobs.ignite()
return ..()
// Plasmamen
/datum/unit_test/liver/plasmaman/Run()
// Pause natural mob life so it can be handled entirely by the test
SSmobs.pause()
var/mob/living/carbon/human/species/plasma/mrbones = allocate(/mob/living/carbon/human/species/plasma)
var/datum/reagent/toxin/plasma/plasma = /datum/reagent/toxin/plasma
var/datum/reagent/toxin/hot_ice/hot_ice = /datum/reagent/toxin/hot_ice
// Testing plasma/hot ice healing on wounds
TEST_ASSERT(!isnull(mrbones.get_organ_by_type(/obj/item/organ/liver/bone/plasmaman)), "Plasmaman does not have a plasmaman bone liver")
TEST_ASSERT_EQUAL(mrbones.has_reagent(plasma), FALSE, "Plasmaman somehow has plasma before drinking")
TEST_ASSERT_EQUAL(mrbones.has_reagent(hot_ice), FALSE, "Plasmaman somehow has hot ice before drinking")
var/obj/item/bodypart/r_arm = mrbones.get_bodypart(BODY_ZONE_R_ARM)
var/obj/item/bodypart/l_arm = mrbones.get_bodypart(BODY_ZONE_L_ARM)
var/expected_wound_healing = 4 * REM * SECONDS_PER_TICK
// Test plasma
r_arm.receive_damage(WOUND_MINIMUM_DAMAGE, 0, wound_bonus = 100, sharpness = NONE)
TEST_ASSERT(length(mrbones.all_wounds), "Plasmaman did not receive a wound on their right arm")
mrbones.reagents.add_reagent(plasma, 50)
mrbones.Life(SSMOBS_DT)
var/datum/wound/afflicted_wound = mrbones.all_wounds[1]
TEST_ASSERT_EQUAL(afflicted_wound.cryo_progress, expected_wound_healing, "Plasma did not reduce wound on plasmaman")
mrbones.reagents.remove_all(mrbones.reagents.total_volume)
mrbones.fully_heal()
TEST_ASSERT(!length(r_arm.wounds), "Plasmaman did not fully heal wounds")
// Test hot ice
l_arm.receive_damage(WOUND_MINIMUM_DAMAGE, 0, wound_bonus = 100, sharpness = NONE)
TEST_ASSERT(length(mrbones.all_wounds), "Plasmaman did not receive a wound on their left arm")
afflicted_wound = mrbones.all_wounds[1]
mrbones.reagents.add_reagent(hot_ice, 50)
mrbones.Life(SSMOBS_DT)
TEST_ASSERT_EQUAL(afflicted_wound.cryo_progress, expected_wound_healing, "Hot ice did not reduce wound on plasmaman")
// Test gunpowder giving plasmamen hallucinations
var/datum/reagent/gunpowder/gunpowder = /datum/reagent/gunpowder
mrbones.reagents.add_reagent(gunpowder, 50)
mrbones.Life(SSMOBS_DT)
TEST_ASSERT(mrbones.has_status_effect(/datum/status_effect/drugginess), "Plasmaman did not get druggy status after consuming gunpowder")
TEST_ASSERT(mrbones.has_status_effect(/datum/status_effect/hallucination), "Plasmaman did not get hallucinating status after consuming gunpowder")
/datum/unit_test/liver/plasmaman/Destroy()
SSmobs.ignite()
return ..()
#undef DAMAGE_AMOUNT
#undef SECONDS_PER_TICK