#==============================================================================
# ** TDS Auto Battle Command
#    Ver: 1.0
#------------------------------------------------------------------------------
#  * Description:
#  This script adds a command to battle that makes characters select their 
#  actions automatically.
#------------------------------------------------------------------------------
#  * Features: 
#  A command to automate Actor battler actions.
#------------------------------------------------------------------------------
#  * Instructions:
#  Just put it in your game under the "Materials" area of the script list and
#  enjoy.
#------------------------------------------------------------------------------
#  * Notes:
#  None.
#------------------------------------------------------------------------------
# WARNING:
#
# Do not release, distribute or change my work without my expressed written 
# consent, doing so violates the terms of use of this work.
#
# If you really want to share my work please just post a link to the original
# site.
#
# * Not Knowing English or understanding these terms will not excuse you in any
#   way from the consequenses.
#==============================================================================
# * Import to Global Hash *
#==============================================================================
($imported ||= {})[:TDS_Auto_Battle_Command] = true

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------  
  alias tds_auto_battle_command_scene_battle_create_party_command_window  create_party_command_window
  #--------------------------------------------------------------------------
  # * Create Party Commands Window
  #--------------------------------------------------------------------------
  def create_party_command_window(*args, &block)    
    # Run Original Method
    tds_auto_battle_command_scene_battle_create_party_command_window(*args, &block)
    # Set Auto Battle Handler
    @party_command_window.set_handler(:auto_battle, method(:command_auto_battle))
  end
  #--------------------------------------------------------------------------
  # * [Auto Battle] Command
  #--------------------------------------------------------------------------
  def command_auto_battle
    # Make Auto Battle Actions for Alive Party Members
    $game_party.alive_members.each {|a| a.make_auto_battle_actions}
    # Start Turn
    turn_start
  end
end


#==============================================================================
# ** Window_PartyCommand
#------------------------------------------------------------------------------
#  This window is used to select whether to fight or escape on the battle
# screen.
#==============================================================================

class Window_PartyCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------  
  alias tds_auto_battle_command_window_partycommand_make_command_list make_command_list
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list(*args, &block)
    # Run Original Method
    tds_auto_battle_command_window_partycommand_make_command_list(*args, &block)
    # Add Auto Battle Command
    add_command("Auto Battle", :auto_battle)    
  end
end