1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-04-11 11:21:54 +02:00

remove old captain's shop code

This commit is contained in:
danielmartin0 2024-09-15 21:12:26 +01:00
parent 1b9d9067dd
commit 43d981d5bd
16 changed files with 321 additions and 941 deletions

View File

@ -1155,8 +1155,6 @@ function Public.loading_update(tickinterval)
local force = memory.force local force = memory.force
if not (force and force.valid) then return end if not (force and force.valid) then return end
script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {})
else else
PiratesApiEvents.load_some_map_chunks_random_order(surface, currentdestination, fraction) --random order is good for maze world PiratesApiEvents.load_some_map_chunks_random_order(surface, currentdestination, fraction) --random order is good for maze world
if currentdestination.subtype == IslandEnum.enum.CAVE then if currentdestination.subtype == IslandEnum.enum.CAVE then

View File

@ -21,7 +21,7 @@ local Islands = require 'maps.pirates.surfaces.islands.islands'
local Progression = require 'maps.pirates.progression' local Progression = require 'maps.pirates.progression'
local Crowsnest = require 'maps.pirates.surfaces.crowsnest' local Crowsnest = require 'maps.pirates.surfaces.crowsnest'
local PiratesApiEvents = require 'maps.pirates.api_events' local PiratesApiEvents = require 'maps.pirates.api_events'
local Upgrades = require 'maps.pirates.boat_upgrades' local Upgrades = require 'maps.pirates.shop.boat_upgrades'
local Effects = require 'maps.pirates.effects' local Effects = require 'maps.pirates.effects'
local Kraken = require 'maps.pirates.surfaces.sea.kraken' local Kraken = require 'maps.pirates.surfaces.sea.kraken'
local _inspect = require 'utils.inspect'.inspect local _inspect = require 'utils.inspect'.inspect

View File

@ -9,7 +9,6 @@ local Public = {}
local enum = { local enum = {
update_crew_progress_gui = Event.generate_event_name('update_crew_progress_gui'), update_crew_progress_gui = Event.generate_event_name('update_crew_progress_gui'),
update_crew_fuel_gui = Event.generate_event_name('update_crew_fuel_gui'),
} }
Public.enum = enum Public.enum = enum

View File

@ -156,94 +156,6 @@ function Public.flow_add_floating_button(flow1, button_name)
return flow3 return flow3
end end
function Public.flow_add_shop_item(flow, name)
local flow2, flow3
local shop_data_1 = Shop.Captains.main_shop_data_1
local shop_data_2 = Shop.Captains.main_shop_data_2
local trade_data = shop_data_1[name] or shop_data_2[name]
if not trade_data then return end
flow2 = flow.add({
name = name,
type = 'flow',
direction = 'horizontal',
})
flow2.style.top_margin = 3
flow2.style.horizontal_align = 'center'
flow2.style.vertical_align = 'center'
flow2.tooltip = trade_data.tooltip
for k, v in pairs(trade_data.what_you_get_sprite_buttons) do
flow3 = flow2.add({
type = 'sprite-button',
name = k,
sprite = k,
enabled = false,
})
flow3.style.minimal_height = 40
flow3.style.maximal_height = 40
if v == false then
flow3.number = nil
else
flow3.number = v
end
flow3.tooltip = trade_data.tooltip
end
flow3 = flow2.add({
type = 'label',
name = 'for',
caption = 'for'
})
flow3.style.font = 'default-large'
flow3.style.font_color = Public.default_font_color
flow3.tooltip = trade_data.tooltip
for k, _ in pairs(trade_data.base_cost) do
flow3 = flow2.add({
name = 'cost_' .. k,
type = 'sprite-button',
enabled = false,
})
flow3.style.minimal_height = 40
flow3.style.maximal_height = 40
flow3.tooltip = trade_data.tooltip
if k == 'fuel' then
flow3.sprite = 'item/coal'
elseif k == 'coins' then
flow3.sprite = 'item/coin'
elseif k == 'iron_plates' then
flow3.sprite = 'item/iron-plate'
elseif k == 'copper_plates' then
flow3.sprite = 'item/copper-plate'
end
end
flow3 = flow2.add({
name = 'spacing',
type = 'flow',
direction = 'horizontal',
})
flow3.style.horizontally_stretchable = true
flow3 = flow2.add({
type = 'sprite-button',
name = 'buy_button',
caption = 'Buy'
})
flow3.style.font = 'default-large'
flow3.style.font_color = Public.default_font_color
flow3.style.height = 32
flow3.style.width = 50
flow3.style.padding = 0
flow3.style.margin = 0
return flow2
end
function Public.flow_add_section(flow, name, caption) function Public.flow_add_section(flow, name, caption)
local flow2, flow3 local flow2, flow3

View File

@ -1,194 +0,0 @@
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/ComfyFactory/ComfyFactorio and https://github.com/danielmartin0/ComfyFactorio-Pirates.
local Memory = require 'maps.pirates.memory'
-- local Common = require 'maps.pirates.common'
-- local CoreData = require 'maps.pirates.coredata'
local Utils = require 'maps.pirates.utils_local'
-- local Math = require 'maps.pirates.math'
local Balance = require 'maps.pirates.balance'
-- local Surfaces = require 'maps.pirates.surfaces.surfaces'
local Roles = require 'maps.pirates.roles.roles'
local Crew = require 'maps.pirates.crew'
local Shop = require 'maps.pirates.shop.shop'
-- local Progression = require 'maps.pirates.progression'
-- local Structures = require 'maps.pirates.structures.structures'
local _inspect = require 'utils.inspect'.inspect
-- local Boats = require 'maps.pirates.structures.boats.boats'
local GuiCommon = require 'maps.pirates.gui.common'
local Public = {}
local window_name = 'fuel'
function Public.toggle_window(player)
local flow, flow2, flow3
local shop_data_1 = Shop.Captains.main_shop_data_1
local shop_data_2 = Shop.Captains.main_shop_data_2
if player.gui.screen[window_name .. '_piratewindow'] then
player.gui.screen[window_name .. '_piratewindow'].destroy()
return
end
flow = GuiCommon.new_window(player, window_name)
flow.caption = 'Captain\'s Store'
flow2 = flow.add({
name = 'trades',
type = 'flow',
direction = 'vertical',
})
flow2.style.top_margin = 3
flow2.style.bottom_margin = 3
flow2.style.horizontal_align = 'center'
flow2.style.vertical_align = 'center'
for k, _ in pairs(shop_data_1) do
GuiCommon.flow_add_shop_item(flow2, k)
end
flow3 = flow2.add({
name = 'line_1',
type = 'line',
})
flow3.style.width = 100
for k, _ in pairs(shop_data_2) do
GuiCommon.flow_add_shop_item(flow2, k)
end
flow2 = GuiCommon.flow_add_close_button(flow, window_name .. '_piratebutton')
flow2.add({
name = 'tospend',
type = 'sprite-button',
sprite = 'item/coin',
index = 1,
enabled = false,
})
end
function Public.regular_update(player)
local flow
-- local memory = Memory.get_crew_memory()
if not player.gui.screen[window_name .. '_piratewindow'] then return end
flow = player.gui.screen[window_name .. '_piratewindow']
if Roles.player_privilege_level(player) >= Roles.privilege_levels.OFFICER then
flow.close_button_flow.hflow.tospend.visible = true
local inv = player.get_inventory(defines.inventory.character_main)
if inv and inv.valid then
local coin_amount = inv.get_item_count('coin') or 0
flow.close_button_flow.hflow.tospend.number = coin_amount
flow.close_button_flow.hflow.tospend.tooltip = string.format("You're holding " .. Utils.bignumber_abbrevform2(coin_amount) .. " doubloons.")
end
else
flow.close_button_flow.hflow.tospend.visible = false
end
end
function Public.full_update(player)
if Public.regular_update then Public.regular_update(player) end
local flow
local memory = Memory.get_crew_memory()
local shop_data = Utils.nonrepeating_join_dict(Shop.Captains.main_shop_data_1, Shop.Captains.main_shop_data_2)
local shop_data_1 = Shop.Captains.main_shop_data_1
local shop_data_2 = Shop.Captains.main_shop_data_2
local availability_data = memory.mainshop_availability_bools
if not player.gui.screen[window_name .. '_piratewindow'] then return end
flow = player.gui.screen[window_name .. '_piratewindow']
--*** WHAT TO SHOW ***--
-- if memory.stored_fuel then
-- flow.close_button_flow.hflow.tospend.number = memory.stored_fuel
-- flow.close_button_flow.hflow.tospend.tooltip = string.format('The crew has %01d stored coal.', memory.stored_fuel)
-- else
-- flow.close_button_flow.hflow.tospend.number = 0
-- flow.close_button_flow.hflow.tospend.tooltip = string.format('The crew has %01d stored coal.', 0)
-- end
if memory.crewstatus == Crew.enum.ADVENTURING then
flow.trades.visible = true
else
flow.trades.visible = false
end
local anything_in_shop_1 = false
for k, _ in pairs(shop_data_1) do
if availability_data and availability_data[k] == true then
flow.trades[k].visible = true
anything_in_shop_1 = true
if Roles.player_privilege_level(player) >= Roles.privilege_levels.OFFICER then
flow.trades[k].buy_button.visible = true
else
flow.trades[k].buy_button.visible = false
end
else
flow.trades[k].visible = false
end
end
flow.trades.line_1.visible = anything_in_shop_1
for k, _ in pairs(shop_data_2) do
if availability_data and availability_data[k] == true then
flow.trades[k].visible = true
if Roles.player_privilege_level(player) >= Roles.privilege_levels.OFFICER then
flow.trades[k].buy_button.visible = true
else
flow.trades[k].buy_button.visible = false
end
else
flow.trades[k].visible = false
end
end
--*** UPDATE CONTENT ***--
local multiplier = Balance.main_shop_cost_multiplier()
for k, v in pairs(shop_data) do
for k2, v2 in pairs(v.base_cost) do
if v2 == false then
flow.trades[k]['cost_' .. k2].number = nil
else
flow.trades[k]['cost_' .. k2].number = multiplier * v2
end
end
end
end
function Public.click(event)
if not event.element then return end
if not event.element.valid then return end
local player = game.players[event.element.player_index]
local eventname = event.element.name
if not player.gui.screen[window_name .. '_piratewindow'] then return end
-- local flow = player.gui.screen[window_name .. '_piratewindow']
-- local memory = Memory.get_crew_memory()
if eventname == 'buy_button' then
Shop.Captains.main_shop_try_purchase(player, event.element.parent.name)
end
end
return Public

View File

