Class: Lich::DragonRealms::CharacterValidator
- Inherits:
-
Object
- Object
- Lich::DragonRealms::CharacterValidator
- Defined in:
- documented/dragonrealms/commons/common-validation.rb
Overview
Validates character information and manages communication with the lnet script.
Constant Summary collapse
- LNET_SCRIPT_NAME =
'lnet'- FIND_NOT_FOUND =
'There are no adventurers in the realms that match the names specified'
Instance Method Summary collapse
-
#confirm(character) ⇒ void
Confirms the validation of the specified character and optionally greets them.
-
#in_game?(character) ⇒ Boolean
Checks if the specified character is currently in the game.
-
#initialize(announce, should_sleep, greet, name) ⇒ void
constructor
Initializes a new CharacterValidator instance.
-
#send_bankbot_balance(character, balance) ⇒ void
Sends the current bank balance to the specified character.
-
#send_bankbot_help(character, messages) ⇒ void
Sends help messages to the specified character.
-
#send_bankbot_location(character) ⇒ void
Sends the current location to the specified character.
-
#send_slack_token(character) ⇒ void
Sends the Slack token to the specified character.
-
#valid?(character) ⇒ Boolean
Checks if the specified character has been validated.
-
#validate(character) ⇒ void
Validates the specified character by checking if they are already validated.
Constructor Details
#initialize(announce, should_sleep, greet, name) ⇒ void
Initializes a new CharacterValidator instance.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'documented/dragonrealms/commons/common-validation.rb', line 17 def initialize(announce, should_sleep, greet, name) waitrt? fput('sleep') if should_sleep @lnet = (Script.running + Script.hidden).find { |val| val.name == LNET_SCRIPT_NAME } @validated_characters = [] @greet = greet @name = name unless lnet_available? Lich::Messaging.msg("bold", "CharacterValidator: lnet is not running. Chat features will be unavailable.") return end send_chat("#{@name} is up and running in room #{Room.current.id}! Whisper me 'help' for more details.") if announce end |
Instance Method Details
#confirm(character) ⇒ void
This method returns an undefined value.
Confirms the validation of the specified character and optionally greets them.
59 60 61 62 63 64 65 66 67 68 |
# File 'documented/dragonrealms/commons/common-validation.rb', line 59 def confirm(character) return if valid?(character) Lich::Messaging.msg("plain", "CharacterValidator: Successfully validated: #{character}") @validated_characters << character return unless @greet put "whisper #{character} Hi! I'm your friendly neighborhood #{@name}. Whisper me 'help' for more details. Don't worry, I've memorized your name so you won't see this message again." end |
#in_game?(character) ⇒ Boolean
Checks if the specified character is currently in the game.
116 117 118 119 |
# File 'documented/dragonrealms/commons/common-validation.rb', line 116 def in_game?(character) result = DRC.bput("find #{character}", FIND_NOT_FOUND, /^\s{2}#{character}\.$/, 'Unknown command') result =~ /^\s{2}#{character}\.$/ end |
#send_bankbot_balance(character, balance) ⇒ void
This method returns an undefined value.
Sends the current bank balance to the specified character.
81 82 83 84 85 86 87 |
# File 'documented/dragonrealms/commons/common-validation.rb', line 81 def send_bankbot_balance(character, balance) return unless lnet_available? = "Current Balance: #{balance}" Lich::Messaging.msg("plain", "CharacterValidator: Attempting to DM #{character} with message: #{}") send_chat_to(character, ) end |
#send_bankbot_help(character, messages) ⇒ void
This method returns an undefined value.
Sends help messages to the specified character.
104 105 106 107 108 109 110 111 |
# File 'documented/dragonrealms/commons/common-validation.rb', line 104 def send_bankbot_help(character, ) return unless lnet_available? .each do || Lich::Messaging.msg("plain", "CharacterValidator: Attempting to DM #{character} with message: #{}") send_chat_to(character, ) end end |
#send_bankbot_location(character) ⇒ void
This method returns an undefined value.
Sends the current location to the specified character.
92 93 94 95 96 97 98 |
# File 'documented/dragonrealms/commons/common-validation.rb', line 92 def send_bankbot_location(character) return unless lnet_available? = "Current Location: #{Room.current.id}" Lich::Messaging.msg("plain", "CharacterValidator: Attempting to DM #{character} with message: #{}") send_chat_to(character, ) end |
#send_slack_token(character) ⇒ void
This method returns an undefined value.
Sends the Slack token to the specified character.
37 38 39 40 41 42 43 |
# File 'documented/dragonrealms/commons/common-validation.rb', line 37 def send_slack_token(character) return unless lnet_available? = "slack_token: #{UserVars.slack_token || 'Not Found'}" Lich::Messaging.msg("plain", "CharacterValidator: Attempting to DM #{character} with message: #{}") send_chat_to(character, ) end |
#valid?(character) ⇒ Boolean
Checks if the specified character has been validated.
73 74 75 |
# File 'documented/dragonrealms/commons/common-validation.rb', line 73 def valid?(character) @validated_characters.include?(character) end |
#validate(character) ⇒ void
This method returns an undefined value.
Validates the specified character by checking if they are already validated.
48 49 50 51 52 53 54 |
# File 'documented/dragonrealms/commons/common-validation.rb', line 48 def validate(character) return if valid?(character) return unless lnet_available? Lich::Messaging.msg("plain", "CharacterValidator: Attempting to validate: #{character}") @lnet.unique_buffer.push("who #{character}") end |