Skip to content

Commit

Permalink
Round BBS adverts to closest sensible price
Browse files Browse the repository at this point in the history
  • Loading branch information
impaktor authored and Web-eWorks committed Dec 22, 2020
1 parent b08ca7e commit 3034803
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion data/modules/Assassination/Assassination.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ local makeAdvert = function (station)
local due = Game.time + dist / max_ass_dist * time * 22*60*60*24 + Engine.rand:Number(7*60*60*24, 31*60*60*24)
local danger = Engine.rand:Integer(1,4)
local reward = Engine.rand:Number(2100, 7000) * danger
reward = math.ceil(reward)
reward = utils.round(reward, 500)

-- XXX hull mass is a bad way to determine suitability for role
--local shipdefs = utils.build_array(utils.filter(function (k,def) return def.tag == 'SHIP' and def.hullMass >= (danger * 17) and def.equipSlotCapacity.ATMOSHIELD > 0 end, pairs(ShipDef)))
Expand Down
3 changes: 2 additions & 1 deletion data/modules/BreakdownServicing/BreakdownServicing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local Format = require 'Format'
local Serializer = require 'Serializer'
local Equipment = require 'Equipment'
local Character = require 'Character'
local utils = require 'utils'

local l = Lang.GetResource("module-breakdownservicing")
local lui = Lang.GetResource("ui-core")
Expand Down Expand Up @@ -107,7 +108,7 @@ local onChat = function (form, ref, option)
})[hyperdrive.l10n_key] or 10)) or 0

-- Now make it bigger (-:
price = price * 10
price = utils.round(price * 10, 5)

-- Replace those tokens into ad's intro text that can change during play
local pricesuggestion = string.interp(ad.price, {
Expand Down
2 changes: 1 addition & 1 deletion data/modules/CargoRun/CargoRun.lua
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ local makeAdvert = function (station)
due = due + Game.time
end
end
reward = math.ceil(reward)
reward = utils.round(reward, 25)

local n = getNumberOfFlavours("INTROTEXT_" .. missiontype)
local introtext
Expand Down
1 change: 1 addition & 0 deletions data/modules/Combat/Combat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ local makeAdvert = function (station)
location = flavour.planets[Engine.rand:Integer(1, #flavour.planets)]
dist = location:DistanceTo(Game.system)
reward = math.ceil(dist * typical_reward * (1 + dedication)^2 * (1 + risk) * (1 + urgency) * Engine.rand:Number(0.8, 1.2))
reward = utils.round(reward, 100)
due = Game.time + typical_travel_time * Engine.rand:Number(0.9, 1.1) + dist * typical_hyperspace_time * (1.5 - urgency) * Engine.rand:Number(0.9, 1.1)

if Engine.rand:Number(1) > 0.5 then
Expand Down
3 changes: 3 additions & 0 deletions data/modules/CrewContracts/CrewContracts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local Game = require 'Game'
local Character = require 'Character'
local Format = require 'Format'
local Timer = require 'Timer'
local utils = require 'utils'

-- This module allows the player to hire crew members through BB adverts
-- on stations, and handles periodic events such as their wages.
Expand Down Expand Up @@ -180,6 +181,7 @@ local onChat = function (form,ref,option)
+c.sensors
-- Base wage on experience
c.estimatedWage = c.estimatedWage or wageFromScore(c.experience)
c.estimatedWage = utils.round(c.estimatedWage, 1)
end

-- Now look for any persistent characters that are available in this station
Expand All @@ -205,6 +207,7 @@ local onChat = function (form,ref,option)
-- Either base wage on experience, or as a slight increase on their previous wage
-- (which should only happen if this candidate was dismissed with wages owing)
c.estimatedWage = math.max(c.contract and (c.contract.wage + 5) or 0, c.estimatedWage or wageFromScore(c.experience))
c.estimatedWage = utils.round(c.estimatedWage, 1)
end

form:ClearFace()
Expand Down
2 changes: 1 addition & 1 deletion data/modules/DeliverPackage/DeliverPackage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ local makeAdvert = function (station, manualFlavour, nearbystations)
reward = ((dist / max_delivery_dist) * typical_reward * (1+risk) * (1.5+urgency) * Engine.rand:Number(0.8,1.2))
due = Game.time + ((dist / max_delivery_dist) * typical_travel_time * (1.5-urgency) * Engine.rand:Number(0.9,1.1))
end
reward = math.ceil(reward)
reward = utils.round(reward, 5)

local ad = {
station = station,
Expand Down
1 change: 1 addition & 0 deletions data/modules/SearchRescue/SearchRescue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,7 @@ local makeAdvert = function (station, manualFlavour, closestplanets)

-- calculate the reward
local reward = calcReward(flavour, pickup_crew, pickup_pass, pickup_comm, deliver_crew, deliver_pass, deliver_comm)
reward = utils.round(reward, 100)

local ad = {
location = location,
Expand Down
3 changes: 2 additions & 1 deletion data/modules/SecondHand/SecondHand.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local Format = require 'Format'
local Serializer = require 'Serializer'
local Equipment = require 'Equipment'
local Character = require 'Character'
local utils = require 'utils'

local l = Lang.GetResource("module-secondhand")
local l2 = Lang.GetResource("ui-core")
Expand Down Expand Up @@ -135,7 +136,7 @@ local makeAdvert = function (station)
-- buy back price in equipment market is 0.8, so make sure the value is higher
local reduction = Engine.rand:Number(0.8,0.9)

local price = math.ceil(station:GetEquipmentPrice(equipment) * reduction)
local price = utils.round(station:GetEquipmentPrice(equipment) * reduction, 2)

local ad = {
character = character,
Expand Down
2 changes: 1 addition & 1 deletion data/modules/Taxi/Taxi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ local makeAdvert = function (station)
location = nearbysystems[Engine.rand:Integer(1,#nearbysystems)]
local dist = location:DistanceTo(Game.system)
reward = ((dist / max_taxi_dist) * typical_reward * (group / 2) * (1+risk) * (1+3*urgency) * Engine.rand:Number(0.8,1.2))
reward = math.ceil(reward)
reward = utils.round(reward, 50)
due = Game.time + ((dist / max_taxi_dist) * typical_travel_time * (1.5-urgency) * Engine.rand:Number(0.9,1.1))

local ad = {
Expand Down

0 comments on commit 3034803

Please sign in to comment.