@ -10,7 +10,6 @@ local GuiProgress = require 'maps.pirates.gui.progress'
local GuiRuns = require 'maps.pirates.gui.runs' local GuiRuns = require 'maps.pirates.gui.runs'
local GuiCrew = require 'maps.pirates.gui.crew' local GuiCrew = require 'maps.pirates.gui.crew'
local GuiClasses = require 'maps.pirates.gui.classes' local GuiClasses = require 'maps.pirates.gui.classes'
local GuiFuel = require 'maps.pirates.gui.fuel'
local GuiMinimap = require 'maps.pirates.gui.minimap' local GuiMinimap = require 'maps.pirates.gui.minimap'
local GuiInfo = require 'maps.pirates.gui.info' local GuiInfo = require 'maps.pirates.gui.info'
local Quest = require 'maps.pirates.quest' local Quest = require 'maps.pirates.quest'
@ -42,7 +41,6 @@ local enum = {
RUNS = 'runs', RUNS = 'runs',
CREW = 'crew', CREW = 'crew',
CLASSES = 'classes', CLASSES = 'classes',
FUEL = 'fuel',
MINIMAP = 'minimap', MINIMAP = 'minimap',
INFO = 'info', INFO = 'info',
COLOR = 'color', COLOR = 'color',
@ -52,7 +50,6 @@ Public.progress = require 'maps.pirates.gui.progress'
Public.runs = require 'maps.pirates.gui.runs' Public.runs = require 'maps.pirates.gui.runs'
Public.crew = require 'maps.pirates.gui.crew' Public.crew = require 'maps.pirates.gui.crew'
Public.classes = require 'maps.pirates.gui.classes' Public.classes = require 'maps.pirates.gui.classes'
Public.fuel = require 'maps.pirates.gui.fuel'
Public.minimap = require 'maps.pirates.gui.minimap' Public.minimap = require 'maps.pirates.gui.minimap'
Public.info = require 'maps.pirates.gui.info' Public.info = require 'maps.pirates.gui.info'
Public.color = require 'maps.pirates.gui.color' Public.color = require 'maps.pirates.gui.color'
@ -71,13 +68,8 @@ end
function Public.update_crew_progress_gui() function Public.update_crew_progress_gui()
return Public.update_crew_gui('progress') return Public.update_crew_gui('progress')
end end
Event.add(CustomEvents.enum['update_crew_progress_gui'], Public.update_crew_progress_gui)
-- script.raise_event(CustomEvents.enum['update_crew_progress_gui'], {})
function Public.update_crew_fuel_gui()
return Public.update_crew_gui('fuel')
end
Event.add(CustomEvents.enum['update_crew_fuel_gui'], Public.update_crew_fuel_gui)
Event.add(CustomEvents.enum['update_crew_progress_gui'], Public.update_crew_progress_gui)
local function create_gui(player) local function create_gui(player)
local flow1, flow2, flow3, flow4 local flow1, flow2, flow3, flow4
@ -87,19 +79,19 @@ local function create_gui(player)
flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'info_piratebutton') flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'info_piratebutton')
flow2.caption = '?' flow2.caption = '?'
flow2.style.font = 'debug' flow2.style.font = 'debug'
flow2.tooltip = {'pirates.gui_info_main_tooltip'} flow2.tooltip = { 'pirates.gui_info_main_tooltip' }
flow2.style.font_color = {r=1, g=1, b=1} flow2.style.font_color = { r = 1, g = 1, b = 1 }
flow2.style.hovered_font_color = {r=1, g=1, b=1} flow2.style.hovered_font_color = { r = 1, g = 1, b = 1 }
flow2.style.clicked_font_color = {r=1, g=1, b=1} flow2.style.clicked_font_color = { r = 1, g = 1, b = 1 }
flow2.parent.style.left_padding = -6 flow2.parent.style.left_padding = -6
flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'runs_piratebutton', 70) flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'runs_piratebutton', 70)
flow2.caption = {'pirates.gui_crews'} flow2.caption = { 'pirates.gui_crews' }
flow2.tooltip = {'pirates.gui_crews_main_tooltip'} flow2.tooltip = { 'pirates.gui_crews_main_tooltip' }
flow2.style.font = 'debug' flow2.style.font = 'debug'
flow2.style.font_color = {r=1, g=1, b=1} flow2.style.font_color = { r = 1, g = 1, b = 1 }
flow2.style.hovered_font_color = {r=1, g=1, b=1} flow2.style.hovered_font_color = { r = 1, g = 1, b = 1 }
flow2.style.clicked_font_color = {r=1, g=1, b=1} flow2.style.clicked_font_color = { r = 1, g = 1, b = 1 }
flow2.parent.style.width = 67 flow2.parent.style.width = 67
flow2.parent.style.left_padding = -6 flow2.parent.style.left_padding = -6
@ -131,11 +123,11 @@ local function create_gui(player)
flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'evo_piratebutton') flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'evo_piratebutton')
flow2.sprite = 'entity/small-biter' flow2.sprite = 'entity/small-biter'
flow2.mouse_button_filter = {'middle'} --hack to avoid press visual flow2.mouse_button_filter = { 'middle' } --hack to avoid press visual
flow2.show_percent_for_small_numbers = true --as of factorio v1.1.59, there is a bug in which 1.002 displays as like 1e-2% or something. but after 1.01 it's ok flow2.show_percent_for_small_numbers = true --as of factorio v1.1.59, there is a bug in which 1.002 displays as like 1e-2% or something. but after 1.01 it's ok
flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'minimap_piratebutton') flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'minimap_piratebutton')
flow2.tooltip = {'pirates.gui_minimap_main_tooltip'} flow2.tooltip = { 'pirates.gui_minimap_main_tooltip' }
flow2.sprite = 'utility/map' flow2.sprite = 'utility/map'
-- flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'shop_piratebutton') -- flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'shop_piratebutton')
@ -167,7 +159,7 @@ local function create_gui(player)
}) })
flow3.style.font = 'default-large-semibold' flow3.style.font = 'default-large-semibold'
flow3.style.font_color = GuiCommon.bold_font_color flow3.style.font_color = GuiCommon.bold_font_color
flow3.caption = {'pirates.gui_fuel_1'} flow3.caption = { 'pirates.gui_fuel_1' }
flow3 = flow2.add({ flow3 = flow2.add({
name = 'fuel_label_1', name = 'fuel_label_1',
@ -222,9 +214,9 @@ local function create_gui(player)
flow3.style.font = 'default-large-semibold' flow3.style.font = 'default-large-semibold'
flow3.style.font_color = GuiCommon.bold_font_color flow3.style.font_color = GuiCommon.bold_font_color
flow3 = flow2.add({type = 'table', name = 'cost_table', column_count = #CoreData.cost_items}) flow3 = flow2.add({ type = 'table', name = 'cost_table', column_count = #CoreData.cost_items })
for i = 1, #CoreData.cost_items do for i = 1, #CoreData.cost_items do
flow4 = flow3.add({type = 'sprite-button', name = 'cost_' .. i, number = 0}) flow4 = flow3.add({ type = 'sprite-button', name = 'cost_' .. i, number = 0 })
-- flow4.mouse_button_filter = {'middle'} -- flow4.mouse_button_filter = {'middle'}
flow4.sprite = CoreData.cost_items[i].sprite_name flow4.sprite = CoreData.cost_items[i].sprite_name
flow4.enabled = false flow4.enabled = false
@ -234,14 +226,14 @@ local function create_gui(player)
flow4.visible = false flow4.visible = false
end end
-- and -- and
flow4 = flow3.add({type = 'sprite-button', name = 'cost_launch_rocket'}) flow4 = flow3.add({ type = 'sprite-button', name = 'cost_launch_rocket' })
-- flow4.mouse_button_filter = {'middle'} -- flow4.mouse_button_filter = {'middle'}
flow4.sprite = 'item/rocket-silo' flow4.sprite = 'item/rocket-silo'
flow4.enabled = false flow4.enabled = false
flow4.style.top_margin = -6 flow4.style.top_margin = -6
flow4.style.right_margin = -6 flow4.style.right_margin = -6
flow4.style.maximal_height = 38 flow4.style.maximal_height = 38
flow4.visible = false flow4.visible = false
flow3.style.left_margin = -1 flow3.style.left_margin = -1
flow3.style.right_margin = -2 --to get to the end of the button frame flow3.style.right_margin = -2 --to get to the end of the button frame
@ -485,13 +477,13 @@ local function create_gui(player)
-- spontaneous inside view of the hold: -- spontaneous inside view of the hold:
flow1 = flow1 =
player.gui.screen.add( player.gui.screen.add(
{ {
type = 'camera', type = 'camera',
name = 'pirates_spontaneous_camera', name = 'pirates_spontaneous_camera',
position = {x=0,y=0}, position = { x = 0, y = 0 },
} }
) )
flow1.visible = false flow1.visible = false
flow1.style.margin = 8 flow1.style.margin = 8
-- flow2.style.minimal_height = 64 -- flow2.style.minimal_height = 64
@ -546,34 +538,32 @@ function Public.process_etaframe_update(player, flow1, bools)
flow2.etaframe_label_1.visible = true flow2.etaframe_label_1.visible = true
flow2.etaframe_label_2.visible = false flow2.etaframe_label_2.visible = false
tooltip = {'pirates.gui_etaframe_board_warning_tooltip'} tooltip = { 'pirates.gui_etaframe_board_warning_tooltip' }
flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_board_warning'}
flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_board_warning' }
elseif bools.eta_bool then elseif bools.eta_bool then
flow2.etaframe_label_1.visible = true flow2.etaframe_label_1.visible = true
flow2.etaframe_label_2.visible = true flow2.etaframe_label_2.visible = true
tooltip = {'pirates.auto_undock_tooltip'} tooltip = { 'pirates.auto_undock_tooltip' }
local passive_eta = dynamic_data.time_remaining local passive_eta = dynamic_data.time_remaining
flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_autoundock'} flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_autoundock' }
flow2.etaframe_label_2.caption = Utils.standard_string_form_of_time_in_seconds(passive_eta) flow2.etaframe_label_2.caption = Utils.standard_string_form_of_time_in_seconds(passive_eta)
elseif bools.atsea_loading_bool then elseif bools.atsea_loading_bool then
if Kraken.get_active_kraken_count(memory.id) > 0 then if Kraken.get_active_kraken_count(memory.id) > 0 then
flow2.etaframe_label_1.visible = true flow2.etaframe_label_1.visible = true
flow2.etaframe_label_2.visible = false flow2.etaframe_label_2.visible = false
tooltip = {'pirates.defeat_krakens_tooltip'} tooltip = { 'pirates.defeat_krakens_tooltip' }
flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_defeat_krakens'} flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_defeat_krakens' }
else else
flow2.etaframe_label_1.visible = true flow2.etaframe_label_1.visible = true
flow2.etaframe_label_2.visible = true flow2.etaframe_label_2.visible = true
tooltip = {'pirates.atsea_loading_tooltip'} tooltip = { 'pirates.atsea_loading_tooltip' }
local total = Common.map_loading_ticks_atsea local total = Common.map_loading_ticks_atsea
if destination.type == Surfaces.enum.DOCK then if destination.type == Surfaces.enum.DOCK then
@ -584,34 +574,31 @@ function Public.process_etaframe_update(player, flow1, bools)
local eta_ticks = total + (memory.extra_time_at_sea or 0) - memory.loadingticks local eta_ticks = total + (memory.extra_time_at_sea or 0) - memory.loadingticks
flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_loading_for'} flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_loading_for' }
flow2.etaframe_label_2.caption = Utils.standard_string_form_of_time_in_seconds(eta_ticks / 60) flow2.etaframe_label_2.caption = Utils.standard_string_form_of_time_in_seconds(eta_ticks / 60)
end end
elseif bools.atsea_waiting_bool then elseif bools.atsea_waiting_bool then
flow2.etaframe_label_1.visible = true flow2.etaframe_label_1.visible = true
flow2.etaframe_label_2.visible = false flow2.etaframe_label_2.visible = false
tooltip = {'pirates.atsea_waiting_tooltip'} tooltip = { 'pirates.atsea_waiting_tooltip' }
flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_atsea_waiting'}
flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_atsea_waiting' }
elseif bools.atsea_victorious_bool then elseif bools.atsea_victorious_bool then
flow2.etaframe_label_1.visible = true flow2.etaframe_label_1.visible = true
flow2.etaframe_label_2.visible = false flow2.etaframe_label_2.visible = false
tooltip = {'pirates.atsea_victorious_tooltip'} tooltip = { 'pirates.atsea_victorious_tooltip' }
flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_atsea_victorious'}
flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_atsea_victorious' }
elseif bools.leave_anytime_bool then elseif bools.leave_anytime_bool then
flow2.etaframe_label_1.visible = true flow2.etaframe_label_1.visible = true
flow2.etaframe_label_2.visible = true flow2.etaframe_label_2.visible = true
tooltip = {'pirates.leave_anytime_tooltip'} tooltip = { 'pirates.leave_anytime_tooltip' }
flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_undock'} flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_undock' }
flow2.etaframe_label_2.caption = {'pirates.gui_etaframe_anytime'} flow2.etaframe_label_2.caption = { 'pirates.gui_etaframe_anytime' }
end end
if bools.cost_bool and Kraken.get_active_kraken_count(memory.id) == 0 then if bools.cost_bool and Kraken.get_active_kraken_count(memory.id) == 0 then
@ -624,65 +611,65 @@ function Public.process_etaframe_update(player, flow1, bools)
cost_table.visible = true cost_table.visible = true
if flow2.etaframe_label_2.visible then if flow2.etaframe_label_2.visible then
flow2.etaframe_label_2.caption = flow2.etaframe_label_2.caption .. '.' flow2.etaframe_label_2.caption = flow2.etaframe_label_2.caption .. '.'
end end
-- local caption -- local caption
if bools.atsea_loading_bool then if bools.atsea_loading_bool then
flow2.etaframe_label_3.caption = {'pirates.gui_etaframe_next_escape_cost'} flow2.etaframe_label_3.caption = { 'pirates.gui_etaframe_next_escape_cost' }
if Boats.need_resources_to_undock(Common.overworldx(), destination.subtype) then if Boats.need_resources_to_undock(Common.overworldx(), destination.subtype) then
if bools.cost_includes_rocket_launch_bool then if bools.cost_includes_rocket_launch_bool then
tooltip = {'pirates.resources_needed_tooltip_4_rocketvariant'} tooltip = { 'pirates.resources_needed_tooltip_4_rocketvariant' }
else else
tooltip = {'pirates.resources_needed_tooltip_4'} tooltip = { 'pirates.resources_needed_tooltip_4' }
end end
elseif destination.static_params.undock_cost_decreases == true then elseif destination.static_params.undock_cost_decreases == true then
if bools.cost_includes_rocket_launch_bool then if bools.cost_includes_rocket_launch_bool then
tooltip = {'pirates.resources_needed_tooltip_1_rocketvariant'} tooltip = { 'pirates.resources_needed_tooltip_1_rocketvariant' }
else else
tooltip = {'pirates.resources_needed_tooltip_1'} tooltip = { 'pirates.resources_needed_tooltip_1' }
end end
else else
if bools.cost_includes_rocket_launch_bool then if bools.cost_includes_rocket_launch_bool then
tooltip = {'pirates.resources_needed_tooltip_0a_rocketvariant'} tooltip = { 'pirates.resources_needed_tooltip_0a_rocketvariant' }
else else
tooltip = {'pirates.resources_needed_tooltip_0a'} tooltip = { 'pirates.resources_needed_tooltip_0a' }
end end
end end
elseif (not bools.eta_bool) then -- Shown when ship doesn't have auto undock timer elseif (not bools.eta_bool) then -- Shown when ship doesn't have auto undock timer
flow2.etaframe_label_3.visible = false flow2.etaframe_label_3.visible = false
flow2.etaframe_label_1.visible = true flow2.etaframe_label_1.visible = true
flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_to_escape_store'} flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_to_escape_store' }
if bools.cost_includes_rocket_launch_bool then if bools.cost_includes_rocket_launch_bool then
tooltip = {'pirates.resources_needed_tooltip_3_rocketvariant'} tooltip = { 'pirates.resources_needed_tooltip_3_rocketvariant' }
else else
tooltip = {'pirates.resources_needed_tooltip_3'} tooltip = { 'pirates.resources_needed_tooltip_3' }
end end
else -- Shown when at island else -- Shown when at island
if Boats.need_resources_to_undock(Common.overworldx(), destination.subtype) then if Boats.need_resources_to_undock(Common.overworldx(), destination.subtype) then
flow2.etaframe_label_3.visible = false flow2.etaframe_label_3.visible = false
if bools.cost_includes_rocket_launch_bool then if bools.cost_includes_rocket_launch_bool then
tooltip = {'pirates.resources_needed_tooltip_5_rocketvariant'} tooltip = { 'pirates.resources_needed_tooltip_5_rocketvariant' }
else else
tooltip = {'pirates.resources_needed_tooltip_5'} tooltip = { 'pirates.resources_needed_tooltip_5' }
end end
elseif destination.static_params.undock_cost_decreases == true then elseif destination.static_params.undock_cost_decreases == true then
flow2.etaframe_label_3.caption = {'pirates.gui_etaframe_or_store'} flow2.etaframe_label_3.caption = { 'pirates.gui_etaframe_or_store' }
local adjusted_costs_resources_strings = Common.time_adjusted_departure_cost_resources_strings(memory) local adjusted_costs_resources_strings = Common.time_adjusted_departure_cost_resources_strings(memory)
if bools.cost_includes_rocket_launch_bool then if bools.cost_includes_rocket_launch_bool then
tooltip = {'pirates.resources_needed_tooltip_2_rocketvariant', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2]} tooltip = { 'pirates.resources_needed_tooltip_2_rocketvariant', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2] }
else else
--@Future reference: localisation handling --@Future reference: localisation handling
tooltip = {'pirates.resources_needed_tooltip_2', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2]} tooltip = { 'pirates.resources_needed_tooltip_2', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2] }
end end
else else
if bools.cost_includes_rocket_launch_bool then if bools.cost_includes_rocket_launch_bool then
tooltip = {'pirates.resources_needed_tooltip_3_rocketvariant'} tooltip = { 'pirates.resources_needed_tooltip_3_rocketvariant' }
else else
tooltip = {'pirates.resources_needed_tooltip_3'} tooltip = { 'pirates.resources_needed_tooltip_3' }
end end
end end
end end
@ -710,7 +697,7 @@ function Public.process_etaframe_update(player, flow1, bools)
else else
cost_table['cost_launch_rocket'].number = 0 cost_table['cost_launch_rocket'].number = 0
end end
cost_table['cost_launch_rocket'].tooltip = {'pirates.gui_etaframe_rocket_requirement_tooltip'} cost_table['cost_launch_rocket'].tooltip = { 'pirates.gui_etaframe_rocket_requirement_tooltip' }
cost_table['cost_launch_rocket'].visible = true cost_table['cost_launch_rocket'].visible = true
else else
cost_table['cost_launch_rocket'].visible = false cost_table['cost_launch_rocket'].visible = false
@ -721,24 +708,22 @@ function Public.process_etaframe_update(player, flow1, bools)
flow2.tooltip = tooltip flow2.tooltip = tooltip
if bools.captain_bool and (not bools.retreating_bool) and (bools.leave_anytime_bool or bools.atsea_waiting_bool or bools.eta_bool or (bools.cost_bool and (not bools.atsea_loading_bool))) then if bools.captain_bool and (not bools.retreating_bool) and (bools.leave_anytime_bool or bools.atsea_waiting_bool or bools.eta_bool or (bools.cost_bool and (not bools.atsea_loading_bool))) then
flow1.etaframe_piratebutton.mouse_button_filter = {'left'} flow1.etaframe_piratebutton.mouse_button_filter = { 'left' }
if memory.undock_shortcut_are_you_sure_data and memory.undock_shortcut_are_you_sure_data[player.index] and memory.undock_shortcut_are_you_sure_data[player.index] > game.tick - 60 * 4 then if memory.undock_shortcut_are_you_sure_data and memory.undock_shortcut_are_you_sure_data[player.index] and memory.undock_shortcut_are_you_sure_data[player.index] > game.tick - 60 * 4 then
flow2.etaframe_label_1.visible = true flow2.etaframe_label_1.visible = true
flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_undock_are_you_sure'} flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_undock_are_you_sure' }
flow2.etaframe_label_2.visible = false flow2.etaframe_label_2.visible = false
flow2.etaframe_label_3.visible = false flow2.etaframe_label_3.visible = false
end end
else else
flow1.etaframe_piratebutton.mouse_button_filter = {'middle'} --hack to avoid press visual flow1.etaframe_piratebutton.mouse_button_filter = { 'middle' } --hack to avoid press visual
end end
else else
flow1.visible = false flow1.visible = false
end end
end end
function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bools) function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bools)
local destination = Common.current_destination() local destination = Common.current_destination()
local dynamic_data = destination.dynamic_data --assumes this always exists local dynamic_data = destination.dynamic_data --assumes this always exists
@ -747,40 +732,37 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo
flow1 = flowsilo flow1 = flowsilo
if flow1 then if flow1 then
if bools.silo_bool then if bools.silo_bool then
flow1.visible = true flow1.visible = true
if bools.charged_bool then if bools.charged_bool then
if bools.launched_bool then if bools.launched_bool then
flow1.silo_progressbar.visible = false flow1.silo_progressbar.visible = false
flow1.silo_label_2.visible = false flow1.silo_label_2.visible = false
flow1.silo_label_3.visible = true flow1.silo_label_3.visible = true
-- flow1.silo_label_1.caption = string.format('[achievement=there-is-no-spoon]: +%.0f[item=sulfur]', dynamic_data.rocketcoalreward) -- flow1.silo_label_1.caption = string.format('[achievement=there-is-no-spoon]: +%.0f[item=sulfur]', dynamic_data.rocketcoalreward)
flow1.silo_label_1.caption = {'pirates.gui_etaframe_launched'} flow1.silo_label_1.caption = { 'pirates.gui_etaframe_launched' }
-- flow1.silo_label_1.caption = string.format('Launched for %.0f[item=coal] , ' .. Balance.rocket_launch_coin_reward .. '[item=coin]', dynamic_data.rocketcoalreward) -- flow1.silo_label_1.caption = string.format('Launched for %.0f[item=coal] , ' .. Balance.rocket_launch_coin_reward .. '[item=coin]', dynamic_data.rocketcoalreward)
flow1.silo_label_1.style.font_color = GuiCommon.achieved_font_color flow1.silo_label_1.style.font_color = GuiCommon.achieved_font_color
local rocket_launch_coal_reward = Balance.rocket_launch_fuel_reward() local rocket_launch_coal_reward = Balance.rocket_launch_fuel_reward()
local rocket_launch_coin_reward = Balance.rocket_launch_coin_reward() local rocket_launch_coin_reward = Balance.rocket_launch_coin_reward()
flow1.silo_label_3.caption = Math.floor(rocket_launch_coal_reward/100)/10 .. 'k[item=coal], ' .. Math.floor(rocket_launch_coin_reward/100)/10 .. 'k[item=coin]' flow1.silo_label_3.caption = Math.floor(rocket_launch_coal_reward / 100) / 10 .. 'k[item=coal], ' .. Math.floor(rocket_launch_coin_reward / 100) / 10 .. 'k[item=coin]'
local tooltip = {'pirates.gui_etaframe_launched_tooltip'} local tooltip = { 'pirates.gui_etaframe_launched_tooltip' }
flow1.tooltip = tooltip flow1.tooltip = tooltip
flow1.silo_label_1.tooltip = tooltip flow1.silo_label_1.tooltip = tooltip
flow1.silo_label_3.tooltip = tooltip flow1.silo_label_3.tooltip = tooltip
else else
local tooltip = {'pirates.gui_etaframe_launching'} local tooltip = { 'pirates.gui_etaframe_launching' }
flow1.tooltip = tooltip flow1.tooltip = tooltip
flow1.silo_label_1.tooltip = tooltip flow1.silo_label_1.tooltip = tooltip
flow1.silo_progressbar.tooltip = tooltip flow1.silo_progressbar.tooltip = tooltip
flow1.silo_label_1.caption = {'pirates.gui_etaframe_charge'} flow1.silo_label_1.caption = { 'pirates.gui_etaframe_charge' }
flow1.silo_label_1.style.font_color = GuiCommon.bold_font_color flow1.silo_label_1.style.font_color = GuiCommon.bold_font_color
flow1.silo_label_2.visible = false flow1.silo_label_2.visible = false
flow1.silo_label_3.visible = false flow1.silo_label_3.visible = false
@ -788,9 +770,8 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo
flow1.silo_progressbar.value = 1 flow1.silo_progressbar.value = 1
end end
else else
flow1.silo_label_1.caption = {'pirates.gui_etaframe_charge'} flow1.silo_label_1.caption = { 'pirates.gui_etaframe_charge' }
flow1.silo_label_1.style.font_color = GuiCommon.bold_font_color flow1.silo_label_1.style.font_color = GuiCommon.bold_font_color
flow1.silo_label_2.visible = true flow1.silo_label_2.visible = true
flow1.silo_progressbar.visible = true flow1.silo_progressbar.visible = true
@ -800,9 +781,9 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo
local needed = dynamic_data.rocketsiloenergyneeded local needed = dynamic_data.rocketsiloenergyneeded
local recent = (dynamic_data.rocketsiloenergyconsumedwithinlasthalfsecond * 2) local recent = (dynamic_data.rocketsiloenergyconsumedwithinlasthalfsecond * 2)
flow1.silo_progressbar.value = consumed/needed flow1.silo_progressbar.value = consumed / needed
local tooltip = {'pirates.gui_etaframe_charge_tooltip', string.format('%.1f', Math.floor(consumed / 100000000)/10), string.format('%.1f', Math.floor(needed / 100000000)/10)} local tooltip = { 'pirates.gui_etaframe_charge_tooltip', string.format('%.1f', Math.floor(consumed / 100000000) / 10), string.format('%.1f', Math.floor(needed / 100000000) / 10) }
flow1.tooltip = tooltip flow1.tooltip = tooltip
flow1.silo_label_1.tooltip = tooltip flow1.silo_label_1.tooltip = tooltip
flow1.silo_label_2.tooltip = tooltip flow1.silo_label_2.tooltip = tooltip
@ -836,16 +817,15 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo
local quest_reward = dynamic_data.quest_reward or nil local quest_reward = dynamic_data.quest_reward or nil
local quest_progress = dynamic_data.quest_progress or 0 local quest_progress = dynamic_data.quest_progress or 0
local quest_progressneeded = dynamic_data.quest_progressneeded or 0 local quest_progressneeded = dynamic_data.quest_progressneeded or 0
local quest_complete = dynamic_data.quest_complete or false local quest_complete = dynamic_data.quest_complete or false
if quest_type then if quest_type then
---@type string|table ---@type string|table
local tooltip = '' local tooltip = ''
if quest_complete and quest_reward then if quest_complete and quest_reward then
tooltip = {'pirates.gui_questframe_complete_tooltip', quest_type} tooltip = { 'pirates.gui_questframe_complete_tooltip', quest_type }
flow1.quest_label_1.caption = {'pirates.gui_questframe'} flow1.quest_label_1.caption = { 'pirates.gui_questframe' }
flow1.quest_label_1.style.font_color = GuiCommon.achieved_font_color flow1.quest_label_1.style.font_color = GuiCommon.achieved_font_color
flow1.quest_label_2.visible = true flow1.quest_label_2.visible = true
flow1.quest_label_3.visible = false flow1.quest_label_3.visible = false
@ -853,7 +833,7 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo
flow1.quest_label_2.caption = quest_reward.display_amount .. ' ' .. quest_reward.display_sprite flow1.quest_label_2.caption = quest_reward.display_amount .. ' ' .. quest_reward.display_sprite
elseif quest_reward then elseif quest_reward then
if quest_progress < quest_progressneeded then if quest_progress < quest_progressneeded then
flow1.quest_label_1.caption = {'pirates.gui_questframe'} flow1.quest_label_1.caption = { 'pirates.gui_questframe' }
flow1.quest_label_1.style.font_color = GuiCommon.bold_font_color flow1.quest_label_1.style.font_color = GuiCommon.bold_font_color
flow1.quest_label_2.visible = true flow1.quest_label_2.visible = true
flow1.quest_label_3.visible = true flow1.quest_label_3.visible = true
@ -867,7 +847,7 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo
end end
if quest_type == Quest.enum.TIME then if quest_type == Quest.enum.TIME then
if tooltip == '' then tooltip = {'pirates.gui_questframe_time'} end if tooltip == '' then tooltip = { 'pirates.gui_questframe_time' } end
if quest_progress >= 0 then if quest_progress >= 0 then
flow1.quest_label_3.caption = string.format('%.0fm%.0fs', Math.floor(quest_progress / 60), quest_progress % 60) flow1.quest_label_3.caption = string.format('%.0fm%.0fs', Math.floor(quest_progress / 60), quest_progress % 60)
@ -885,49 +865,42 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo
end end
end end
else else
flow1.quest_label_3.caption = {'pirates.gui_questframe_fail'} flow1.quest_label_3.caption = { 'pirates.gui_questframe_fail' }
flow1.quest_label_3.style.font_color = GuiCommon.insufficient_font_color flow1.quest_label_3.style.font_color = GuiCommon.insufficient_font_color
end end
elseif quest_type == Quest.enum.WORMS then elseif quest_type == Quest.enum.WORMS then
if tooltip == '' then tooltip = {'pirates.gui_questframe_worms'} end if tooltip == '' then tooltip = { 'pirates.gui_questframe_worms' } end
elseif quest_type == Quest.enum.FIND then elseif quest_type == Quest.enum.FIND then
if tooltip == '' then tooltip = {'pirates.gui_questframe_find'} end if tooltip == '' then tooltip = { 'pirates.gui_questframe_find' } end
elseif quest_type == Quest.enum.RESOURCEFLOW then elseif quest_type == Quest.enum.RESOURCEFLOW then
if tooltip == '' then tooltip = {'pirates.gui_questframe_resourceflow'} end if tooltip == '' then tooltip = { 'pirates.gui_questframe_resourceflow' } end
-- out of date: -- out of date:
if quest_progressneeded/60 % 1 == 0 then if quest_progressneeded / 60 % 1 == 0 then
flow1.quest_label_2.caption = string.format('%s %.1f/%.0f /s', '[item=' .. quest_params.item .. ']', quest_progress/60, quest_progressneeded/60) flow1.quest_label_2.caption = string.format('%s %.1f/%.0f /s', '[item=' .. quest_params.item .. ']', quest_progress / 60, quest_progressneeded / 60)
flow1.quest_label_3.caption = string.format(' for %s', quest_reward.display_sprite) flow1.quest_label_3.caption = string.format(' for %s', quest_reward.display_sprite)
else else
flow1.quest_label_2.caption = string.format('%s %.1f/%.1f /s', '[item=' .. quest_params.item .. ']', quest_progress/60, quest_progressneeded/60) flow1.quest_label_2.caption = string.format('%s %.1f/%.1f /s', '[item=' .. quest_params.item .. ']', quest_progress / 60, quest_progressneeded / 60)
flow1.quest_label_3.caption = string.format(' for %s', quest_reward.display_sprite) flow1.quest_label_3.caption = string.format(' for %s', quest_reward.display_sprite)
end end
elseif quest_type == Quest.enum.RESOURCECOUNT then elseif quest_type == Quest.enum.RESOURCECOUNT then
if tooltip == '' then tooltip = {'pirates.gui_questframe_resourcecount'} end if tooltip == '' then tooltip = { 'pirates.gui_questframe_resourcecount' } end
flow1.quest_label_2.caption = string.format('%s ', '[item=' .. quest_params.item .. ']') flow1.quest_label_2.caption = string.format('%s ', '[item=' .. quest_params.item .. ']')
elseif quest_type == Quest.enum.NODAMAGE then elseif quest_type == Quest.enum.NODAMAGE then
if tooltip == '' then tooltip = {'pirates.gui_questframe_nodamage'} end if tooltip == '' then tooltip = { 'pirates.gui_questframe_nodamage' } end
if bools.approaching_bool or (dynamic_data.rocketsilos and dynamic_data.rocketsilos[1] and dynamic_data.rocketsilos[1].valid and dynamic_data.rocketsilohp == dynamic_data.rocketsilomaxhp) then if bools.approaching_bool or (dynamic_data.rocketsilos and dynamic_data.rocketsilos[1] and dynamic_data.rocketsilos[1].valid and dynamic_data.rocketsilohp == dynamic_data.rocketsilomaxhp) then
flow1.quest_label_3.caption = {'pirates.gui_questframe_ok'} flow1.quest_label_3.caption = { 'pirates.gui_questframe_ok' }
flow1.quest_label_3.style.font_color = GuiCommon.sufficient_font_color flow1.quest_label_3.style.font_color = GuiCommon.sufficient_font_color
else else
flow1.quest_label_3.caption = {'pirates.gui_questframe_fail'} flow1.quest_label_3.caption = { 'pirates.gui_questframe_fail' }
flow1.quest_label_3.style.font_color = GuiCommon.insufficient_font_color flow1.quest_label_3.style.font_color = GuiCommon.insufficient_font_color
end end
elseif quest_type == Quest.enum.FISH then elseif quest_type == Quest.enum.FISH then
if tooltip == '' then tooltip = {'pirates.gui_questframe_fish'} end if tooltip == '' then tooltip = { 'pirates.gui_questframe_fish' } end
elseif quest_type == Quest.enum.COMPILATRON then elseif quest_type == Quest.enum.COMPILATRON then
if tooltip == '' then tooltip = {'pirates.gui_questframe_compilatron'} end if tooltip == '' then tooltip = { 'pirates.gui_questframe_compilatron' } end
end end
end end
@ -943,7 +916,6 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo
end end
end end
-- local function create_gui_2() -- local function create_gui_2()
-- end -- end
@ -965,11 +937,11 @@ function Public.update_gui(player)
flow1 = pirates_flow.crew_piratebutton_frame.crew_piratebutton flow1 = pirates_flow.crew_piratebutton_frame.crew_piratebutton
if Common.is_id_valid(memory.id) then if Common.is_id_valid(memory.id) then
flow1.tooltip = {'pirates.gui_crew_tooltip_1'} flow1.tooltip = { 'pirates.gui_crew_tooltip_1' }
flow1.mouse_button_filter = {'left','right'} flow1.mouse_button_filter = { 'left', 'right' }
else else
flow1.tooltip = {'pirates.gui_crew_tooltip_2'} flow1.tooltip = { 'pirates.gui_crew_tooltip_2' }
flow1.mouse_button_filter = {'middle'} --hack to avoid press visual flow1.mouse_button_filter = { 'middle' } --hack to avoid press visual
if player.gui.screen['crew_piratewindow'] then if player.gui.screen['crew_piratewindow'] then
player.gui.screen['crew_piratewindow'].destroy() player.gui.screen['crew_piratewindow'].destroy()
end end
@ -978,11 +950,11 @@ function Public.update_gui(player)
flow1 = pirates_flow.classes_piratebutton_frame.classes_piratebutton flow1 = pirates_flow.classes_piratebutton_frame.classes_piratebutton
if Common.is_id_valid(memory.id) then if Common.is_id_valid(memory.id) then
flow1.tooltip = {'pirates.gui_classes_tooltip_1'} flow1.tooltip = { 'pirates.gui_classes_tooltip_1' }
flow1.mouse_button_filter = {'left','right'} flow1.mouse_button_filter = { 'left', 'right' }
else else
flow1.tooltip = {'pirates.gui_classes_tooltip_2'} flow1.tooltip = { 'pirates.gui_classes_tooltip_2' }
flow1.mouse_button_filter = {'middle'} --hack to avoid press visual flow1.mouse_button_filter = { 'middle' } --hack to avoid press visual
if player.gui.screen['classes_piratewindow'] then if player.gui.screen['classes_piratewindow'] then
player.gui.screen['classes_piratewindow'].destroy() player.gui.screen['classes_piratewindow'].destroy()
end end
@ -993,7 +965,6 @@ function Public.update_gui(player)
if GuiRuns.full_update then GuiRuns.full_update(player) end if GuiRuns.full_update then GuiRuns.full_update(player) end
if GuiCrew.full_update then GuiCrew.full_update(player) end if GuiCrew.full_update then GuiCrew.full_update(player) end
if GuiClasses.full_update then GuiClasses.full_update(player) end if GuiClasses.full_update then GuiClasses.full_update(player) end
if GuiFuel.regular_update then GuiFuel.regular_update(player) end --moved to event
if GuiMinimap.full_update then GuiMinimap.full_update(player) end if GuiMinimap.full_update then GuiMinimap.full_update(player) end
if GuiInfo.full_update then GuiInfo.full_update(player) end if GuiInfo.full_update then GuiInfo.full_update(player) end
@ -1013,7 +984,7 @@ function Public.update_gui(player)
flow1 = pirates_flow.fuel_flow flow1 = pirates_flow.fuel_flow
-- flow1 = pirates_flow.fuel_piratebutton_flow_1 -- flow1 = pirates_flow.fuel_piratebutton_flow_1
local tooltip = {'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0)} local tooltip = { 'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0) }
flow1.tooltip = tooltip flow1.tooltip = tooltip
-- flow1.fuel_piratebutton.tooltip = {'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0)} -- flow1.fuel_piratebutton.tooltip = {'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0)}
@ -1023,11 +994,11 @@ function Public.update_gui(player)
flow2.fuel_label_1.caption = Utils.bignumber_abbrevform(memory.stored_fuel or 0) .. '[item=coal]' flow2.fuel_label_1.caption = Utils.bignumber_abbrevform(memory.stored_fuel or 0) .. '[item=coal]'
flow2.fuel_label_2.caption = Utils.negative_rate_abbrevform(memory.fuel_depletion_rate_memoized or 0) flow2.fuel_label_2.caption = Utils.negative_rate_abbrevform(memory.fuel_depletion_rate_memoized or 0)
local color_scale = Math.clamp(0, 1, (- (memory.fuel_depletion_rate_memoized or 0))/30) local color_scale = Math.clamp(0, 1, (-(memory.fuel_depletion_rate_memoized or 0)) / 30)
flow2.fuel_label_2.style.font_color = { flow2.fuel_label_2.style.font_color = {
r = GuiCommon.fuel_color_1.r * (1-color_scale) + GuiCommon.fuel_color_2.r * color_scale, r = GuiCommon.fuel_color_1.r * (1 - color_scale) + GuiCommon.fuel_color_2.r * color_scale,
g = GuiCommon.fuel_color_1.g * (1-color_scale) + GuiCommon.fuel_color_2.g * color_scale, g = GuiCommon.fuel_color_1.g * (1 - color_scale) + GuiCommon.fuel_color_2.g * color_scale,
b = GuiCommon.fuel_color_1.b * (1-color_scale) + GuiCommon.fuel_color_2.b * color_scale, b = GuiCommon.fuel_color_1.b * (1 - color_scale) + GuiCommon.fuel_color_2.b * color_scale,
} }
flow2.fuel_label_0.tooltip = tooltip flow2.fuel_label_0.tooltip = tooltip
flow2.fuel_label_1.tooltip = tooltip flow2.fuel_label_1.tooltip = tooltip
@ -1037,7 +1008,7 @@ function Public.update_gui(player)
flow1 = pirates_flow.progress_piratebutton_frame.progress_piratebutton flow1 = pirates_flow.progress_piratebutton_frame.progress_piratebutton
flow1.number = (memory.overworldx or 0) flow1.number = (memory.overworldx or 0)
flow1.tooltip = {'pirates.gui_progress_tooltip', memory.overworldx or 0, CoreData.victory_x} flow1.tooltip = { 'pirates.gui_progress_tooltip', memory.overworldx or 0, CoreData.victory_x }
-- pirates_flow.destination_piratebutton_frame.destination_piratebutton.number = memory.destinationsvisited_indices and #memory.destinationsvisited_indices or 0 -- pirates_flow.destination_piratebutton_frame.destination_piratebutton.number = memory.destinationsvisited_indices and #memory.destinationsvisited_indices or 0
@ -1178,41 +1149,41 @@ function Public.update_gui(player)
if not flow1 then --comfy panel might possibly destroy this, so this puts it back if not flow1 then --comfy panel might possibly destroy this, so this puts it back
flow1 = flow1 =
player.gui.screen.add( player.gui.screen.add(
{ {
type = 'camera', type = 'camera',
name = 'pirates_spontaneous_camera', name = 'pirates_spontaneous_camera',
position = {x=0,y=0}, position = { x = 0, y = 0 },
} }
) )
flow1.visible = false flow1.visible = false
flow1.style.margin = 8 flow1.style.margin = 8
end end
if flow1 then if flow1 then
flow1.visible = false flow1.visible = false
flow1.location = {x = 8, y = 48} flow1.location = { x = 8, y = 48 }
if bools.on_deck_standing_near_loco_bool then if bools.on_deck_standing_near_loco_bool then
flow1.visible = true flow1.visible = true
flow1.surface_index = Hold.get_hold_surface(1).index flow1.surface_index = Hold.get_hold_surface(1).index
flow1.zoom = 0.182 flow1.zoom = 0.182
flow1.style.minimal_height = 292 flow1.style.minimal_height = 292
flow1.style.minimal_width = 540 flow1.style.minimal_width = 540
flow1.position = {x=0,y=-2} flow1.position = { x = 0, y = -2 }
elseif bools.on_deck_standing_near_cabin_bool then elseif bools.on_deck_standing_near_cabin_bool then
flow1.visible = true flow1.visible = true
flow1.surface_index = Cabin.get_cabin_surface().index flow1.surface_index = Cabin.get_cabin_surface().index
flow1.zoom = 0.468 flow1.zoom = 0.468
flow1.style.minimal_height = 400 flow1.style.minimal_height = 400
flow1.style.minimal_width = 280 flow1.style.minimal_width = 280
flow1.position = {x=0,y=-1} flow1.position = { x = 0, y = -1 }
elseif bools.on_deck_standing_near_crowsnest_bool then elseif bools.on_deck_standing_near_crowsnest_bool then
flow1.visible = true flow1.visible = true
flow1.surface_index = Crowsnest.get_crowsnest_surface().index flow1.surface_index = Crowsnest.get_crowsnest_surface().index
flow1.zoom = 0.21 flow1.zoom = 0.21
flow1.style.minimal_height = 384 flow1.style.minimal_height = 384
flow1.style.minimal_width = 384 flow1.style.minimal_width = 384
flow1.position = {x=memory.overworldx,y=memory.overworldy} flow1.position = { x = memory.overworldx, y = memory.overworldy }
elseif bools.in_crowsnest_bool then elseif bools.in_crowsnest_bool then
flow1.visible = true flow1.visible = true
flow1.surface_index = game.surfaces[memory.boat.surface_name].index flow1.surface_index = game.surfaces[memory.boat.surface_name].index
@ -1223,15 +1194,13 @@ function Public.update_gui(player)
local position = memory.boat.position local position = memory.boat.position
if (destination and destination.type and destination.type == Surfaces.enum.ISLAND and memory.boat.surface_name and memory.boat.surface_name == destination.surface_name and destination.static_params and destination.static_params.boat_starting_xposition) then if (destination and destination.type and destination.type == Surfaces.enum.ISLAND and memory.boat.surface_name and memory.boat.surface_name == destination.surface_name and destination.static_params and destination.static_params.boat_starting_xposition) then
-- nicer viewing position: -- nicer viewing position:
position = {x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0} position = { x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0 }
end end
flow1.position = position flow1.position = position
end end
end end
end end
-- ATTENTION: Giving same names to GUI elements can cause issues, because click events are dispatched to all GUI windows! -- ATTENTION: Giving same names to GUI elements can cause issues, because click events are dispatched to all GUI windows!
local function on_gui_click(event) local function on_gui_click(event)
if not event then return end if not event then return end
@ -1258,7 +1227,6 @@ local function on_gui_click(event)
memory.undock_shortcut_are_you_sure_data[player.index] = game.tick memory.undock_shortcut_are_you_sure_data[player.index] = game.tick
end end
end end
elseif memory.boat.state == Boats.enum_state.ATSEA_WAITING_TO_SAIL then elseif memory.boat.state == Boats.enum_state.ATSEA_WAITING_TO_SAIL then
if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then
local destination_index = memory.mapbeingloadeddestination_index local destination_index = memory.mapbeingloadeddestination_index
@ -1266,7 +1234,6 @@ local function on_gui_click(event)
Progression.progress_to_destination(destination_index) Progression.progress_to_destination(destination_index)
memory.loadingticks = 0 memory.loadingticks = 0
end end
elseif memory.boat.state == Boats.enum_state.ATSEA_VICTORIOUS then elseif memory.boat.state == Boats.enum_state.ATSEA_VICTORIOUS then
if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then
memory.boat.state = Boats.enum_state.ATSEA_SAILING memory.boat.state = Boats.enum_state.ATSEA_SAILING
@ -1275,17 +1242,16 @@ local function on_gui_click(event)
if not (force and force.valid) then return end if not (force and force.valid) then return end
if memory.victory_continue_message then if memory.victory_continue_message then
memory.victory_continue_message = false memory.victory_continue_message = false
Common.notify_force(force, {'pirates.crew_continue_on_freeplay'}, CoreData.colors.notify_victory) Common.notify_force(force, { 'pirates.crew_continue_on_freeplay' }, CoreData.colors.notify_victory)
end end
end end
end end
elseif string.sub(event.element.name, -13, -1) and string.sub(event.element.name, -13, -1) == '_piratebutton' then elseif string.sub(event.element.name, -13, -1) and string.sub(event.element.name, -13, -1) == '_piratebutton' then
local name = string.sub(event.element.name, 1, -14) local name = string.sub(event.element.name, 1, -14)
if Public[name] then if Public[name] then
Public[name].toggle_window(player) Public[name].toggle_window(player)
Public[name].full_update(player) Public[name].full_update(player)
end end
-- elseif event.element.name == 'fuel_label_1' or event.element.name == 'fuel_label_2' then -- elseif event.element.name == 'fuel_label_1' or event.element.name == 'fuel_label_2' then
-- Public.fuel.toggle_window(player) -- Public.fuel.toggle_window(player)
-- Public.fuel.full_update(player) -- Public.fuel.full_update(player)
@ -1294,10 +1260,9 @@ local function on_gui_click(event)
if GuiRuns.click then GuiRuns.click(event) end if GuiRuns.click then GuiRuns.click(event) end
if GuiCrew.click then GuiCrew.click(event) end if GuiCrew.click then GuiCrew.click(event) end
if GuiClasses.click then GuiClasses.click(event) end if GuiClasses.click then GuiClasses.click(event) end
if GuiFuel.click then GuiFuel.click(event) end
if GuiMinimap.click then GuiMinimap.click(event) end if GuiMinimap.click then GuiMinimap.click(event) end
if GuiInfo.click then GuiInfo.click(event) end if GuiInfo.click then GuiInfo.click(event) end
end end
end end
local function on_gui_location_changed(event) local function on_gui_location_changed(event)
@ -1320,4 +1285,4 @@ event.add(defines.events.on_gui_location_changed, on_gui_location_changed)
return Public return Public

