Skip to content

Commit

Permalink
[MIRROR] Fixes to the Galactic Material Market regarding market quant…
Browse files Browse the repository at this point in the history
…ity. [MDB IGNORE] (#647)

* Fixes to the Galactic Material Market regarding market quantity. (#79307)

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: ArcaneMusic <[email protected]>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@ users.noreply.github.com>
  • Loading branch information
4 people authored Nov 18, 2023
1 parent 31547de commit 041cf5d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
9 changes: 5 additions & 4 deletions code/controllers/subsystem/stock_market.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ SUBSYSTEM_DEF(stock_market)
price_minimum = round(initial(mat.minimum_value_override) * SHEET_MATERIAL_AMOUNT)
var/price_maximum = round(initial(mat.value_per_unit) * SHEET_MATERIAL_AMOUNT * 3)
var/price_baseline = initial(mat.value_per_unit) * SHEET_MATERIAL_AMOUNT
var/quantity_baseline = initial(mat.tradable_base_quantity)

var/stock_quantity = materials_quantity[mat]

Expand Down Expand Up @@ -84,15 +85,15 @@ SUBSYSTEM_DEF(stock_market)
switch(trend)
if(MARKET_TREND_UPWARD)
price_change = ROUND_UP(gaussian(price_units * 0.1, price_baseline * 0.05)) //If we don't ceil, small numbers will get trapped at low values
quantity_change = -round(gaussian(stock_quantity * 0.1, stock_quantity * 0.05))
quantity_change = -round(gaussian(quantity_baseline * 0.05, quantity_baseline * 0.05))
if(MARKET_TREND_STABLE)
price_change = round(gaussian(0, price_baseline * 0.01))
quantity_change = round(gaussian(0, stock_quantity * 0.01))
quantity_change = round(gaussian(0, quantity_baseline * 0.01))
if(MARKET_TREND_DOWNWARD)
price_change = -ROUND_UP(gaussian(price_units * 0.1, price_baseline * 0.05))
quantity_change = round(gaussian(stock_quantity * 0.1, stock_quantity * 0.05))
quantity_change = round(gaussian(quantity_baseline * 0.05, quantity_baseline * 0.05))
materials_prices[mat] = round(clamp(price_units + price_change, price_minimum, price_maximum))
materials_quantity[mat] = round(clamp(stock_quantity + quantity_change, 0, initial(mat.tradable_base_quantity) * 2))
materials_quantity[mat] = round(clamp(stock_quantity + quantity_change, 0, quantity_baseline * 2))

/**
* Market events are a way to spice up the market and make it more interesting.
Expand Down
13 changes: 13 additions & 0 deletions code/modules/cargo/packs/_packs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,16 @@
name = "[purchaser]'s Materials Order"
src.cost = cost
src.contains = contains

/datum/supply_pack/custom/minerals/fill(obj/structure/closet/crate/C)
. = ..()
//Remove our material sheets from SSstock_market's materials_quantity equal to the quantity within the crate.
for(var/obj/item/stack/sheet/possible_stack as anything in contains)
if(!ispath(possible_stack, /obj/item/stack/sheet))
continue
if(!possible_stack.material_type)
continue
if(!SSstock_market.materials_quantity[possible_stack.material_type])
continue
SSstock_market.materials_quantity[possible_stack.material_type] -= contains[possible_stack]
SSstock_market.materials_prices[possible_stack.material_type] += round((SSstock_market.materials_prices[possible_stack.material_type]) * (contains[possible_stack] / (SSstock_market.materials_quantity[possible_stack.material_type] - contains[possible_stack])))

0 comments on commit 041cf5d

Please sign in to comment.