Module: EveStatic::Queries::Industry
- Included in:
- Database
- Defined in:
- lib/eve_static/queries/industry.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/eve_static/queries/industry.rb', line 26 def self.included(klass) klass.extend(ClassMethods) klass.instance_eval do industry_time_generator(:manufacture_time, { :industry => 0.0, :implant_modifier => 1.0, :slot_modifier => 1.0, :pe => 0.0 }) do |result, params| if params[:pe] >= 0 pe = params[:pe].to_f/(1.0+params[:pe].to_f) else pe = params[:pe].to_f - 1.0 end res = result[:productionTime] * ((1-(0.04*params[:industry])))*params[:implant_modifier]*params[:slot_modifier] res = res * ( 1.0 - ((result[:productivityModifier].to_f)/result[:productionTime].to_f) * pe) res.to_i end industry_time_generator(:material_research_time, { :metallurgy => 0.0, :implant_modifier => 1.0, :slot_modifier => 1.0 }) do |result, params| research_time(result[:researchMaterialTime], params[:metallurgy], params[:slot_modifier], params[:implant_modifier]).to_i end industry_time_generator(:production_research_time, { :research => 0.0, :implant_modifier => 1.0, :slot_modifier => 1.0 }) do |result, params| research_time(result[:researchProductivityTime], params[:research], params[:slot_modifier], params[:implant_modifier]).to_i end industry_time_generator(:copy_research_time, { :science => 0.0, :implant_modifier => 1.0, :slot_modifier => 1.0 }) do |result, params| research_time(result[:researchCopyTime], params[:science], params[:slot_modifier], params[:implant_modifier]).to_i end end end |
Instance Method Details
#blueprint(type) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/eve_static/queries/industry.rb', line 73 def blueprint(type) typeID = coerce_type_id(type) result = instance[:invBlueprintTypes].where(:productTypeID => typeID).first result ||= instance[:invBlueprintTypes].where(:blueprintTypeID => typeID).first result end |
#materials(type, me = 0) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/eve_static/queries/industry.rb', line 88 def materials(type, me = 0) typeID = coerce_industry_type(type) productTypeID = product(typeID) bp = blueprint(typeID) raw = raw_materials(productTypeID).to_a extra = extra_materials(typeID).to_a subtract = extra.select { |e| e[:recycle] } subtract = subtract.map do |s| raw_materials(s[:requiredTypeID]).to_a end subtract = subtract.flatten raw_hash = Hash[raw.map { |r| [ r[:materialTypeID], r ] }] subtract.each do |s| if raw_hash.keys.include? s[:materialTypeID] raw_hash[s[:materialTypeID]][:quantity] -= s[:quantity] end end raw = raw_hash.values raw = raw.select do |r| r[:quantity] > 0 end raw = raw.map { |r| r.merge({ :waste => waste(r[:quantity], bp[:wasteFactor], me) }) } raw = raw.map { |r| normalize_materials r } extra = extra.map { |e| normalize_materials e } { :raw => raw, :extra => extra } end |
#product(type) ⇒ Object
82 83 84 85 86 |
# File 'lib/eve_static/queries/industry.rb', line 82 def product(type) typeID = coerce_type_id(type) instance[:invBlueprintTypes].where(:blueprintTypeID => typeID).select(Sequel.lit('productTypeID')).first[:productTypeID] end |