View File

@ -40,7 +40,7 @@ function Public.toggle_window(player)
end -- else: end -- else:
flow = GuiCommon.new_window(player, window_name) flow = GuiCommon.new_window(player, window_name)
flow.caption = {'pirates.gui_minimap_outside_view'} flow.caption = { 'pirates.gui_minimap_outside_view' }
flow.style.maximal_width = 800 flow.style.maximal_width = 800
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
@ -60,11 +60,11 @@ function Public.toggle_window(player)
if not (memory.boat and memory.boat.position and memory.boat.surface_name) then return end if not (memory.boat and memory.boat.position and memory.boat.surface_name) then return end
local position = memory.boat.position local position = memory.boat.position
local destination = Common.current_destination() local destination = Common.current_destination()
if (destination and destination.type and destination.type == Surfaces.enum.ISLAND and destination.static_params and destination.static_params.boat_starting_xposition) then if (destination and destination.type and destination.type == Surfaces.enum.ISLAND and destination.static_params and destination.static_params.boat_starting_xposition) then
-- nicer viewing position: -- nicer viewing position:
position = {x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0} position = { x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0 }
end end
local zoom local zoom
if gui_memory and gui_memory[window_name] and gui_memory[window_name].zoom then if gui_memory and gui_memory[window_name] and gui_memory[window_name].zoom then
@ -79,25 +79,25 @@ function Public.toggle_window(player)
size = default_size size = default_size
end end
local element = flow['camera'] local element = flow['camera']
if not element then if not element then
element = element =
flow.add( flow.add(
{ {
type = 'camera', type = 'camera',
name = 'camera', name = 'camera',
position = position, position = position,
surface_index = game.surfaces[memory.boat.surface_name].index, surface_index = game.surfaces[memory.boat.surface_name].index,
zoom = zoom, zoom = zoom,
tooltip = {'pirates.gui_minimap_tooltip'} tooltip = { 'pirates.gui_minimap_tooltip' }
} }
) )
element.style.margin = 1 element.style.margin = 1
element.style.minimal_height = size element.style.minimal_height = size
element.style.minimal_width = size element.style.minimal_width = size
element.style.maximal_height = size element.style.maximal_height = size
element.style.maximal_width = size element.style.maximal_width = size
end end
flow2 = GuiCommon.flow_add_close_button(flow, window_name .. '_piratebutton') flow2 = GuiCommon.flow_add_close_button(flow, window_name .. '_piratebutton')
flow2.add( flow2.add(
@ -107,16 +107,12 @@ function Public.toggle_window(player)
index = 1, index = 1,
allow_none_state = false, allow_none_state = false,
switch_state = switch_state, switch_state = switch_state,
left_label_caption = {'pirates.gui_minimap_switch_left'}, left_label_caption = { 'pirates.gui_minimap_switch_left' },
right_label_caption = {'pirates.gui_minimap_switch_right'}, right_label_caption = { 'pirates.gui_minimap_switch_right' },
} }
) )
end end
-- function Public.regular_update(player) -- function Public.regular_update(player)
-- end -- end
@ -131,13 +127,13 @@ function Public.full_update(player)
if not player.gui.screen[window_name .. '_piratewindow'] then return end if not player.gui.screen[window_name .. '_piratewindow'] then return end
flow = player.gui.screen[window_name .. '_piratewindow'] flow = player.gui.screen[window_name .. '_piratewindow']
local element = flow['camera'] local element = flow['camera']
if element then if element then
local position = boat.position local position = boat.position
local destination = Common.current_destination() local destination = Common.current_destination()
if (destination and destination.type and destination.type == Surfaces.enum.ISLAND and boat.surface_name and boat.surface_name == destination.surface_name and destination.static_params and destination.static_params.boat_starting_xposition) then if (destination and destination.type and destination.type == Surfaces.enum.ISLAND and boat.surface_name and boat.surface_name == destination.surface_name and destination.static_params and destination.static_params.boat_starting_xposition) then
-- nicer viewing position: -- nicer viewing position:
position = {x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0} position = { x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0 }
end end
if position then if position then
@ -149,7 +145,6 @@ function Public.full_update(player)
end end
end end
function Public.click(event) function Public.click(event)
if not event.element then return end if not event.element then return end
if not event.element.valid then return end if not event.element.valid then return end
@ -162,13 +157,8 @@ function Public.click(event)
-- local flow = player.gui.screen[window_name .. '_piratewindow'] -- local flow = player.gui.screen[window_name .. '_piratewindow']
-- local memory = Memory.get_crew_memory() -- local memory = Memory.get_crew_memory()
-- local shop_data = Shop.main_shop_data
-- if eventname == 'buy_button' then if eventname ~= 'camera' then return end
-- Shop.Captains.main_shop_try_purchase(event.element.parent.name)
-- end
if eventname ~= 'camera' then return end
local zoom = default_zoom local zoom = default_zoom
local size = default_size local size = default_size
@ -181,7 +171,7 @@ function Public.click(event)
size = gui_memory[window_name].size or default_size size = gui_memory[window_name].size or default_size
end end
if event.button == defines.mouse_button_type.right then if event.button == defines.mouse_button_type.right then
if zoom == 0.15 then if zoom == 0.15 then
zoom = 0.11 zoom = 0.11
elseif zoom == 0.11 then elseif zoom == 0.11 then
@ -189,9 +179,9 @@ function Public.click(event)
else else
zoom = 0.04 zoom = 0.04
end end
event.element.zoom = zoom event.element.zoom = zoom
end end
if event.button == defines.mouse_button_type.left then if event.button == defines.mouse_button_type.left then
if zoom == 0.04 then if zoom == 0.04 then
zoom = 0.07 zoom = 0.07
elseif zoom == 0.07 then elseif zoom == 0.07 then
@ -199,9 +189,9 @@ function Public.click(event)
else else
zoom = 0.15 zoom = 0.15
end end
event.element.zoom = zoom event.element.zoom = zoom
end end
if event.button == defines.mouse_button_type.middle then if event.button == defines.mouse_button_type.middle then
if size == 340 then if size == 340 then
size = 440 size = 440
elseif size == 440 then elseif size == 440 then
@ -213,31 +203,29 @@ function Public.click(event)
else else
size = 340 size = 340
end end
event.element.style.minimal_height = size event.element.style.minimal_height = size
event.element.style.minimal_width = size event.element.style.minimal_width = size
event.element.style.maximal_height = size event.element.style.maximal_height = size
event.element.style.maximal_width = size event.element.style.maximal_width = size
end end
GuiCommon.update_gui_memory(player, window_name, 'zoom', zoom) GuiCommon.update_gui_memory(player, window_name, 'zoom', zoom)
GuiCommon.update_gui_memory(player, window_name, 'size', size) GuiCommon.update_gui_memory(player, window_name, 'size', size)
end end
local function on_player_changed_surface(event) local function on_player_changed_surface(event)
local player = game.players[event.player_index] local player = game.players[event.player_index]
if not Common.validate_player_and_character(player) then if not Common.validate_player_and_character(player) then
return return
end end
local window = player.gui.screen[window_name .. '_piratewindow'] local window = player.gui.screen[window_name .. '_piratewindow']
local from_hold_or_cabin_bool = string.sub(game.surfaces[event.surface_index].name, 9, 12) == 'Hold' or string.sub(game.surfaces[event.surface_index].name, 9, 13) == 'Cabin' local from_hold_or_cabin_bool = string.sub(game.surfaces[event.surface_index].name, 9, 12) == 'Hold' or string.sub(game.surfaces[event.surface_index].name, 9, 13) == 'Cabin'
local to_hold_or_cabin_bool = string.sub(player.surface.name, 9, 12) == 'Hold' or string.sub(player.surface.name, 9, 13) == 'Cabin' local to_hold_or_cabin_bool = string.sub(player.surface.name, 9, 12) == 'Hold' or string.sub(player.surface.name, 9, 13) == 'Cabin'
if from_hold_or_cabin_bool and (not to_hold_or_cabin_bool) then if from_hold_or_cabin_bool and (not to_hold_or_cabin_bool) then
if window then if window then
Public.toggle_window(player) Public.toggle_window(player)
end end
elseif to_hold_or_cabin_bool and (not from_hold_or_cabin_bool) then elseif to_hold_or_cabin_bool and (not from_hold_or_cabin_bool) then
@ -247,11 +235,10 @@ local function on_player_changed_surface(event)
if (gui_memory and gui_memory[window_name] and gui_memory[window_name].auto_map) or (not gui_memory) or (gui_memory and (not gui_memory[window_name])) then --if no gui memory exists for this, default to opening the minimap if (gui_memory and gui_memory[window_name] and gui_memory[window_name].auto_map) or (not gui_memory) or (gui_memory and (not gui_memory[window_name])) then --if no gui memory exists for this, default to opening the minimap
Public.toggle_window(player) Public.toggle_window(player)
end end
end end
end end
local event = require 'utils.event' local event = require 'utils.event'
event.add(defines.events.on_player_changed_surface, on_player_changed_surface) event.add(defines.events.on_player_changed_surface, on_player_changed_surface)
return Public return Public

