#===============================================================================
# 为了能够把数组读出来啦
#===============================================================================
class Game_Party
attr_accessor :items
attr_accessor :weapons
attr_accessor :armors
end
#===============================================================================
module Crysse
#===============================================================================
# 查找背包内的物品并返回数组
# 条件:稀有度,判定方向(< 小于 =等于 >大于)
#===============================================================================
def self.oks_search(rarity = 0, dir = "<=")
#防手滑
return {},{},0,0 if $game_party == nil
res1 = {} #结果数组
res2 = {} #结果数组
amount = 0 #总价
count = 0 #计数
# 执行筛选武器
$game_party.weapons.each{|i,n|
e = $data_weapons[i]
if( eval( e.rarity.to_s + dir + rarity.to_s))
res1[i] = n
amount += n * e.price
count += n
end
}
# 执行筛选防具
$game_party.armors.each{|i,n|
e = $data_armors[i]
if( eval( e.rarity.to_s + dir + rarity.to_s))
res2[i] = n
amount += n * e.price
count += n
end
}
#返回结果数组和总价
return res1,res2,amount,count
end
#=============================================================================
# 熟练地售出条件指定品质的装备
# 条件:稀有度,判定方向(< 小于 =等于 >大于)
# 可变调用,输入已经筛选的结果,或者是按照条件查找
#=============================================================================
#def self.oks_sale(rarity = 0, dir = "<=")
def self.oks_sale(ary = 0,dir = "<=")
ary = ary
if ary == 0
ary = oks_search(ary, dir)
end
res1 = ary[0]
res2 = ary[1]
amount = ary[2]
count = ary[3]
text = "售出#{count}件装备,获得#{amount}#{$data_system.words.gold},确定吗?"
#调用显示确认窗口
text_window = Window_Base.new(150,150,396,80)
text_window.contents = Bitmap.new(360,64)
text_window.contents.draw_text(0, 0, 360, 64, text)
window = Window_Command.new(128,["确定","取消"])
window.x = 150
window.y = 232
loop do
Input.update
Graphics.update
window.update
if Input.trigger?(Input::C)
case window.index
when 0
$game_system.se_play($data_system.decision_se)
res1.each{|i,n|$game_party.lose_weapon(i, n)}
res2.each{|i,n|$game_party.lose_armor(i, n)}
$game_party.gain_gold(amount)
Graphics.freeze
text_window.dispose
window.dispose
Graphics.transition
return true
when 1
$game_system.se_play($data_system.cancel_se)
Graphics.freeze
text_window.dispose
window.dispose
Graphics.transition
return false
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
Graphics.freeze
text_window.dispose
window.dispose
Graphics.transition
return false
end
end
end
#=============================================================================
# 根据颜色选择
#=============================================================================
def self.oks_sale_color(colors = "白") #多选,oks_sale_color("灰白绿蓝紫红金")
rst = [{},{},0,0]
#colors = colors.scan(/./)
if colors.include?("灰") #0-
rst.addup(oks_search(0,"<"))
end
if colors.include?("白") #0
rst.addup(oks_search(0,"=="))
end
if colors.include?("绿") #1
rst.addup(oks_search(1,"=="))
end
if colors.include?("蓝") #23
rst.addup(oks_search(2,"=="))
end
if colors.include?("紫") #45
rst.addup(oks_search(4,"=="))
rst.addup(oks_search(5,"=="))
end
if colors.include?("红") #67
rst.addup(oks_search(3,"=="))
end
if colors.include?("金") #8+
rst.addup(oks_search(6,">="))
end
return oks_sale(rst)
end
#=============================================================================
# 选择颜色并显示统计结果
#=============================================================================
def self.oks_sel
text_window = Window_Base.new(150,150,396,80)
text_window.contents = Bitmap.new(350,64)
text_window.contents.font.size = 15
text_window.contents.draw_text(0, 0, 350, 64, "↑选中 ↓取消 ←→移动 空格键出售 ESC退出")
w1 = Window_Base.new(150,150,396,80)
w1.contents = Bitmap.new(360,80)
i = 0
ary = ["灰","白","绿","蓝","紫","红","金"]
aryc = [ Color.new(160,160,160),
Color.new(255,255,255),
Color.new(0,255,0),
Color.new(0,120,255),
Color.new(160, 0, 255),
Color.new(255,120,0),
Color.new(255,255,0)
]
arys = [false,false,false,false,false,false,false]
cur = 0
b = Color.new(0,255,0)
w = Color.new(255,255,255)
for c in 0..ary.size-1
if(cur == c)
w1.contents.fill_rect( 4+c * 24 - 1,3,18,18,b)
w1.contents.fill_rect( 4+c * 24 - 2,2,20,20,w)
end
if(arys[c])
w1.contents.fill_rect( 4+c * 24 - 4,0,24,24,b)
end
w1.contents.fill_rect( 4+c * 24,4,16,16,aryc[c])
end
ofr = Graphics.frame_rate
Graphics.frame_rate = 2
loop do
Input.update
Graphics.update
if(Input.trigger?(Input::C))
$game_system.se_play($data_system.decision_se)
cs = ""
for i in 0..ary.size-1
if(arys[i])
cs += ary[i]
end
end
Graphics.frame_rate = ofr
text_window.visible = false
text_window.update
if(oks_sale_color cs)
break
end
text_window.visible = true
text_window.update
ofr = Graphics.frame_rate
Graphics.frame_rate = 2
end
if(Input.trigger?(Input::B))
$game_system.se_play($data_system.cancel_se)
break
end
case(Input.dir4)
when 2
$game_system.se_play($data_system.cancel_se)
arys[cur] = false
when 4
cur = (cur + arys.size - 1) % arys.size
when 6
cur = (cur + arys.size + 1) % arys.size
when 8
$game_system.se_play($data_system.decision_se)
arys[cur] = true
end
w1.contents.clear
for c in 0..ary.size-1
if(arys[c])
w1.contents.fill_rect( 4+c * 24 - 4,0,24,24,b)
end
if(cur == c)
w1.contents.fill_rect( 4+c * 24 - 1,3,18,18,b)
w1.contents.fill_rect( 4+c * 24 - 2,2,20,20,w)
end
w1.contents.fill_rect( 4+c * 24,4,16,16,aryc[c])
end
end
Graphics.frame_rate = ofr
Graphics.freeze
w1.dispose
text_window.dispose
Graphics.transition
end
end