Class: Object

Inherits:
BasicObject
Defined in:
scripts/00002 state.rb,
scripts/00800 Studio/00001 Accessors.rb,
scripts/00000 Dependencies/00201 Object.rb,
scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb,
scripts/00700 Ajout_PSDK/00001 Graphics Debug.rb,
scripts/01450 Systems/00000 General/00300 Random.rb

Constant Summary collapse

EMPTY_OPTIONAL =

Array representing an empty optional key hash

[].freeze
VALIDATE_PARAM_ERROR =

Default error message

'Parameter %<param_name>s sent to %<method_name>s is incorrect : %<reason>s'
EXC_MSG =

Exception message

'Invalid param value passed to %s#%s, see previous errors to know what are the invalid params'

Instance Method Summary collapse

Instance Method Details

#_clean_name_utf8(arr) ⇒ arr

Clean an array containing object responding to #name (force utf-8)

Parameters:

  • arr (Array<#name>)

Returns:

  • (arr)


50
51
52
53
54
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 50

def _clean_name_utf8(arr)
  utf8 = Encoding::UTF_8
  arr.each { |o| o&.name&.force_encoding(utf8) }
  return arr
end

#bchance?(rate, logic = nil) ⇒ Boolean

Attempt to get for the battles

Parameters:

  • rate (Float)

    number between 0 & 1 telling how much chance we have

  • logic (Battle::Logic) (defaults to: nil)

Returns:

  • (Boolean)


32
33
34
35
36
37
# File 'scripts/01450 Systems/00000 General/00300 Random.rb', line 32

def bchance?(rate, logic = nil)
  logic ||= (@logic || ($scene.is_a?(Battle::Scene) ? $scene.logic : nil))
  raise 'bchance? called outside of Battle!' unless logic

  return logic.generic_rng.rand < rate
end

#ext_text(file_id, text_id) ⇒ String

Get a text front the external text database

Parameters:

  • file_id (Integer)

    ID of the text file

  • text_id (Integer)

    ID of the text in the file

Returns:



60
61
62
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 60

def ext_text(file_id, text_id)
  Studio::Text.get_external(file_id, text_id)
end

#help

Method that shows the help



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'scripts/00700 Ajout_PSDK/00001 Graphics Debug.rb', line 55

def help
  cc 0x75
  puts "\r#{'PSDK Help'.center(80)}"
  cc 0x07
  print <<~EODESCRIPTION
    Here's the list of the command you can enter in this terminal.
    Remember that you're executing actual Ruby code.
    When an ID is 005 or 023 you have to write 5 or 23, the 0-prefix should never appear in the command you enter.
  EODESCRIPTION
  cc 0x06
  print <<~EOLIST
    Warp the player to another map :\e[37m
      - Debugger.warp(map_id, x, y)\e[36m
    Test a trainer battle :\e[37m
      - Debugger.battle_trainer(trainer_id)\e[36m
    Add a Pokemon to the party :\e[37m
      - S.MI.add_pokemon(id, level)\e[36m
    Add a Pokemon defined by a Hash to the party :\e[37m
      - S.MI.add_specific_pokemon(hash)\e[36m
    Remove a Pokemon from the Party :\e[37m
      - S.MI.withdraw_pokemon_at(index)\e[36m
    Learn a skill to a Pokemon :\e[37m
      - S.MI.skill_learn(pokemon, skill_id)
      - S.MI.skill_learn($actors[index_in_the_party], skill_id)\e[36m
    Add an egg to the party :\e[37m
      - S.MI.add_egg(id)\e[36m
    Start a wild battle :\e[37m
      - S.MI.call_battle_wild(id, level)
      - S.MI.call_battle_wild(id1, level1, id2, level2) \e[32m# 2v2\e[37m
      - S.MI.call_battle_wild(pokemon, nil)
      - S.MI.call_battle_wild(pokemon1, nil, pokemon2)\e[36m
    Save the game :\e[37m
      - S.MI.force_save
  EOLIST
end

#parse_text(file_id, text_id, additionnal_var = nil) ⇒ String

Parse a text from the text database with specific informations

Parameters:

  • file_id (Integer)

    ID of the text file

  • text_id (Integer)

    ID of the text in the file

  • additionnal_var (nil, Hash{String => String}) (defaults to: nil)

    additional remplacements in the text

Returns:

  • (String)

    the text parsed and ready to be displayed



28
29
30
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 28

def parse_text(file_id, text_id, additionnal_var = nil)
  PFM::Text.parse(file_id, text_id, additionnal_var)
end

#parse_text_with_2pokemon(file_id, text_id, pokemon1, pokemon2, additionnal_var = nil) ⇒ String

Parse a text from the text database with 2 pokemon & specific information

Parameters:

  • file_id (Integer)

    ID of the text file

  • text_id (Integer)

    ID of the text in the file

  • pokemon1 (PFM::Pokemon)

    pokemon we're talking about

  • pokemon2 (PFM::Pokemon)

    pokemon who originated the “problem” (eg. bind)

  • additionnal_var (nil, Hash{String => String}) (defaults to: nil)

    additional remplacements in the text

Returns:

  • (String)

    the text parsed and ready to be displayed



19
20
21
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 19

def parse_text_with_2pokemon(file_id, text_id, pokemon1, pokemon2, additionnal_var = nil)
  PFM::Text.parse_with_2pokemon(file_id, text_id, pokemon1, pokemon2, additionnal_var)
end

#parse_text_with_pokemon(file_id, text_id, pokemon, additionnal_var = nil) ⇒ String

Parse a text from the text database with specific informations and a pokemon

Parameters:

  • file_id (Integer)

    ID of the text file

  • text_id (Integer)

    ID of the text in the file

  • pokemon (PFM::Pokemon)

    pokemon that will introduce an offset on text_id (its name is also used)

  • additionnal_var (nil, Hash{String => String}) (defaults to: nil)

    additional remplacements in the text

Returns:

  • (String)

    the text parsed and ready to be displayed



8
9
10
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 8

def parse_text_with_pokemon(file_id, text_id, pokemon, additionnal_var = nil)
  PFM::Text.parse_with_pokemon(file_id, text_id, pokemon, additionnal_var)
end

#play_actor_collapse_se

Play the Actor collapse SE



110
111
112
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 110

def play_actor_collapse_se
  $game_system&.se_play($data_system&.actor_collapse_se)
end

#play_buzzer_se

Play buzzer SE



75
76
77
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 75

def play_buzzer_se
  $game_system&.se_play($data_system&.buzzer_se)
end

#play_cancel_se

Play cancel SE



80
81
82
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 80

def play_cancel_se
  $game_system&.se_play($data_system&.cancel_se)
end

#play_cursor_se

Play cursor SE



70
71
72
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 70

def play_cursor_se
  $game_system&.se_play($data_system&.cursor_se)
end

#play_decision_se

Play decision SE



65
66
67
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 65

def play_decision_se
  $game_system&.se_play($data_system&.decision_se)
end

#play_enemy_collapse_se

Play the Enemy collapse SE



115
116
117
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 115

def play_enemy_collapse_se
  $game_system&.se_play($data_system&.enemy_collapse_se)
end

#play_equip_se

Play the Equip SE



85
86
87
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 85

def play_equip_se
  $game_system&.se_play($data_system&.equip_se)
end

#play_escape_se

Play the Escape SE



105
106
107
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 105

def play_escape_se
  $game_system&.se_play($data_system&.escape_se)
end

#play_load_se

Play the Load SE



100
101
102
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 100

def play_load_se
  $game_system&.se_play($data_system&.load_se)
end

#play_save_se

Play the Save SE



95
96
97
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 95

def play_save_se
  $game_system&.se_play($data_system&.save_se)
end

#play_shop_se

Play the Shop SE



90
91
92
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 90

def play_shop_se
  $game_system&.se_play($data_system&.shop_se)
end

#text_file_get(file_id) ⇒ Array<String>

Get a list of text from the text database

Parameters:

  • file_id (Integer)

    ID of the text file

Returns:

  • (Array<String>)

    the list of text contained in the file.



43
44
45
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 43

def text_file_get(file_id)
  Studio::Text.get_file(file_id)
end

#text_get(file_id, text_id) ⇒ String

Get a text front the text database

Parameters:

  • file_id (Integer)

    ID of the text file

  • text_id (Integer)

    ID of the text in the file

Returns:



36
37
38
# File 'scripts/00700 Ajout_PSDK/01300 PSDK_Def.rb', line 36

def text_get(file_id, text_id)
  Studio::Text.get(file_id, text_id)
end

#validate_param(method_name, *param_names, param_values)

Note:

To use a custom message, define a validate_param_message

Function that validate the input paramters

Examples:

Param with a static type

validate_param(:meth, :param, param => Type)

Param with various allowed types

validate_param(:meth, :param, param => [Type1, Type2])

Param using a validation method

validate_param(:meth, :param, param => :validation_method)

Param using a complex structure (Array of String)

validate_param(:meth, :param, param => { Array => String })

Param using a complex structure (Array of Symbol, Integer, String, repetetive)

validate_param(:meth, :param, param => { Array => [Symbol, Integer, String], :cyclic => true, min: 3, max: 9})

Param using a complex structure (Hash)

validate_param(:meth, :param, param => { Hash => { key1: Type, key2: Type2, key3: [String, Symbol] },
                                         :optional => [:key2] })

Parameters:

  • method_name (Symbol)

    name of the method which its param are being validated

  • param_names (Array<Symbol>)

    list of the names of the params

  • param_values (Hash)

    hash associating a param value to the expected type (description)

Raises:

  • (ArgumentError)


26
27
28
29
30
31
32
33
34
# File 'scripts/00000 Dependencies/00201 Object.rb', line 26

def validate_param(method_name, *param_names, param_values)
  index = 0
  exception = false
  param_values.each do |param_value, param_types|
    exception |= validate_param_value(method_name, param_names[index], param_value, param_types)
    index += 1
  end
  raise ArgumentError, format(EXC_MSG, self.class, method_name) if exception
end

#void(*args)

Function that does nothing and return nil

Examples:

alias function_to_disable void


39
40
41
# File 'scripts/00000 Dependencies/00201 Object.rb', line 39

def void(*args)
  return nil
end

#void0(*args)

Function that does nothing and return 0

Examples:

alias function_to_disable void0


60
61
62
# File 'scripts/00000 Dependencies/00201 Object.rb', line 60

def void0(*args)
  return 0
end

#void_array(*args)

Function that does nothing and return []

Examples:

alias function_to_disable void_array


67
68
69
# File 'scripts/00000 Dependencies/00201 Object.rb', line 67

def void_array(*args)
  return nil.to_a
end

#void_false(*args)

Function that does nothing and return false

Examples:

alias function_to_disable void_false


53
54
55
# File 'scripts/00000 Dependencies/00201 Object.rb', line 53

def void_false(*args)
  return false
end

#void_string(*args)

Function that does nothing and return “”

Examples:

alias function_to_disable void_array


74
75
76
# File 'scripts/00000 Dependencies/00201 Object.rb', line 74

def void_string(*args)
  return nil.to_s
end

#void_true(*args)

Function that does nothing and return true

Examples:

alias function_to_disable void_true


46
47
48
# File 'scripts/00000 Dependencies/00201 Object.rb', line 46

def void_true(*args)
  return true
end