View File

@ -57,7 +57,7 @@ require 'maps.pirates.ores'
require 'maps.pirates.quest' require 'maps.pirates.quest'
require 'maps.pirates.parrot' require 'maps.pirates.parrot'
require 'maps.pirates.shop.shop' require 'maps.pirates.shop.shop'
require 'maps.pirates.boat_upgrades' require 'maps.pirates.shop.boat_upgrades'
local Token = require 'utils.token' local Token = require 'utils.token'
local Task = require 'utils.task' local Task = require 'utils.task'
local Server = require 'utils.server' local Server = require 'utils.server'

View File

@ -26,7 +26,7 @@ local Crew = require 'maps.pirates.crew'
-- local Hold = require 'maps.pirates.surfaces.hold' -- local Hold = require 'maps.pirates.surfaces.hold'
-- local Cabin = require 'maps.pirates.surfaces.cabin' -- local Cabin = require 'maps.pirates.surfaces.cabin'
local Shop = require 'maps.pirates.shop.shop' local Shop = require 'maps.pirates.shop.shop'
local Upgrades = require 'maps.pirates.boat_upgrades' local Upgrades = require 'maps.pirates.shop.boat_upgrades'
local Kraken = require 'maps.pirates.surfaces.sea.kraken' local Kraken = require 'maps.pirates.surfaces.sea.kraken'
local Highscore = require 'maps.pirates.highscore' local Highscore = require 'maps.pirates.highscore'
local CustomEvents = require 'maps.pirates.custom_events' local CustomEvents = require 'maps.pirates.custom_events'
@ -424,12 +424,13 @@ function Public.generate_overworld_destination(p)
} }
local i = 1 local i = 1
for price_name, price_count in pairs(Shop.Captains.main_shop_data_1[dest.static_params.upgrade_for_sale].base_cost) do for _, price_data in ipairs(Upgrades.upgrades_data[dest.static_params.upgrade_for_sale].market_item.price) do
local price_name, price_count = price_data[1], price_data[2]
local sprite local sprite
if price_name == 'fuel' then if price_name == 'coal' then
sprite = 'item/coal' sprite = 'item/coal'
else else
sprite = 'item/coin' sprite = 'item/' .. price_name
end end
dest.dynamic_data.crowsnest_renderings[price_name] = { dest.dynamic_data.crowsnest_renderings[price_name] = {
text_rendering = rendering.draw_text { text_rendering = rendering.draw_text {
@ -516,7 +517,12 @@ function Public.ensure_lane_generated_up_to(lane_yvalue, x)
end end
for rendering_name, r in pairs(dest.dynamic_data.crowsnest_renderings) do for rendering_name, r in pairs(dest.dynamic_data.crowsnest_renderings) do
if type(r) == 'table' and r.text_rendering and rendering.is_valid(r.text_rendering) then if type(r) == 'table' and r.text_rendering and rendering.is_valid(r.text_rendering) then
rendering.set_text(r.text_rendering, Utils.bignumber_abbrevform2(Shop.Captains.main_shop_data_1[dest.static_params.upgrade_for_sale].base_cost[rendering_name])) for _, price_data in ipairs(Upgrades.upgrades_data[dest.static_params.upgrade_for_sale].market_item.price) do
if price_data[1] == rendering_name then
rendering.set_text(r.text_rendering, Utils.bignumber_abbrevform2(price_data[2]))
break
end
end
end end
end end
end end

View File

@ -29,7 +29,7 @@ local Shop = require 'maps.pirates.shop.shop'
local Overworld = require 'maps.pirates.overworld' local Overworld = require 'maps.pirates.overworld'
local Hold = require 'maps.pirates.surfaces.hold' local Hold = require 'maps.pirates.surfaces.hold'
local Cabin = require 'maps.pirates.surfaces.cabin' local Cabin = require 'maps.pirates.surfaces.cabin'
local Upgrades = require 'maps.pirates.boat_upgrades' local Upgrades = require 'maps.pirates.shop.boat_upgrades'
local Task = require 'utils.task' local Task = require 'utils.task'
local Token = require 'utils.token' local Token = require 'utils.token'
local ShopDock = require 'maps.pirates.shop.dock' local ShopDock = require 'maps.pirates.shop.dock'
@ -133,8 +133,6 @@ function Public.go_from_starting_dock_to_first_destination()
boat.stored_resources = {} boat.stored_resources = {}
Shop.Captains.initialise_captains_shop()
Hold.create_hold_surface(1) Hold.create_hold_surface(1)
boat.EEI_stage = 1 boat.EEI_stage = 1
boat.random_class_purchase_count = 0 boat.random_class_purchase_count = 0
@ -261,8 +259,6 @@ function Public.progress_to_destination(destination_index)
end end
end end
script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {})
-- Delay.add(Delay.enum.PLACE_DOCK_JETTY_AND_BOATS) -- Delay.add(Delay.enum.PLACE_DOCK_JETTY_AND_BOATS)
Task.set_timeout_in_ticks(2, place_dock_jetty_and_boats, { crew_id = memory.id }) Task.set_timeout_in_ticks(2, place_dock_jetty_and_boats, { crew_id = memory.id })
else else
@ -413,8 +409,6 @@ function Public.check_for_end_of_boat_movement(boat)
memory.mainshop_availability_bools.unlock_merchants = false memory.mainshop_availability_bools.unlock_merchants = false
memory.mainshop_availability_bools.rockets_for_sale = false memory.mainshop_availability_bools.rockets_for_sale = false
script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {})
Public.go_from_currentdestination_to_sea() Public.go_from_currentdestination_to_sea()
return true return true
@ -492,8 +486,6 @@ function Public.undock_from_dock(manual)
memory.mainshop_availability_bools.new_boat_cutter_with_hold = false memory.mainshop_availability_bools.new_boat_cutter_with_hold = false
memory.mainshop_availability_bools.new_boat_sloop_with_hold = false memory.mainshop_availability_bools.new_boat_sloop_with_hold = false
script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {})
Crew.summon_crew() Crew.summon_crew()
local force = memory.force local force = memory.force

View File

@ -49,13 +49,78 @@ Public.crowsnest_display_form = {
[enum.UPGRADE_CANNONS] = { 'pirates.upgrade_cannons_crowsnest_form' }, [enum.UPGRADE_CANNONS] = { 'pirates.upgrade_cannons_crowsnest_form' },
} }
-- WARNING: The dock market pulls from these values, but the Crowsnest caption pulls data from main_shop_data_1. So don't change one without the other Public.upgrades_data = {
Public.market_offer_form = { [enum.MORE_POWER] = {
[enum.MORE_POWER] = { price = { { 'coin', 7000 }, { 'coal', 500 } }, offer = { type = 'nothing', effect_description = { 'pirates.market_description_upgrade_power' } } }, market_item = {
[enum.EXTRA_HOLD] = { price = { { 'coin', 7000 }, { 'coal', 500 } }, offer = { type = 'nothing', effect_description = { 'pirates.market_description_upgrade_hold' } } }, price = {
[enum.UNLOCK_MERCHANTS] = { price = { { 'coin', 14000 }, { 'coal', 1000 } }, offer = { type = 'nothing', effect_description = { 'pirates.market_description_upgrade_merchants' } } }, { 'coin', 7000 },
[enum.ROCKETS_FOR_SALE] = { price = { { 'coin', 21000 }, { 'coal', 1000 } }, offer = { type = 'nothing', effect_description = { 'pirates.market_description_upgrade_rockets' } } }, { 'coal', 500 }
[enum.UPGRADE_CANNONS] = { price = { { 'repair-pack', 20 }, { 'coin', 5000 }, { 'coal', 800 } }, offer = { type = 'nothing', effect_description = { 'pirates.market_description_upgrade_turrets' } } }, },
offer = {
type = 'nothing',
effect_description = { 'pirates.market_description_upgrade_power' }
},
},
tooltip = { 'pirates.market_description_upgrade_power' },
what_you_get_sprite_buttons = { ['utility/status_working'] = false },
},
[enum.EXTRA_HOLD] = {
market_item = {
price = {
{ 'coin', 7000 },
{ 'coal', 500 }
},
offer = {
type = 'nothing',
effect_description = { 'pirates.market_description_upgrade_hold' }
},
},
tooltip = { 'pirates.market_description_upgrade_hold' },
what_you_get_sprite_buttons = { ['item/steel-chest'] = false },
},
[enum.UNLOCK_MERCHANTS] = {
market_item = {
price = {
{ 'coin', 14000 },
{ 'coal', 1000 }
},
offer = {
type = 'nothing',
effect_description = { 'pirates.market_description_upgrade_merchants' }
},
},
tooltip = { 'pirates.market_description_upgrade_merchants' },
what_you_get_sprite_buttons = { ['entity/market'] = false },
},
[enum.ROCKETS_FOR_SALE] = {
market_item = {
price = {
{ 'coin', 21000 },
{ 'coal', 1000 }
},
offer = {
type = 'nothing',
effect_description = { 'pirates.market_description_upgrade_rockets' }
},
},
tooltip = { 'pirates.market_description_upgrade_rockets' },
what_you_get_sprite_buttons = { ['item/rocket-launcher'] = false },
},
[enum.UPGRADE_CANNONS] = {
market_item = {
price = {
{ 'repair-pack', 20 },
{ 'coin', 5000 },
{ 'coal', 800 }
},
offer = {
type = 'nothing',
effect_description = { 'pirates.market_description_upgrade_turrets' }
},
},
tooltip = { 'pirates.market_description_upgrade_turrets' },
what_you_get_sprite_buttons = { ['item/artillery-turret'] = false },
},
} }
function Public.execute_upgade(upgrade_type, player) function Public.execute_upgade(upgrade_type, player)

