Module: Util::SystemMessage

Included in:
Interpreter
Defined in:
docs/4_Systems_004_Message.rb

Overview

Module that help showing system message.

How to use it : “‘ruby

include Util::SystemMessage
# ...
  show_message(:message_name) # Basic message
  if yes_no_choice(load_message(:message_name)) # Choice from interpreter
    show_message(:message_name, pokemon: pokemon) # Will set PKNICK[0] & PKNAME[0]
    show_message(:message_name, pokemon_1: pokemon) # Will set PKNICK[1] & PKNAME[1]
    show_message(:message_name, item: item_id, pokemon: pokemon) # Will set ITEM2[0], PKNICK[0] & PKNAME[0]
    show_message_and_wait(:message_name) # Will wait until the message box disappear

“‘

How to define “:message_name”s :

- Simple message (from RH) : `Util::SystemMessage::MESSAGES[:message_name] = [:text_get, id, line]`
- Complex message : `Util::SystemMessage::MESSAGES[:message_name] = proc { |opts| next(message_contents) }`

Note : opts are the optionnals arguments sent to show_message

Constant Summary collapse

MESSAGES =

List of message by name

{received_pokemon: [:ext_text, 8999, 15], give_nickname_question: [:ext_text, 8999, 16], is_nickname_correct_qesion: [:ext_text, 8999, 17], pokemon_stored_to_box: [:ext_text, 8999, 18], bag_store_item_in_pocket: [:text_get, 41, 9], pokemon_shop_unavailable: [:ext_text, 9003, 1]}
HAS_NUMBER_REG =

Capture regexp

/_([0-9]+)$/
IS_POKEMON =

Tell if the key contain pokemon

/^pokemon/
IS_ITEM =

Tell if the key contain item

/^item/
IS_NUMBER1 =

Tell if the key contain num1

/^num1/
IS_NUMBER2 =

Tell if the key contain num2

/^num2/
IS_NUMBER3 =

Tell if the key contain num3

/^num3/

Class Method Summary collapse

Class Method Details

.load_message(message_name, opts = nil)

Load a message

Parameters:

  • message_name (Symbol)

    ID of the message in MESSAGES

  • opts (Hash) (defaults to: nil)

    options (additional text replacement)



39
40
# File 'docs/4_Systems_004_Message.rb', line 39

def load_message(message_name, opts = nil)
end

.parse_opts(opts)

Parse the message opts

Parameters:

  • opts (Hash)

    options (additional text replacement)



53
54
# File 'docs/4_Systems_004_Message.rb', line 53

def parse_opts(opts)
end

.show_message(message_name, opts = nil)

Show a message

Parameters:

  • message_name (Symbol)

    ID of the message in MESSAGES

  • opts (Hash) (defaults to: nil)

    options (additional text replacement)



44
45
# File 'docs/4_Systems_004_Message.rb', line 44

def show_message(message_name, opts = nil)
end

.show_message_and_wait(message_name, opts = nil)

Show a message

Parameters:

  • message_name (Symbol)

    ID of the message in MESSAGES

  • opts (Hash) (defaults to: nil)

    options (additional text replacement)



49
50
# File 'docs/4_Systems_004_Message.rb', line 49

def show_message_and_wait(message_name, opts = nil)
end