From 3bab3141f3ad7313b020b7eef6cb5a401f5ccbb0 Mon Sep 17 00:00:00 2001 From: "Ryan P. McKinnon" <15917743+mrhoribu@users.noreply.github.com> Date: Wed, 6 May 2026 10:48:10 -0400 Subject: [PATCH] fix(enhancives.lic): v0.0.4 add time-charged support Updated version to 0.0.4 experimental with new features for time-charged enhancives, including support for expiry reporting and time threshold settings. --- scripts/enhancives.lic | 163 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 153 insertions(+), 10 deletions(-) diff --git a/scripts/enhancives.lic b/scripts/enhancives.lic index dfa47f29f..55a7a9f89 100644 --- a/scripts/enhancives.lic +++ b/scripts/enhancives.lic @@ -16,9 +16,15 @@ game: Gemstone tags: core, mechanics, utility required: Lich > 5.6.2 - version: 0.0.3 experimental + version: 0.0.4 experimental changelog: + v 0.0.4 experimental (2026-05-06) + add support for time-charged enhancives (items charged until a date) + add separate :time_threshold setting (default 7 days) + report now renders a second table for time-charged items + main loop now warns on items expiring within the time threshold + save_history persists latest expiry for time-charged items v 0.0.3 experimental (2025-03-06) removed unnecessary namespace scope from script v 0.0.2 experimental (2024-07-26) @@ -36,10 +42,39 @@ module Enhancives extend self # I'ma hear about this one. . . - @enhancive_rx = %r[\s+(?:an?)? .*? noun=\"(?[\w]+)\">(?[\w\s\-]+)<\/a>.*?\((?:)?(?\d+)(?:)?\/(?\d+) charges\)]i + @enhancive_rx = %r[\s+(?:an?|some)? .*? noun=\"(?[\w]+)\">(?[\w\s\-]+)<\/a>.*?\((?:)?(?\d+)(?:)?\/(?\d+) charges\)]i + @time_charged_rx = %r[\s+(?:an?|some)? .*? noun=\"(?[\w]+)\">(?[\w\s\-]+)<\/a>.*?\(charged until (?\d{1,2}/\d{1,2}/\d{4}\s+\d{1,2}:\d{2}:\d{2}\s+[A-Z]{2,4})\)]i @no_enhancive_rx = %r[^You are not (?:holding|wearing)] @first_run_detected = false + # Common North American TZ abbreviations the game emits. Ruby's Time.parse + # handles these on most platforms but not reliably on Windows; map explicitly + # to avoid a tzinfo dependency. + @tz_offsets = { + 'EST' => '-0500', 'EDT' => '-0400', + 'CST' => '-0600', 'CDT' => '-0500', + 'MST' => '-0700', 'MDT' => '-0600', + 'PST' => '-0800', 'PDT' => '-0700', + 'AST' => '-0400', 'ADT' => '-0300', + 'HST' => '-1000', 'AKST' => '-0900', 'AKDT' => '-0800', + 'UTC' => '+0000', 'GMT' => '+0000' + }.freeze + + def parse_expiry(str) + # str like "1/3/2031 18:22:31 CST" + if (m = str.match(/^(?\d{1,2}\/\d{1,2}\/\d{4})\s+(?