View File

@ -1,347 +0,0 @@
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/ComfyFactory/ComfyFactorio and https://github.com/danielmartin0/ComfyFactorio-Pirates.
local Memory = require 'maps.pirates.memory'
-- local Roles = require 'maps.pirates.roles.roles'
-- local Balance = require 'maps.pirates.balance'
-- local Common = require 'maps.pirates.common'
-- local Utils = require 'maps.pirates.utils_local'
-- local Math = require 'maps.pirates.math'
-- local Loot = require 'maps.pirates.loot'
local _inspect = require 'utils.inspect'.inspect
local Upgrades = require 'maps.pirates.boat_upgrades'
-- local Hold = require 'maps.pirates.surfaces.hold'
-- local Crew = require 'maps.pirates.crew'
-- local Boats = require 'maps.pirates.structures.boats.boats'
-- local Dock = require 'maps.pirates.surfaces.dock'
local CustomEvents = require 'maps.pirates.custom_events'
local Public = {}
-- Note! This file is deprecated. It is replaced with a dedicated market at the dock and inside the captain's cabin. The exception is main_shop_data_1 as noted below, which is consulted for the Crowsnest caption. (Haven't had time to unify this yet.)
--== Warning: If something only costs fuel, then we need to check the player can't buy it whilst they're dead
-- WARNING: The Crowsnest caption pulls data from this data. But the actual dock market pulls from boat_upgrades.lua.
Public.main_shop_data_1 = {
-- upgrade_cannons = {
-- tooltip = 'Increase cannons max health. This will also repair them.',
-- what_you_get_sprite_buttons = {['item/artillery-turret'] = false},
-- base_cost = {coins = 1000},
-- },
new_boat_cutter = {
tooltip = 'Purchase a cutter.',
what_you_get_sprite_buttons = { ['utility/spawn_flag'] = false },
base_cost = { fuel = 3000 },
},
new_boat_sloop_with_hold = {
tooltip = 'Purchase a sloop (with hold).',
what_you_get_sprite_buttons = { ['utility/spawn_flag'] = false },
base_cost = { fuel = 3500 },
},
new_boat_cutter_with_hold = {
tooltip = 'Purchase a cutter (with hold).',
what_you_get_sprite_buttons = { ['utility/spawn_flag'] = false },
base_cost = { fuel = 5000 },
},
-- buy_iron = {
-- tooltip = 'Purchase 250 iron plates for 300 stored fuel.',
-- what_you_get_sprite_buttons = {['item/iron-plate'] = 250},
-- base_cost = {fuel = 300},
-- },
-- buy_copper = {
-- tooltip = 'Purchase 250 copper plates for 300 stored fuel.',
-- what_you_get_sprite_buttons = {['item/copper-plate'] = 250},
-- base_cost = {fuel = 300},
-- },
-- sell_iron = {
-- tooltip = 'Purchase 200 stored fuel for 2000 iron plates.',
-- what_you_get_sprite_buttons = {['item/sulfur'] = 200},
-- base_cost = {iron_plates = 2000},
-- },
-- sell_copper = {
-- tooltip = 'Purchase 100 stored fuel for 2500 copper plates',
-- what_you_get_sprite_buttons = {['item/sulfur'] = 100},
-- base_cost = {copper_plates = 2500},
-- },
-- as as initial pass let's try making the fuel values half of the old gold values...
[Upgrades.enum.MORE_POWER] = {
tooltip = { 'pirates.market_description_upgrade_power' },
what_you_get_sprite_buttons = { ['utility/status_working'] = false },
base_cost = { coins = 7000, fuel = 500 },
},
[Upgrades.enum.EXTRA_HOLD] = {
tooltip = { 'pirates.market_description_upgrade_hold' },
what_you_get_sprite_buttons = { ['item/steel-chest'] = false },
base_cost = { coins = 7000, fuel = 500 },
},
[Upgrades.enum.UNLOCK_MERCHANTS] = {
tooltip = { 'pirates.market_description_upgrade_merchants' },
what_you_get_sprite_buttons = { ['entity/market'] = false },
base_cost = { coins = 14000, fuel = 1000 },
},
[Upgrades.enum.ROCKETS_FOR_SALE] = {
tooltip = { 'pirates.market_description_upgrade_rockets' },
what_you_get_sprite_buttons = { ['item/rocket-launcher'] = false },
base_cost = { coins = 21000, fuel = 1000 },
},
[Upgrades.enum.UPGRADE_CANNONS] = {
tooltip = { 'pirates.market_description_upgrade_turrets' },
what_you_get_sprite_buttons = { ['item/artillery-turret'] = false },
base_cost = { coins = 5000, fuel = 800 },
},
}
Public.main_shop_data_2 = {
rail_signal = {
tooltip = "50 signals, used to steer the boat one space in the Crow's Nest View.",
what_you_get_sprite_buttons = { ['item/rail-signal'] = 50 },
base_cost = { coins = 500, fuel = 50 },
},
artillery_shell = {
tooltip = '8 cannon shells.',
what_you_get_sprite_buttons = { ['item/artillery-shell'] = 8 },
base_cost = { coins = 800, fuel = 30 },
},
-- artillery_remote = {
-- tooltip = 'An artillery targeting remote.',
-- what_you_get_sprite_buttons = {['item/artillery-targeting-remote'] = 1},
-- base_cost = {coins = 12000, fuel = 2500},
-- },
-- buy_fast_loader = {
-- tooltip = 'A fast loader for 500 stored fuel.',
-- what_you_get_sprite_buttons = {['item/fast-loader'] = 1},
-- base_cost = {fuel = 500},
-- },
uranium_ore = {
tooltip = '10 green rocks of unknown origin.',
what_you_get_sprite_buttons = { ['item/uranium-238'] = 10 },
base_cost = { coins = 1000, fuel = 100 },
},
extra_time = {
tooltip = 'Relax at sea for an extra minute. (Increases the next destination\'s loading time.)',
what_you_get_sprite_buttons = { ['utility/time_editor_icon'] = 60 },
base_cost = { coins = 10, fuel = 1 },
},
}
function Public.initialise_captains_shop()
local memory = Memory.get_crew_memory()
memory.mainshop_availability_bools = {
uranium_ore = true,
rail_signal = true,
artillery_shell = true,
artillery_remote = false, --good way to get trolled by crew and remove skill
extra_time = false,
new_boat_sloop_with_hold = false,
new_boat_cutter_with_hold = false,
new_boat_cutter = false,
buy_iron = false,
upgrade_cannons = false,
-- sell_iron = false,
-- buy_fast_loader = true,
-- sell_copper = false,
}
script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {})
end
-- function Public.main_shop_try_purchase(player, purchase_name)
-- local memory = Memory.get_crew_memory()
-- local destination = Common.current_destination()
-- local shop_data_1 = Public.main_shop_data_1
-- local shop_data_2 = Public.main_shop_data_2
-- local trade_data = shop_data_1[purchase_name] or shop_data_2[purchase_name]
-- if not trade_data then return end
-- local stored_fuel = memory.stored_fuel
-- if not stored_fuel then return end
-- -- local captain_index = memory.playerindex_captain
-- -- if not (stored_fuel and captain_index) then return end
-- -- local captain = game.players[captain_index]
-- if not Common.validate_player_and_character(player) then return end
-- local inv = player.get_inventory(defines.inventory.character_main)
-- if not (inv and inv.valid) then return end
-- local multiplier = Balance.main_shop_cost_multiplier()
-- -- local rate_limit_ok = not (memory.mainshop_rate_limit_ticker and memory.mainshop_rate_limit_ticker > 0)
-- local rate_limit_ok = true
-- local enough_fuel = true
-- local enough_iron_plates = true
-- local enough_coins = true
-- local enough_copper_plates = true
-- local coins_got
-- local iron_plates_got
-- local copper_plates_got
-- -- local able_to_buy_boats = memory.boat.state == Boats.enum_state.DOCKED --disabled for now
-- local able_to_buy_boats = false
-- -- local able_to_buy_boats = (memory.boat.state == Boats.enum_state.DOCKED or memory.boat.state == Boats.enum_state.APPROACHING) --problem with this if you buy whilst approaching, the original one no longer moves
-- for k, v in pairs(trade_data.base_cost) do
-- if k == 'fuel' then
-- enough_fuel = (stored_fuel >= v * multiplier)
-- elseif k == 'coins' then
-- coins_got = inv.get_item_count('coin')
-- enough_coins = coins_got >= v * multiplier
-- elseif k == 'iron_plates' then
-- iron_plates_got = inv.get_item_count('iron-plate')
-- enough_iron_plates = iron_plates_got >= v * multiplier
-- elseif k == 'copper_plates' then
-- copper_plates_got = inv.get_item_count('copper-plate')
-- enough_copper_plates = copper_plates_got >= v * multiplier
-- end
-- end
-- local can_buy = rate_limit_ok and enough_coins and enough_fuel and enough_iron_plates and enough_copper_plates
-- if purchase_name == 'new_boat_sloop_with_hold' or purchase_name == 'new_boat_cutter_with_hold' or purchase_name == 'new_boat_cutter' then can_buy = can_buy and able_to_buy_boats end
-- -- @TODO: prevent people from buying things whilst marooned
-- if can_buy then
-- for k, v in pairs(trade_data.base_cost) do
-- if k == 'fuel' then
-- memory.stored_fuel = memory.stored_fuel - v * multiplier
-- elseif k == 'coins' then
-- inv.remove{name="coin", count=v * multiplier}
-- elseif k == 'iron_plates' then
-- inv.remove{name="iron-plate", count=v * multiplier}
-- elseif k == 'copper_plates' then
-- inv.remove{name="copper-plate", count=v * multiplier}
-- end
-- end
-- local force = memory.force
-- if not (force and force.valid) then return end
-- local gotamount
-- if purchase_name == 'uranium_ore' then
-- gotamount = trade_data.what_you_get_sprite_buttons['item/uranium-238']
-- Common.give(player, {{name = 'uranium-238', count = gotamount}})
-- Common.notify_force_light(force,string.format('%s is buying green rocks...', player.name))
-- elseif purchase_name == 'extra_time' then
-- local success = Crew.try_add_extra_time_at_sea(60 * 60)
-- if success then
-- Common.notify_force_light(force,string.format('%s is buying extra time at sea...', player.name))
-- else
-- Common.notify_player_error(player, string.format('Purchase error: Can\'t buy more time than this.', player.name))
-- -- refund:
-- memory.stored_fuel = memory.stored_fuel + trade_data.base_cost.fuel * multiplier
-- end
-- elseif purchase_name == 'rail_signal' then
-- gotamount = trade_data.what_you_get_sprite_buttons['item/rail-signal']
-- Common.give(player, {{name = 'rail-signal', count = gotamount}})
-- Common.notify_force_light(force,string.format('%s is buying signals...', player.name))
-- elseif purchase_name == 'artillery_shell' then
-- gotamount = trade_data.what_you_get_sprite_buttons['item/artillery-shell']
-- Common.give(player, {{name = 'artillery-shell', count = gotamount}})
-- Common.notify_force_light(force,string.format('%s is buying cannon shells...', player.name))
-- elseif purchase_name == 'artillery_remote' then
-- gotamount = trade_data.what_you_get_sprite_buttons['item/artillery-targeting-remote']
-- Common.give(player, {{name = 'artillery-targeting-remote', count = gotamount}})
-- Common.notify_force_light(force,string.format('%s is buying an artillery targeting remote...', player.name))
-- elseif purchase_name == 'new_boat_cutter' or purchase_name == 'new_boat_cutter_with_hold' or purchase_name == 'new_boat_sloop_with_hold' then
-- Dock.execute_boat_purchase()
-- Common.notify_force(force,string.format('[font=heading-1]%s bought a %s.[/font]', player.name, Boats[Common.current_destination().static_params.boat_for_sale_type].Data.display_name))
-- elseif purchase_name == 'repair_cannons' then
-- -- heal all cannons:
-- local cannons = game.surfaces[destination.surface_name].find_entities_filtered({type = 'artillery-turret'})
-- for _, c in pairs(cannons) do
-- local unit_number = c.unit_number
-- local healthbar = memory.healthbars[unit_number]
-- if _DEBUG then game.print(unit_number) end
-- if healthbar then
-- healthbar.health = healthbar.max_health
-- Public.update_healthbar_rendering(healthbar, healthbar.max_health)
-- end
-- end
-- Common.notify_force(force,string.format('[font=heading-1]%s repaired the cannons.[/font]', player.name))
-- memory.mainshop_availability_bools[purchase_name] = false
-- elseif purchase_name == Upgrades.enum.MORE_POWER then
-- Upgrades.execute_upgade(Upgrades.enum.MORE_POWER)
-- memory.mainshop_availability_bools[purchase_name] = false
-- elseif purchase_name == Upgrades.enum.EXTRA_HOLD then
-- Upgrades.execute_upgade(Upgrades.enum.EXTRA_HOLD)
-- memory.mainshop_availability_bools[purchase_name] = false
-- elseif purchase_name == Upgrades.enum.UNLOCK_MERCHANTS then
-- Upgrades.execute_upgade(Upgrades.enum.UNLOCK_MERCHANTS)
-- memory.mainshop_availability_bools[purchase_name] = false
-- elseif purchase_name == Upgrades.enum.ROCKETS_FOR_SALE then
-- Upgrades.execute_upgade(Upgrades.enum.ROCKETS_FOR_SALE)
-- memory.mainshop_availability_bools[purchase_name] = false
-- elseif purchase_name == 'sell_iron' then
-- gotamount = trade_data.what_you_get_sprite_buttons['item/coal']
-- Common.give(player, {{name = 'fuel', count = gotamount}})
-- Common.notify_force_light(force,string.format('%s is selling iron...', player.name))
-- elseif purchase_name == 'buy_iron' then
-- gotamount = trade_data.what_you_get_sprite_buttons['item/iron-plate']
-- Common.give_items_to_crew{{name = 'iron-plate', count = gotamount}}
-- Common.notify_force_light(force,string.format('%s is buying iron...', player.name))
-- elseif purchase_name == 'buy_copper' then
-- gotamount = trade_data.what_you_get_sprite_buttons['item/copper-plate']
-- Common.give_items_to_crew{{name = 'copper-plate', count = gotamount}}
-- Common.notify_force_light(force,string.format('%s is buying copper...', player.name))
-- -- elseif name == 'buy_fast_loader' then
-- -- gotamount = trade_data.what_you_get_sprite_buttons['item/fast-loader']
-- -- Common.give(player, {{name = 'fast-loader', count = gotamount}})
-- -- Common.notify_force_light(force,string.format('%s bought a fast loader...', player.name))
-- elseif purchase_name == 'sell_copper' then
-- gotamount = trade_data.what_you_get_sprite_buttons['item/coal']
-- Common.give(player, {{name = 'fuel', count = gotamount}})
-- Common.notify_force_light(force,string.format('%s is selling copper...', player.name))
-- end
-- script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {})
-- -- memory.mainshop_rate_limit_ticker = Common.mainshop_rate_limit_ticks
-- else
-- -- play sound?
-- if rate_limit_ok == false then
-- Common.notify_player_error(player, 'Purchase error: Shop rate limit exceeded.')
-- end
-- if enough_fuel == false then
-- Common.notify_player_error(player, 'Purchase error: Not enough stored fuel.')
-- end
-- if enough_coins == false then
-- Common.notify_player_error(player, 'Purchase error: Not enough doubloons.')
-- end
-- if enough_iron_plates == false then
-- Common.notify_player_error(player, 'Purchase error: Not enough iron plates.')
-- end
-- if enough_copper_plates == false then
-- Common.notify_player_error(player, 'Purchase error: Not enough copper plates.')
-- end
-- if (purchase_name == 'new_boat_cutter' or purchase_name == 'new_boat_sloop_with_hold' or purchase_name == 'new_boat_cutter_with_hold') and (not able_to_buy_boats) then
-- Common.notify_player_error(player, 'Purchase error: Not able to purchase ships right now.')
-- end
-- end
-- end
return Public

