#==============================================================================
#  @> Cycle Party Members ~ Karin's Soulkeeper, 2015
#------------------------------------------------------------------------------
#   v1.1 - Jan 17 : Took out !repeat?
#   v1.0 - May 10 : Started & finished.
#------------------------------------------------------------------------------
#  * Description:
#    This script allows one to quickly change the order of the party with
#    just one script call. As an example, say we have this party:
#    ["Alex", "Bard", "Lea", "Go"]; Calling the script will change the party's
#    order to: ["Bard", "Lea", "Go", "Alex"]; And that's pretty much it.
#    Useful for, you know, doing stuff.
#------------------------------------------------------------------------------
#  * To Use:
#    Put this script below Materials and above Main.
#    In map: Press the CYCLE_BUTTON assigned below
#    Script Call: $game_party.cycle_members
#------------------------------------------------------------------------------
#  * Compatibility:
#    This script aliases Scene_Map.update; aside from that, this script
#    should be compatible with all other scripts, including those
#    that modify Game_Party.
#------------------------------------------------------------------------------
#  * Terms:
#    Free to use in any kind of project, with or without credit. I wouldn't
#    really mind. Though I'd appreciate it! (^w^)/
#    Just don't, you know, claim that you made this here script yourself,
#    Because that's just mean (._.)
#==============================================================================

#CUSTOMIZATION OPTIONS
module KS
  module Cycle_Party
  #--------------------------------------------------------------------------
  # Set the button that will trigger the cycle party method (Default: [S])
  # Set to nil to disable.
  #--------------------------------------------------------------------------
  CYCLE_BUTTON = (:Y)
  
  #--------------------------------------------------------------------------
  # Set the sfx to play when cycling. Set to nil to disable. (checks Audio/SE/)
  #--------------------------------------------------------------------------
  CYCLE_SFX = nil
  
  end
end
# END OF CUSTOMIZATION OPTIONS

#==============================================================================
# ** Modified Class: Game_Party
#==============================================================================

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # * New: Cycle Members of Party
  #--------------------------------------------------------------------------
  def cycle_members
    return unless @actors.size > 1
    temp = @actors[0]
    for x in 1...@actors.size
      @actors[x-1] = @actors[x]
    end
    @actors[-1] = temp
    print "Cycled Party: #{@actors};\n"
    $game_player.refresh
    return unless KS::Cycle_Party::CYCLE_SFX
    Audio.se_play(sprintf("Audio/SE/%s", KS::Cycle_Party::CYCLE_SFX))
  end
end

#==============================================================================
# ** Alias Class: Scene_Map
#==============================================================================

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias: Frame Update
  #--------------------------------------------------------------------------
  alias gorgo update
  def update
    gorgo
    $game_party.cycle_members if KS::Cycle_Party::CYCLE_BUTTON && Input.trigger?(KS::Cycle_Party::CYCLE_BUTTON)
  end
end