Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Fixes to the Galactic Material Market regarding market quantity. #647

Merged
merged 1 commit into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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])))
Loading