From f7b53b1ba9021a99be038b497aadb6bf1a0c6a97 Mon Sep 17 00:00:00 2001 From: Mahtra <93822896+MahtraDR@users.noreply.github.com> Date: Fri, 17 Jan 2025 20:31:26 +1300 Subject: [PATCH 1/4] [new script][nexus] Add Nexus sacrifice script --- nexus.lic | 75 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/nexus.lic b/nexus.lic index c06c0b013d..68660aba10 100644 --- a/nexus.lic +++ b/nexus.lic @@ -1,48 +1,61 @@ -=begin - Documentation: -=end custom_require.call(%w[common common-travel]) + class Nexus def initialize - UserVars.nexus ||= {} arg_definitions = [ [ - { name: 'offering', options: %w[concentration health mana spirit fatigue], description: 'What will you sacrifice to power the nexus?' }, - { name: 'room', display: 'Room id #', regex: /\d+/, description: 'What is the room id of the room you are making a sacrifice in?' } - ], - [ - { name: 'list', regex: /list/i, description: 'List all the known nexus rooms' } + { name: 'resources', regex: /\w+/i, optional: true, description: 'Resource to sacrifice at nexus point' } ] - ] - args = parse_args(arg_definitions) - if args.list - print_list + + args = parse_args(arg_definitions, true) + + unless args.resources + echo("No resource specified. Exiting.") + exit + end + UserVars.last_nexus ||= Time.now - 6.hours + settings = get_settings + hometown = settings.nexus_town || settings.fang_cove_override_town || settings.hometown + room = get_room(hometown) + unless should_sacrifice? + echo("Not enough time has passed since last nexus sacrifice.") + echo("Exiting.") + exit + end + DRCT.walk_to(room) + sacrifice(args.resources) if args.resources + end + + def should_sacrifice? + unless Time.now - 6.hours > UserVars.last_nexus + return false else - sacrifice?(args.room, args.offering) + return true end end - def sacrifice?(room, offering) - DRCT.walk_to room - case DRC.bput("sacrifice nexus #{offering}", 'Before you can register it happening, a part of you is ripped violently away', 'Noble as that sacrifice would be', "You've recently sacrificed to empower a nexus", /^\[You don't have access to creating empowered nexus points/, '^But you have no attunement to sacrifice') - when 'Before you can register it happening, a part of you is ripped violently away' - UserVars.nexus['last_sacrifice_time'] = Time.now - true - when 'Noble as that sacrifice would be' - echo "#{room} is not a nexus!" - false - when "You've recently sacrificed to empower a nexus", "You don't have access to creating empowered nexus points", 'But you have no attunement to sacrifice' - false + def sacrifice(resources) + case DRC.bput("sacrifice nexus #{resources}", + /^You reach out, sensing the latent nexus and attempt to forge a connection with it/, + /^You've recently sacrificed to empower a nexus. You should wait a while before doing so again/, + /^You sense the energies of the nexus here are still intact/) + when /You reach out, sensing the latent nexus and attempt to forge a connection with it/ + UserVars.last_nexus = Time.now + return true + when /You've recently sacrificed to empower a nexus. You should wait a while before doing so again/ + UserVars.last_nexus = Time.now + 1.hour + return false + when /You sense the energies of the nexus here are still intact/ + UserVars.last_nexus = Time.now + 30.minutes + return false end end - def print_list - respond('-' * 70) - respond(' - Nexus Room Title'.ljust(48) + ' - Nexus Room ID'.rjust(5)) - respond('-' * 70) - Map.list.find_all { |room| room.tags.include?('nexus') } - .each { |room| respond " - #{room.title.first.sub(/^\[/, '').sub(/\]$/, '').ljust(45)} - #{room.id.to_s.rjust(5)}\n" } + def get_room(town) + room = get_data('town')[town]['nexus']['id'] + return room end end + Nexus.new From 34aacbd082db1317bab3786ab39f30670c45f221 Mon Sep 17 00:00:00 2001 From: Mahtra <93822896+MahtraDR@users.noreply.github.com> Date: Fri, 17 Jan 2025 22:22:17 +1300 Subject: [PATCH 2/4] details --- nexus.lic | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/nexus.lic b/nexus.lic index 68660aba10..9855790eb9 100644 --- a/nexus.lic +++ b/nexus.lic @@ -4,7 +4,7 @@ class Nexus def initialize arg_definitions = [ [ - { name: 'resources', regex: /\w+/i, optional: true, description: 'Resource to sacrifice at nexus point' } + { name: 'resources', options: %w[concentration health mana spirit fatigue], description: 'Resource to sacrifice at nexus point' } ] ] @@ -18,13 +18,17 @@ class Nexus settings = get_settings hometown = settings.nexus_town || settings.fang_cove_override_town || settings.hometown room = get_room(hometown) + unless room + echo("No nexus room found for #{hometown}. Exiting.") + exit + end unless should_sacrifice? echo("Not enough time has passed since last nexus sacrifice.") echo("Exiting.") exit end DRCT.walk_to(room) - sacrifice(args.resources) if args.resources + sacrifice(args.resources) if args.resources && Map.current.id == room end def should_sacrifice? @@ -37,9 +41,9 @@ class Nexus def sacrifice(resources) case DRC.bput("sacrifice nexus #{resources}", - /^You reach out, sensing the latent nexus and attempt to forge a connection with it/, - /^You've recently sacrificed to empower a nexus. You should wait a while before doing so again/, - /^You sense the energies of the nexus here are still intact/) + /^You reach out, sensing the latent nexus and attempt to forge a connection with it/, + /^You've recently sacrificed to empower a nexus. You should wait a while before doing so again/, + /^You sense the energies of the nexus here are still intact/) when /You reach out, sensing the latent nexus and attempt to forge a connection with it/ UserVars.last_nexus = Time.now return true From 473797b51b529b62a59e317b7f89ca7f113ad01f Mon Sep 17 00:00:00 2001 From: Mahtra <93822896+MahtraDR@users.noreply.github.com> Date: Fri, 17 Jan 2025 22:23:50 +1300 Subject: [PATCH 3/4] update --- nexus.lic | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nexus.lic b/nexus.lic index 9855790eb9..e2aaa8ca9e 100644 --- a/nexus.lic +++ b/nexus.lic @@ -57,8 +57,7 @@ class Nexus end def get_room(town) - room = get_data('town')[town]['nexus']['id'] - return room + return get_data('town')[town]['nexus']['id'] end end From 167fdc4e8d0433ab765bbcfa5b0b5d7afa1fda4a Mon Sep 17 00:00:00 2001 From: Mahtra <93822896+MahtraDR@users.noreply.github.com> Date: Fri, 17 Jan 2025 22:26:09 +1300 Subject: [PATCH 4/4] Rubocop --- nexus.lic | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nexus.lic b/nexus.lic index e2aaa8ca9e..e89e0a5583 100644 --- a/nexus.lic +++ b/nexus.lic @@ -41,9 +41,9 @@ class Nexus def sacrifice(resources) case DRC.bput("sacrifice nexus #{resources}", - /^You reach out, sensing the latent nexus and attempt to forge a connection with it/, - /^You've recently sacrificed to empower a nexus. You should wait a while before doing so again/, - /^You sense the energies of the nexus here are still intact/) + /^You reach out, sensing the latent nexus and attempt to forge a connection with it/, + /^You've recently sacrificed to empower a nexus. You should wait a while before doing so again/, + /^You sense the energies of the nexus here are still intact/) when /You reach out, sensing the latent nexus and attempt to forge a connection with it/ UserVars.last_nexus = Time.now return true