class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# ● 增加持有金钱
#--------------------------------------------------------------------------
def +(gold)
gain_gold(gold)
self
end
#--------------------------------------------------------------------------
# ● 减少持有金钱
#--------------------------------------------------------------------------
def -(gold)
lose_gold(gold)
self
end
#--------------------------------------------------------------------------
# ● 使角色离队
#--------------------------------------------------------------------------
def delete(actor)
return unless include?(actor)
remove_actor(actor.id)
actor
end
#--------------------------------------------------------------------------
# ● 使指定位置的成员离队
#--------------------------------------------------------------------------
def delete_at(index)
delete(members[index])
end
#--------------------------------------------------------------------------
# ● 使指定位置的成员离队
#--------------------------------------------------------------------------
def slice!(*args)
actors = members[*args]
if actors.kind_of?(Array)
actors.each(&method(:delete))
else
delete(actors)
end
end
#--------------------------------------------------------------------------
# ● 删除符合 block 条件的角色
#--------------------------------------------------------------------------
def delete_if
return to_enum(__method__) unless block_given?
members.each {|actor| delete(actor) if yield actor }
self
end
#--------------------------------------------------------------------------
# ● 删除最后的队员
#--------------------------------------------------------------------------
def pop(n = nil)
return slice!(-1) unless n
n = size if n > size
slice!(-n, n)
end
#--------------------------------------------------------------------------
# ● 添加队员
#--------------------------------------------------------------------------
def <<(actor)
add_actor(actor.id)
self
end
#--------------------------------------------------------------------------
# ● 添加队员
#--------------------------------------------------------------------------
def push(*actors)
actors.each {|actor| add_actor(actor.id) }
self
end
#--------------------------------------------------------------------------
# ● 删除领头的队员
#--------------------------------------------------------------------------
def shift(n = nil); n ? slice!(0, n) : slice!(0); end
end