Class: Lich::Gemstone::Bounty

Inherits:
Object
  • Object
show all
Defined in:
documented/gemstone/bounty.rb,
documented/gemstone/bounty/task.rb,
documented/gemstone/bounty/parser.rb

Overview

Represents a bounty in the Lich Gemstone module. This class is responsible for parsing bounty descriptions.

Examples:

Creating a bounty parser

bounty_parser = Lich::Gemstone::Bounty::Parser.new(description)

Defined Under Namespace

Classes: Parser, Task

Constant Summary collapse

KNOWN_TASKS =

A list of known task matchers for bounties.

Parser::TASK_MATCHERS.keys

Class Method Summary collapse

Class Method Details

.currentTask

Retrieves the current bounty task.

Examples:

Getting the current bounty task

task = Lich::Gemstone::Bounty.current

Returns:

  • (Task)

    The current bounty task instance.



18
19
20
# File 'documented/gemstone/bounty.rb', line 18

def self.current
  Task.new(Parser.parse(checkbounty))
end

.lnet(person) ⇒ Task?

Retrieves bounty information for a specified person from LNet.

Examples:

Getting bounty information from LNet

bounty_info = Lich::Gemstone::Bounty.lnet("John Doe")

Parameters:

  • person (String)

    The name of the person to look up.

Returns:

  • (Task, nil)

    A Task instance if found, otherwise nil.

Raises:

  • (StandardError)

    If there is an issue with the LNet request.



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'documented/gemstone/bounty.rb', line 36

def self.lnet(person)
  if (target_info = LNet.get_data(person.dup, 'bounty'))
    Task.new(Parser.parse(target_info))
  else
    if target_info == false
      text = "No one on LNet with a name like #{person}"
    else
      text = "Empty response from LNet for bounty from #{person}\n"
    end
    Lich::Messaging.msg("warn", text)
    nil
  end
end

.taskTask

Alias for the current bounty task.

Examples:

Accessing the task method

task = Lich::Gemstone::Bounty.task

Returns:

  • (Task)

    The current bounty task instance.



26
27
28
# File 'documented/gemstone/bounty.rb', line 26

def self.task
  current
end