class RPG::Enemy

Public Class Methods

new(hash) click to toggle source
# File lib/rmxp_extractor/classnames.rb, line 1016
def initialize(hash)
  hash.each do |key, value|
    if value.is_a?(Hash)
      eval("@#{key.to_s}=Table.new(value, false)")
    elsif value.is_a?(Array)
      @actions = []
      value.each_with_index do |value|
        @actions << RPG::Enemy::Action.new(value)
      end
    else
      eval("@#{key.to_s}=value")
    end
  end
end

Public Instance Methods

hash() click to toggle source
# File lib/rmxp_extractor/classnames.rb, line 1031
def hash
  dump = {
    id: @id,
    name: @name.force_encoding("iso-8859-1").encode("utf-8"),
    battler_name: @battler_name,
    battler_hue: @battler_hue,
    maxhp: @maxhp,
    maxsp: @maxsp,
    str: @str,
    dex: @dex,
    agi: @agi,
    int: @int,
    atk: @atk,
    pdef: @pdef,
    mdef: @mdef,
    eva: @eva,
    animation1_id: @animation1_id,
    animation2_id: @animation2_id,
    element_ranks: @element_ranks.hash,
    state_ranks: @state_ranks.hash,
    actions: [],
    exp: @exp,
    gold: @gold,
    item_id: @item_id,
    weapon_id: @weapon_id,
    armor_id: @armor_id,
    treasure_prob: @treasure_prob,
  }
  @actions.each_with_index do |value|
    dump[:actions] << value.hash
  end
  dump
end