global
def self.get_parameter_translated(code, parameter, hashmap, game_type)
-
game_type
(String
) -- -
hashmap
(Hash{String => String}
) -- Translation hashmap (as everything in Ruby passed by reference, this pass is free!) -
parameter
(String
) -- -
code
(Integer
) --
def self.get_parameter_translated(code, parameter, hashmap, game_type) # @type [Array<String>] remaining_strings = [] # @type [Array<Boolean>] # true - insert at end # false - insert at start insert_positions = [] ends_with_if = parameter[/ if\(.*\)$/] if ends_with_if parameter = parameter.chomp(ends_with_if) remaining_strings.push(ends_with_if) insert_positions.push(true) end if game_type case game_type when 'lisa' case code when 401, 405 prefix = parameter[/^(\\et\[[0-9]+\]|\\nbt)/] parameter = parameter.sub(prefix, '') if prefix remaining_strings.push(prefix) insert_positions.push(false) else nil end # Implement cases for other games else nil end end translated = hashmap[parameter] return nil if !translated || translated.empty? remaining_strings .zip(insert_positions) .each do |string, position| if !position translated = string + translated else translated += string end end translated end