#==============================================================================
#  @> Better Drops Text ~ Karin's Soulkeeper, 2015
#------------------------------------------------------------------------------
#   v1.0 - May 14 : Started & finished.
#------------------------------------------------------------------------------
#  * Description:
#    This script's pretty straightforward. It simply replaces the plain old:
#    "Obtained 21463G!"
#    "Obtained Potion!"
#    "Obtained Potion!"
#    "Obtained Potion!"
#
#    With:
#    "Obtained 21463[gcon]!"
#    "Obtained 3 [icon]Potions!"
#
#    In the above, [gcon] is the icon as set in GOLD_ICON below
#    [icon] automatically retrieves the item's icon, as set in the database.
#
#------------------------------------------------------------------------------
#  * To Use:
#    Put this script below Materials and above Main.
#------------------------------------------------------------------------------
#  * Compatibility:
#    This script overwrites BattleManager.gain_drop_items
#------------------------------------------------------------------------------
#  * 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 DROPTEXT
  #--------------------------------------------------------------------------
  # Sets the text to be used for when receiving gold
  #--------------------------------------------------------------------------
  # Escape characters are the same as those used in message boxes.
  #--------------------------------------------------------------------------
  RECV_GOLD = 'Obtained %d\I[%d]!'
    
  #--------------------------------------------------------------------------
  # Sets the icon index to be used for the Obtain Gold text
  #--------------------------------------------------------------------------
  GOLD_ICON = 361

  #--------------------------------------------------------------------------
  # Sets the text to be used for when receiving items
  #--------------------------------------------------------------------------
  RECV_ITEM = 'Obtained %s!'
  
  end
end
# END OF CUSTOMIZATION OPTIONS

#==============================================================================
# ** Modified Module: BattleManager
#==============================================================================
module BattleManager
  #--------------------------------------------------------------------------
  # * Overwrite: Gold Acquisition and Display
  #--------------------------------------------------------------------------
  def self.gain_gold
    if $game_troop.gold_total > 0
      text = sprintf(KS::DROPTEXT::RECV_GOLD, $game_troop.gold_total, KS::DROPTEXT::GOLD_ICON)
      $game_message.add('\.' + text)
      $game_party.gain_gold($game_troop.gold_total)
    end
    wait_for_message
  end
  
  #--------------------------------------------------------------------------
  # * Overwrite: Dropped Item Acquisition and Display
  #--------------------------------------------------------------------------
  def self.gain_drop_items
    items = []
    $game_troop.make_drop_items.each do |item|
      $game_party.gain_item(item, 1)
      items.push(item)
    end
    fin = []
    for item in items
      if ! fin.include?(item)
        num = sprintf("%d", items.count(item))
        icn = sprintf('\I[%d]', item.icon_index)
        s = items.count(item) > 1 ? 's' : ''
        fin.push(item)
        $game_message.add(sprintf(KS::DROPTEXT::RECV_ITEM, num + icn + item.name + s))
      end
    end
    wait_for_message
  end
end