Wiccan BeWare: added auto reset option

This commit is contained in:
alterNERDtive 2022-04-17 17:09:32 +02:00
parent 8ba4e8a38c
commit 5a61951596
3 changed files with 43 additions and 1 deletions

View file

@ -1,3 +1,11 @@
# devel
## Added
* Wiccan BeWare: automatic reset option for accidental refuels / repairs.
-----
# 3.0 (2022-04-17)
## Added

View file

@ -76,4 +76,7 @@ will **not** enforce buying the correct cargo, and **not** check the system you
buy it in. It can also not detect if/when you fly through the tunnel at Gateway
Interchange Hub, nor enforce the speed requirement.
There are no settings.
There is one settings:
* `Automatically reset when refuelling or repairing`: Automatically reset when
you Refuel or repair, since that is against the rules. Disabled by default.

View file

@ -36,6 +36,17 @@ startup {
vars.journalEntries.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""MarketSell"", ""MarketID"":\d+, ""Type"":"".*"", ""Type_Localised"":"".*"", ""Count"":\d+, ""SellPrice"":\d+, ""TotalSale"":\d+, ""AvgPricePaid"":\d+ \}"));
// Reset conditions
vars.resetConditions = new List<System.Text.RegularExpressions.Regex>();
vars.resetConditions.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""Repair"", .*\}"));
vars.resetConditions.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""RepairAll"", ""Cost"":\d+ \}"));
vars.resetConditions.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""RefuelAll"", ""Cost"":\d+, ""Amount"":\d+\.\d+ \}"));
vars.resetConditions.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""RefuelPartial"", ""Cost"":\d+, ""Amount"":\d+\.\d+ \}"));
// Journal file handling
vars.journalPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
@ -64,6 +75,9 @@ startup {
// Initialize split counter
vars.currentSplit = 0;
// Initialize settings
settings.Add("autoReset", false, "Automatically reset when refuelling or repairing");
}
// Executes when LiveSplit detects the game process (see “state” at the top of the file).
@ -108,6 +122,23 @@ split {
return split;
}
// Executes every `update`. Triggers a reset if a reset condition is met.
// See https://github.com/LiveSplit/LiveSplit.AutoSplitters/blob/master/README.md#automatic-resets-1
reset {
bool reset = false;
if (settings["autoReset"] && !String.IsNullOrEmpty(current.journalString)) {
foreach (System.Text.RegularExpressions.Regex condition in vars.resetConditions)
{
if (condition.Match(current.journalString).Success) {
reset = true;
}
}
}
return reset;
}
// Executes when the game process is shut down.
// In our case were going to close the files we opened in `init`.
// See https://github.com/LiveSplit/LiveSplit.AutoSplitters/blob/master/README.md#game-exit