View File

@ -13,7 +13,7 @@ local Utils = require 'maps.pirates.utils_local'
local Math = require 'maps.pirates.math' local Math = require 'maps.pirates.math'
local _inspect = require 'utils.inspect'.inspect local _inspect = require 'utils.inspect'.inspect
-- local Upgrades = require 'maps.pirates.boat_upgrades' -- local Upgrades = require 'maps.pirates.shop.boat_upgrades'
local Public = {} local Public = {}
@ -26,7 +26,7 @@ Public.offers_loaders = {
} }
Public.offers_rockets = { Public.offers_rockets = {
{ price = { { 'coin', 250 }, { 'electronic-circuit', 80 } }, offer = { type = 'give-item', item = 'rocket-launcher', count = 1 } }, { price = { { 'coin', 250 }, { 'electronic-circuit', 80 } }, offer = { type = 'give-item', item = 'rocket-launcher', count = 1 } },
{ price = { { 'coin', 1200 }, { 'explosives', 20 }, { 'electronic-circuit', 20 } }, offer = { type = 'give-item', item = 'rocket', count = 20 } }, { price = { { 'coin', 1200 }, { 'explosives', 20 }, { 'electronic-circuit', 20 } }, offer = { type = 'give-item', item = 'rocket', count = 20 } },
} }
@ -34,19 +34,19 @@ Public.offers_default = {
{ price = { { 'coin', 1500 } }, offer = { type = 'give-item', item = 'copper-plate', count = 300 } }, { price = { { 'coin', 1500 } }, offer = { type = 'give-item', item = 'copper-plate', count = 300 } },
{ price = { { 'coin', 1500 } }, offer = { type = 'give-item', item = 'iron-plate', count = 300 } }, { price = { { 'coin', 1500 } }, offer = { type = 'give-item', item = 'iron-plate', count = 300 } },
{ price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'piercing-rounds-magazine', count = 60 } }, { price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'piercing-rounds-magazine', count = 60 } },
{ price = { { 'coin', 900 } }, offer = { type = 'give-item', item = 'heavy-armor', count = 1 } }, { price = { { 'coin', 900 } }, offer = { type = 'give-item', item = 'heavy-armor', count = 1 } },
{ price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'grenade', count = 30 } }, { price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'grenade', count = 30 } },
{ price = { { 'coin', 1200 } }, offer = { type = 'give-item', item = 'defender-capsule', count = 15 } }, { price = { { 'coin', 1200 } }, offer = { type = 'give-item', item = 'defender-capsule', count = 15 } },
{ price = { { 'coin', 1500 } }, offer = { type = 'give-item', item = 'distractor-capsule', count = 15 } }, { price = { { 'coin', 1500 } }, offer = { type = 'give-item', item = 'distractor-capsule', count = 15 } },
{ price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'slowdown-capsule', count = 25 } }, { price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'slowdown-capsule', count = 25 } },
{ price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'poison-capsule', count = 15 } }, { price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'poison-capsule', count = 15 } },
{ price = { { 'coin', 1400 } }, offer = { type = 'give-item', item = 'gate', count = 25 } }, { price = { { 'coin', 1400 } }, offer = { type = 'give-item', item = 'gate', count = 25 } },
{ price = { { 'coin', 800 } }, offer = { type = 'give-item', item = 'storage-tank', count = 20 } }, { price = { { 'coin', 800 } }, offer = { type = 'give-item', item = 'storage-tank', count = 20 } },
{ price = { { 'coin', 600 } }, offer = { type = 'give-item', item = 'big-electric-pole', count = 15 } }, { price = { { 'coin', 600 } }, offer = { type = 'give-item', item = 'big-electric-pole', count = 15 } },
{ price = { { 'coin', 850 } }, offer = { type = 'give-item', item = 'stack-inserter', count = 7 } }, { price = { { 'coin', 850 } }, offer = { type = 'give-item', item = 'stack-inserter', count = 7 } },
{ price = { { 'coin', 900 } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell', count = 15 } }, { price = { { 'coin', 900 } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell', count = 15 } },
{ price = { { 'coin', 960 } }, offer = { type = 'give-item', item = 'flamethrower', count = 1 } }, { price = { { 'coin', 960 } }, offer = { type = 'give-item', item = 'flamethrower', count = 1 } },
{ price = { { 'coin', 980 } }, offer = { type = 'give-item', item = 'flamethrower', count = 1 } }, { price = { { 'coin', 980 } }, offer = { type = 'give-item', item = 'flamethrower', count = 1 } },
{ price = { { 'coin', 1700 } }, offer = { type = 'give-item', item = 'flamethrower-ammo', count = 15 } }, { price = { { 'coin', 1700 } }, offer = { type = 'give-item', item = 'flamethrower-ammo', count = 15 } },
{ price = { { 'coin', 1800 } }, offer = { type = 'give-item', item = 'flamethrower-ammo', count = 20 } }, { price = { { 'coin', 1800 } }, offer = { type = 'give-item', item = 'flamethrower-ammo', count = 20 } },
{ price = { { 'coin', 1800 } }, offer = { type = 'give-item', item = 'flying-robot-frame', count = 5 } }, { price = { { 'coin', 1800 } }, offer = { type = 'give-item', item = 'flying-robot-frame', count = 5 } },

