
class Element
  def numChangePages
    @changePages.length
  end
  def numChangePages=(n)
    if n < @changePages.length
      @changePages = @changePages[0...n]
    end
    while n > @changePages.length
      @changePages.push(ChangePage.new)
    end
    if @current_change_page >= numChangePages
      @current_change_page = numChangePages - 1;
    end
  end
  def change
    @changePages[@current_change_page]
  end
  
  # TODO: put "@current_change_page=0" into initialize
  
  # ---------- token and description strings ----------

  char *token_name             # element token used in config files
  char *class_name             # element class used in config files
  char *editor_description     # pre-defined description for level editor
  char *custom_description     # alternative description from config file
  char description[MAX_ELEMENT_NAME_LEN + 1]   # for custom/group elements

  # ---------- graphic and sound definitions ----------

  int graphic[NUM_ACTIONS]     # default graphics for several actions
  int direction_graphic[NUM_ACTIONS][NUM_DIRECTIONS]
                # special graphics for left/right/up/down

  int crumbled[NUM_ACTIONS]    # crumbled graphics for several actions
  int direction_crumbled[NUM_ACTIONS][NUM_DIRECTIONS]
                # crumbled graphics for left/right/up/down

  int special_graphic[NUM_SPECIAL_GFX_ARGS]
                # special graphics for certain screens

  int sound[NUM_ACTIONS]       # default sounds for several actions

  # ---------- special element property values ----------

  boolean use_gfx_element      # use custom graphic element
  short gfx_element            # optional custom graphic element

  int access_direction         # accessible from which direction

  int collect_score            # score value for collecting
  int collect_count            # count value for collecting

  int push_delay_fixed         # constant delay before pushing
  int push_delay_random        # additional random delay before pushing
  int drop_delay_fixed         # constant delay after dropping
  int drop_delay_random        # additional random delay after dropping
  int move_delay_fixed         # constant delay after moving
  int move_delay_random        # additional random delay after moving

  int move_pattern             # direction movable element moves to
  int move_direction_initial   # initial direction element moves to
  int move_stepsize            # step size element moves with

  int move_enter_element       # element that can be entered (and removed)
  int move_leave_element       # element that can be left behind
  int move_leave_type          # change (limited) or leave (unlimited)

  int slippery_type            # how/where other elements slip away

  int content[3][3]            # new elements after explosion

  int explosion_type           # type of explosion, like 3x3, 3+3 or 1x1
  int explosion_delay          # duration of explosion of this element
  int ignition_delay           # delay for explosion by other explosion

  struct ChangePage *change_page # actual list of change pages # => changePages
  struct ChangePage *change    # pointer to current change page # THIS IS A VIRTUAL ATTRIBUTE

  int num_change_pages         # actual number of change pages
  int current_change_page      # currently edited change page

  # ------------------ attributes of group elements ------------------
  int num_elements             # number of elements in this group
  short element[MAX_ELEMENTS_IN_GROUP] # list of elements in this group

  int choice_mode              # how to choose element from group

  # ---------- internal values used at runtime when playing ----------

#   # the following is the same as above, but with recursively resolved group
#   # elements (group elements may also contain further group elements!)
#   int num_elements_resolved
#   short element_resolved[NUM_FILE_ELEMENTS]
# 
#   int choice_pos               # current element choice position
# 
#   boolean has_change_event[NUM_CHANGE_EVENTS]
# 
#   int event_page_nr[NUM_CHANGE_EVENTS] # page number for each event
#   struct ChangePage *event_page[NUM_CHANGE_EVENTS] # page for event
# 
#   boolean in_group[NUM_GROUP_ELEMENTS]

  # ---------- internal values used in level editor ----------

# TODO: change these into virtual attributes
  int access_type              # walkable or passable
  int access_layer             # accessible over/inside/under
  int access_protected         # protection against deadly elements
  int walk_to_action           # diggable/collectible/pushable
  int smash_targets            # can smash player/enemies/everything
  int deadliness               # deadly when running/colliding/touching

  boolean can_explode_by_fire  # element explodes by fire
  boolean can_explode_smashed  # element explodes when smashed
  boolean can_explode_impact   # element explodes on impact

  boolean modified_settings    # set for all modified custom elements
end

