Skip to content

Commit

Permalink
Add isk per hour calculations to the pi config and planet views.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewd18 committed Dec 10, 2013
1 parent 7f3d6d4 commit 338dac0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
33 changes: 33 additions & 0 deletions model/planet.rb
Expand Up @@ -574,6 +574,17 @@ def input_products_per_hour
return input_products_hash
end

def input_isk_per_hour
isk_value = 0.0

input_products_per_hour.each_pair do |product_name, quantity|
product = Product.find_by_name(product_name)
isk_value += (quantity * product.eve_central_median)
end

return isk_value
end

def output_products_per_hour
output_products_hash = {}

Expand All @@ -588,6 +599,17 @@ def output_products_per_hour
return output_products_hash
end

def output_isk_per_hour
isk_value = 0.0

output_products_per_hour.each_pair do |product_name, quantity|
product = Product.find_by_name(product_name)
isk_value += (quantity * product.eve_central_median)
end

return isk_value
end

def adjusted_products_per_hour
adjusted_hash = {}

Expand All @@ -597,6 +619,17 @@ def adjusted_products_per_hour
return adjusted_hash
end

def adjusted_isk_per_hour
isk_value = 0.0

adjusted_products_per_hour.each_pair do |product_name, quantity|
product = Product.find_by_name(product_name)
isk_value += (quantity * product.eve_central_median)
end

return isk_value
end

def remove_planet
# Lean on parent pi_configuration function.
@pi_configuration.remove_planet(self)
Expand Down
16 changes: 10 additions & 6 deletions view/pi_configuration_view/planet_list_row.rb
Expand Up @@ -51,10 +51,10 @@ def initialize(controller, planet_model)
planet_import_list_scrolled_window.set_policy(Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC)
planet_import_list_scrolled_window.add(@planet_import_list)
planet_import_cost_label = Gtk::Label.new("ISK Spent / Hour:")
planet_import_cost_value = IskAmountLabel.new()
@planet_import_cost_value = IskAmountLabel.new(@planet_model.input_isk_per_hour)
import_isk_cost_row = Gtk::Box.new(:horizontal)
import_isk_cost_row.pack_start(planet_import_cost_label)
import_isk_cost_row.pack_start(planet_import_cost_value)
import_isk_cost_row.pack_start(@planet_import_cost_value)

planet_imports_column = Gtk::Box.new(:vertical)
planet_imports_column.pack_start(imports_label, :expand => false)
Expand All @@ -67,10 +67,10 @@ def initialize(controller, planet_model)
planet_export_scrolled_window.set_policy(Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC)
planet_export_scrolled_window.add(@planet_export_list)
planet_export_cost_label = Gtk::Label.new("ISK Created / Hour:")
planet_export_cost_value = IskAmountLabel.new()
@planet_export_cost_value = IskAmountLabel.new(@planet_model.output_isk_per_hour)
export_isk_cost_row = Gtk::Box.new(:horizontal)
export_isk_cost_row.pack_start(planet_export_cost_label)
export_isk_cost_row.pack_start(planet_export_cost_value)
export_isk_cost_row.pack_start(@planet_export_cost_value)

planet_exports_column = Gtk::Box.new(:vertical)
planet_exports_column.pack_start(exports_label, :expand => false)
Expand All @@ -84,10 +84,10 @@ def initialize(controller, planet_model)
planet_adjusted_scrolled_window.set_policy(Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC)
planet_adjusted_scrolled_window.add(@planet_adjusted_list)
planet_adjusted_cost_label = Gtk::Label.new("Adj. ISK / Hour:")
planet_adjusted_cost_value = IskAmountLabel.new()
@planet_adjusted_cost_value = IskAmountLabel.new(@planet_model.adjusted_isk_per_hour)
adjusted_isk_cost_row = Gtk::Box.new(:horizontal)
adjusted_isk_cost_row.pack_start(planet_adjusted_cost_label)
adjusted_isk_cost_row.pack_start(planet_adjusted_cost_value)
adjusted_isk_cost_row.pack_start(@planet_adjusted_cost_value)


planet_adjusted_column = Gtk::Box.new(:vertical)
Expand All @@ -114,5 +114,9 @@ def planet_model=(new_planet_model)
@planet_image.planet_model = @planet_model
@planet_buildings_box.planet_model = @planet_model
@planet_import_list.planet_model = @planet_model

@planet_import_cost_value.isk_value = @planet_model.input_isk_per_hour
@planet_export_cost_value.isk_value = @planet_model.output_isk_per_hour
@planet_adjusted_cost_value.isk_value = @planet_model.adjusted_isk_per_hour
end
end
13 changes: 13 additions & 0 deletions view/planet_view/planet_view.rb
Expand Up @@ -7,6 +7,7 @@

require_relative '../common/planet_import_list.rb'
require_relative '../common/planet_export_list.rb'
require_relative '../common/isk_amount_label.rb'

require_relative '../gtk_helpers/clear_sort_button.rb'

Expand Down Expand Up @@ -49,22 +50,32 @@ def initialize(controller)
planet_import_list_scrolled_window = Gtk::ScrolledWindow.new
planet_import_list_scrolled_window.set_policy(Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC)
planet_import_list_scrolled_window.add(@planet_import_list)
@planet_import_isk_per_hour = IskAmountLabel.new()

planet_import_frame = Gtk::Frame.new
planet_import_vbox = Gtk::Box.new(:vertical)
planet_import_vbox.pack_start(Gtk::Label.new("Products Used / Hour"), :expand => false)
planet_import_vbox.pack_start(planet_import_list_scrolled_window, :expand => true)
import_isk_row = Gtk::Box.new(:horizontal)
import_isk_row.pack_start(Gtk::Label.new("Isk Cost / Hour: "), :expand => false)
import_isk_row.pack_start(@planet_import_isk_per_hour, :expand => true)
planet_import_vbox.pack_start(import_isk_row, :expand => false)
planet_import_frame.add(planet_import_vbox)

@planet_export_list = PlanetExportList.new(@planet_model)
planet_export_list_scrolled_window = Gtk::ScrolledWindow.new
planet_export_list_scrolled_window.set_policy(Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC)
planet_export_list_scrolled_window.add(@planet_export_list)
@planet_export_isk_per_hour = IskAmountLabel.new()

planet_export_frame = Gtk::Frame.new
planet_export_vbox = Gtk::Box.new(:vertical)
planet_export_vbox.pack_start(Gtk::Label.new("Products Created / Hour"), :expand => false)
planet_export_vbox.pack_start(planet_export_list_scrolled_window, :expand => true)
export_isk_row = Gtk::Box.new(:horizontal)
export_isk_row.pack_start(Gtk::Label.new("Isk Created / Hour: "), :expand => false)
export_isk_row.pack_start(@planet_export_isk_per_hour, :expand => true)
planet_export_vbox.pack_start(export_isk_row, :expand => false)
planet_export_frame.add(planet_export_vbox)

right_column_vbox = Gtk::Box.new(:vertical)
Expand Down Expand Up @@ -95,5 +106,7 @@ def planet_model=(new_planet_model)
@poco_stats_widget.planet_model = (@planet_model)
@planet_import_list.planet_model = (@planet_model)
@planet_export_list.planet_model = (@planet_model)
@planet_import_isk_per_hour.isk_value = (@planet_model.input_isk_per_hour)
@planet_export_isk_per_hour.isk_value = (@planet_model.output_isk_per_hour)
end
end

0 comments on commit 338dac0

Please sign in to comment.