Release 0.0.1.8.8.7
This commit is contained in:
1 parent
3c8a17aa78
commit
c7beab414c
16283 files changed
+768761
-2
No files matched your search
@@ -0,0 +1,154 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
module MPItemDescriptionEffects
|
||||
SHOW_EMPTY_LINE = true
|
||||
MAX_PARTS = 3
|
||||
|
||||
STAT_LABELS = {
|
||||
"health" => "здоровью",
|
||||
"sta" => "выносливости",
|
||||
"sat" => "сытости",
|
||||
"mood" => "настроению",
|
||||
"atk" => "силе",
|
||||
"atk_plus" => "силе",
|
||||
"def" => "защите",
|
||||
"def_plus" => "защите",
|
||||
"wisdom" => "мудрости",
|
||||
"wisdom_plus" => "мудрости",
|
||||
"survival" => "выживанию",
|
||||
"survival_plus" => "выживанию",
|
||||
"morality" => "морали",
|
||||
"morality_plus" => "морали",
|
||||
"weak" => "слабости",
|
||||
"sexy" => "сексуальности",
|
||||
"move_speed" => "скорости",
|
||||
"arousal" => "возбуждению"
|
||||
}
|
||||
|
||||
PARAM_LABELS = [
|
||||
"макс. здоровью",
|
||||
"макс. магии",
|
||||
"силе",
|
||||
"защите",
|
||||
"маг. силе",
|
||||
"маг. защите",
|
||||
"ловкости",
|
||||
"удаче"
|
||||
]
|
||||
|
||||
def self.line(item)
|
||||
parts = parts_for(item)
|
||||
return SHOW_EMPTY_LINE ? "Даёт: без бонусов." : "" if parts.empty?
|
||||
parts = parts[0, MAX_PARTS]
|
||||
"Даёт: #{parts.join(', ')}"
|
||||
rescue
|
||||
SHOW_EMPTY_LINE ? "Даёт: без бонусов." : ""
|
||||
end
|
||||
|
||||
def self.parts_for(item)
|
||||
return [] if item.nil?
|
||||
|
||||
load_effects(item)
|
||||
|
||||
parts = []
|
||||
effects = []
|
||||
effects.concat(item.use_item_effect) if item.respond_to?(:use_item_effect) && item.use_item_effect
|
||||
effects.concat(item.lona_effect) if item.respond_to?(:lona_effect) && item.lona_effect
|
||||
|
||||
effects.compact.each do |effect|
|
||||
text = format_effect(effect)
|
||||
parts << text unless text.nil? || text.empty?
|
||||
end
|
||||
|
||||
if item.respond_to?(:params) && item.params
|
||||
item.params.each_with_index do |value, index|
|
||||
value = value.to_i
|
||||
next if value == 0
|
||||
name = PARAM_LABELS[index]
|
||||
next if name.nil?
|
||||
parts << "#{sign(value)}#{value.abs} к #{name}"
|
||||
end
|
||||
end
|
||||
|
||||
parts.uniq
|
||||
end
|
||||
|
||||
def self.load_effects(item)
|
||||
begin
|
||||
item.lona_effect if item.respond_to?(:lona_effect)
|
||||
rescue
|
||||
end
|
||||
end
|
||||
|
||||
def self.format_effect(effect)
|
||||
return nil if effect.respond_to?(:stats_key) && effect.stats_key
|
||||
attr = effect.respond_to?(:attr) ? effect.attr.to_s : ""
|
||||
return nil if attr.empty?
|
||||
label = STAT_LABELS[attr]
|
||||
return nil if label.nil?
|
||||
|
||||
value = effect.respond_to?(:adjust) ? effect.adjust.to_f : 0.0
|
||||
return nil if value == 0.0
|
||||
|
||||
label = typed_label(label, effect.respond_to?(:attr_type) ? effect.attr_type : nil)
|
||||
op = effect.respond_to?(:type) ? effect.type.to_s : "+"
|
||||
|
||||
case op
|
||||
when "+"
|
||||
"+#{number(value)} к #{label}"
|
||||
when "-"
|
||||
"-#{number(value)} к #{label}"
|
||||
when "*"
|
||||
percent = ((value - 1.0) * 100.0).round
|
||||
return nil if percent == 0
|
||||
"#{sign(percent)}#{percent.abs}% к #{label}"
|
||||
when "/"
|
||||
return nil if value == 0.0
|
||||
percent = ((1.0 / value - 1.0) * 100.0).round
|
||||
return nil if percent == 0
|
||||
"#{sign(percent)}#{percent.abs}% к #{label}"
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def self.typed_label(label, attr_type)
|
||||
return label unless defined?(ActorStat)
|
||||
case attr_type
|
||||
when ActorStat::MAX_STAT, ActorStat::MAX_TRUE, ActorStat::BUFF_TMAX
|
||||
"макс. #{label}"
|
||||
when ActorStat::MIN_STAT, ActorStat::MIN_TRUE, ActorStat::BUFF_TMIN
|
||||
"мин. #{label}"
|
||||
else
|
||||
label
|
||||
end
|
||||
end
|
||||
|
||||
def self.number(value)
|
||||
value = value.to_f.round(2)
|
||||
return value.to_i.to_s if value == value.to_i
|
||||
("%.2f" % value).sub(/0+$/, "").sub(/\.$/, "")
|
||||
end
|
||||
|
||||
def self.sign(value)
|
||||
value.to_f >= 0 ? "+" : "-"
|
||||
end
|
||||
end
|
||||
|
||||
class Menu_Items < Menu_ContentBase
|
||||
def refresh_info
|
||||
@item_info.bitmap.clear
|
||||
item = @container[@real_index]
|
||||
return if item.nil?
|
||||
|
||||
@item_info.bitmap.font.size = 16
|
||||
@item_info.bitmap.font.outline = false
|
||||
|
||||
desc = $game_text[item.description].to_s
|
||||
desc = desc.gsub(/(?:\\n|\r|\n)+\z/, "")
|
||||
bonus = MPItemDescriptionEffects.line(item)
|
||||
desc = desc.empty? ? "\\C[6]#{bonus}\\C[0]" : "#{desc}\n\\C[6]#{bonus}\\C[0]" unless bonus.empty?
|
||||
|
||||
draw_text_on_canvas(@item_info, 7, 6, desc)
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user