View File

@ -12,10 +12,10 @@ local Balance = require 'maps.pirates.balance'
local Common = require 'maps.pirates.common' local Common = require 'maps.pirates.common'
local Utils = require 'maps.pirates.utils_local' local Utils = require 'maps.pirates.utils_local'
local Math = require 'maps.pirates.math' local Math = require 'maps.pirates.math'
local Upgrades = require 'maps.pirates.boat_upgrades' local Upgrades = require 'maps.pirates.shop.boat_upgrades'
local _inspect = require 'utils.inspect'.inspect local _inspect = require 'utils.inspect'.inspect
-- local Upgrades = require 'maps.pirates.boat_upgrades' -- local Upgrades = require 'maps.pirates.shop.boat_upgrades'
local Public = {} local Public = {}
@ -23,67 +23,67 @@ local Public = {}
Public.market_barters = { Public.market_barters = {
{ price = { { 'iron-plate', 300 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } }, { price = { { 'iron-plate', 300 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } },
{ price = { { 'copper-plate', 300 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } }, { price = { { 'copper-plate', 300 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } },
--repeating these: --repeating these:
{ price = { { 'iron-plate', 300 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } }, { price = { { 'iron-plate', 300 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } },
{ price = { { 'copper-plate', 300 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } }, { price = { { 'copper-plate', 300 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } },
{ price = { { 'steel-plate', 40 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } }, { price = { { 'steel-plate', 40 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } },
{ price = { { 'steel-plate', 40 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } }, { price = { { 'steel-plate', 40 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } },
{ price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'coal', count = 500 } }, { price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'coal', count = 500 } },
{ price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'iron-plate', count = 750 } }, { price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'iron-plate', count = 750 } },
{ price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'copper-plate', count = 750 } }, { price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'copper-plate', count = 750 } },
{ price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'steel-plate', count = 150 } }, { price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'steel-plate', count = 150 } },
{ price = { { 'wood', 200 } }, offer = { type = 'give-item', item = 'coin', count = 360 } }, { price = { { 'wood', 200 } }, offer = { type = 'give-item', item = 'coin', count = 360 } },
{ price = { { 'wood', 150 } }, offer = { type = 'give-item', item = 'coal', count = 150 } }, { price = { { 'wood', 150 } }, offer = { type = 'give-item', item = 'coal', count = 150 } },
{ price = { { 'stone-brick', 200 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } }, { price = { { 'stone-brick', 200 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } },
{ price = { { 'stone-brick', 200 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } }, { price = { { 'stone-brick', 200 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } },
{ price = { { 'stone-brick', 200 } }, offer = { type = 'give-item', item = 'steel-plate', count = 160 } }, { price = { { 'stone-brick', 200 } }, offer = { type = 'give-item', item = 'steel-plate', count = 160 } },
} }
-- permanent means you can buy more than once (but only some items???) -- permanent means you can buy more than once (but only some items???)
Public.market_permanent_offers = { Public.market_permanent_offers = {
{ price = { { 'pistol', 1 } }, offer = { type = 'give-item', item = 'coin', count = Balance.coin_sell_amount } }, { price = { { 'pistol', 1 } }, offer = { type = 'give-item', item = 'coin', count = Balance.coin_sell_amount } },
{ price = { { 'coin', 3600 } }, offer = { type = 'give-item', item = 'iron-ore', count = 800 } }, { price = { { 'coin', 3600 } }, offer = { type = 'give-item', item = 'iron-ore', count = 800 } },
{ price = { { 'coin', 3600 } }, offer = { type = 'give-item', item = 'copper-ore', count = 800 } }, { price = { { 'coin', 3600 } }, offer = { type = 'give-item', item = 'copper-ore', count = 800 } },
{ price = { { 'coin', 4200 } }, offer = { type = 'give-item', item = 'crude-oil-barrel', count = 100 } }, { price = { { 'coin', 4200 } }, offer = { type = 'give-item', item = 'crude-oil-barrel', count = 100 } },
{ price = { { 'coin', 3600 } }, offer = { type = 'give-item', item = 'fast-loader', count = 1 } }, { price = { { 'coin', 3600 } }, offer = { type = 'give-item', item = 'fast-loader', count = 1 } },
{ price = { { 'coin', 6200 } }, offer = { type = 'give-item', item = 'beacon', count = 2 } }, { price = { { 'coin', 6200 } }, offer = { type = 'give-item', item = 'beacon', count = 2 } },
{ price = { { 'coin', 4200 } }, offer = { type = 'give-item', item = 'speed-module-2', count = 2 } }, { price = { { 'coin', 4200 } }, offer = { type = 'give-item', item = 'speed-module-2', count = 2 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'explosives', count = 50 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'explosives', count = 50 } },
{ price = { { 'coin', 6500 }, { 'steel-plate', 25 }, { 'explosives', 50 } }, offer = { type = 'give-item', item = 'land-mine', count = 100 } }, { price = { { 'coin', 6500 }, { 'steel-plate', 25 }, { 'explosives', 50 } }, offer = { type = 'give-item', item = 'land-mine', count = 100 } },
-- {price = {{'coin', 30000}}, offer = {type = 'give-item', item = 'artillery-targeting-remote', count = 1}}, -- {price = {{'coin', 30000}}, offer = {type = 'give-item', item = 'artillery-targeting-remote', count = 1}},
} }
-- cheap but one-off -- cheap but one-off
Public.market_sales = { Public.market_sales = {
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'coal', count = 900 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'coal', count = 900 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'piercing-rounds-magazine', count = 75 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'piercing-rounds-magazine', count = 75 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'uranium-rounds-magazine', count = 20 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'uranium-rounds-magazine', count = 20 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell', count = 50 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell', count = 50 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'raw-fish', count = 300 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'raw-fish', count = 300 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'laser-turret', count = 1 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'laser-turret', count = 1 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'vehicle-machine-gun', count = 2 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'vehicle-machine-gun', count = 2 } },
{ price = { { 'coin', 6000 } }, offer = { type = 'give-item', item = 'modular-armor', count = 1 } }, { price = { { 'coin', 6000 } }, offer = { type = 'give-item', item = 'modular-armor', count = 1 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'distractor-capsule', count = 20 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'distractor-capsule', count = 20 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'poison-capsule', count = 20 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'poison-capsule', count = 20 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'slowdown-capsule', count = 20 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'slowdown-capsule', count = 20 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'coin', count = 6000 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'coin', count = 6000 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'roboport', count = 1 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'roboport', count = 1 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'construction-robot', count = 10 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'construction-robot', count = 10 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'logistic-chest-passive-provider', count = 2 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'logistic-chest-passive-provider', count = 2 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'logistic-robot', count = 2 } }, { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'logistic-robot', count = 2 } },
{ price = { { 'transport-belt', 100 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-transport-belt', count = 100 } }, { price = { { 'transport-belt', 100 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-transport-belt', count = 100 } },
{ price = { { 'fast-transport-belt', 100 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-transport-belt', count = 100 } }, { price = { { 'fast-transport-belt', 100 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-transport-belt', count = 100 } },
{ price = { { 'underground-belt', 10 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-underground-belt', count = 10 } }, { price = { { 'underground-belt', 10 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-underground-belt', count = 10 } },
{ price = { { 'fast-underground-belt', 10 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-underground-belt', count = 10 } }, { price = { { 'fast-underground-belt', 10 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-underground-belt', count = 10 } },
{ price = { { 'splitter', 10 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-splitter', count = 10 } }, { price = { { 'splitter', 10 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-splitter', count = 10 } },
{ price = { { 'fast-splitter', 10 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-splitter', count = 10 } }, { price = { { 'fast-splitter', 10 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-splitter', count = 10 } },
{ price = { { 'pistol', 1 }, { 'coin', 300 } }, offer = { type = 'give-item', item = 'submachine-gun', count = 1 } }, { price = { { 'pistol', 1 }, { 'coin', 300 } }, offer = { type = 'give-item', item = 'submachine-gun', count = 1 } },
{ price = { { 'submachine-gun', 1 }, { 'coin', 1000 } }, offer = { type = 'give-item', item = 'vehicle-machine-gun', count = 1 } }, { price = { { 'submachine-gun', 1 }, { 'coin', 1000 } }, offer = { type = 'give-item', item = 'vehicle-machine-gun', count = 1 } },
{ price = { { 'shotgun', 1 }, { 'coin', 3500 } }, offer = { type = 'give-item', item = 'combat-shotgun', count = 1 } }, { price = { { 'shotgun', 1 }, { 'coin', 3500 } }, offer = { type = 'give-item', item = 'combat-shotgun', count = 1 } },
{ price = { { 'shotgun-shell', 100 }, { 'coin', 2000 } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell', count = 100 } }, { price = { { 'shotgun-shell', 100 }, { 'coin', 2000 } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell', count = 100 } },
{ price = { { 'piercing-rounds-magazine', 100 }, { 'coin', 3500 } }, offer = { type = 'give-item', item = 'uranium-rounds-magazine', count = 100 } }, { price = { { 'piercing-rounds-magazine', 100 }, { 'coin', 3500 } }, offer = { type = 'give-item', item = 'uranium-rounds-magazine', count = 100 } },
} }
@ -162,7 +162,7 @@ function Public.create_dock_markets(surface, p)
local upgrade_for_sale = Common.current_destination().static_params.upgrade_for_sale local upgrade_for_sale = Common.current_destination().static_params.upgrade_for_sale
if upgrade_for_sale then if upgrade_for_sale then
e.add_market_item(Upgrades.market_offer_form[upgrade_for_sale]) e.add_market_item(Upgrades.upgrades_data[upgrade_for_sale].market_item)
end end
destination.dynamic_data.dock_captains_market = e destination.dynamic_data.dock_captains_market = e

View File

@ -14,12 +14,11 @@ local Roles = require 'maps.pirates.roles.roles'
local Math = require 'maps.pirates.math' local Math = require 'maps.pirates.math'
local _inspect = require 'utils.inspect'.inspect local _inspect = require 'utils.inspect'.inspect
local SurfacesCommon = require 'maps.pirates.surfaces.common' local SurfacesCommon = require 'maps.pirates.surfaces.common'
local Upgrades = require 'maps.pirates.boat_upgrades' local Upgrades = require 'maps.pirates.shop.boat_upgrades'
local Cabin = require 'maps.pirates.surfaces.cabin' local Cabin = require 'maps.pirates.surfaces.cabin'
-- local Upgrades = require 'maps.pirates.boat_upgrades' -- local Upgrades = require 'maps.pirates.shop.boat_upgrades'
local Public = {} local Public = {}
Public.Captains = require 'maps.pirates.shop.captains'
Public.Covered = require 'maps.pirates.shop.covered' Public.Covered = require 'maps.pirates.shop.covered'
Public.Merchants = require 'maps.pirates.shop.merchants' Public.Merchants = require 'maps.pirates.shop.merchants'
Public.Minimarket = require 'maps.pirates.shop.dock' Public.Minimarket = require 'maps.pirates.shop.dock'

View File

@ -75,8 +75,6 @@ function Public.execute_boat_purchase()
-- memory.mainshop_availability_bools.new_boat_cutter_with_hold = false -- memory.mainshop_availability_bools.new_boat_cutter_with_hold = false
-- memory.mainshop_availability_bools.new_boat_sloop_with_hold = false -- memory.mainshop_availability_bools.new_boat_sloop_with_hold = false
-- memory.mainshop_availability_bools.new_boat_cutter = false -- memory.mainshop_availability_bools.new_boat_cutter = false
script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {})
end end
function Public.place_dock_jetty_and_boats() function Public.place_dock_jetty_and_boats()