Skip to content

Commit

Permalink
frusteration and difficulty
Browse files Browse the repository at this point in the history
  • Loading branch information
InsightfulParasite committed Jan 1, 2025
1 parent e721291 commit c4a7c9e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
14 changes: 12 additions & 2 deletions code/modules/stock_market/computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,24 @@ a.updated {
src.add_fingerprint(usr)
src.updateUsrDialog()

/obj/machinery/computer/stockexchange/attackby(obj/I, mob/user, params)
if(istype(I, /obj/item/holochip))
var/obj/item/holochip/H = I
var/ahn_amount = H.get_item_credit_value()
H.spend(ahn_amount)
AdjustMonies(ahn_amount)
return
else
return ..()

/obj/machinery/computer/stockexchange/proc/sell_some_shares(datum/stock/S, mob/user)
if (!user || !S)
return
var/li = logged_in
if (!li)
to_chat(user, span_danger("No active account on the console!"))
return
var/b = SSshuttle.points
var/b = credits
var/avail = S.shareholders[logged_in]
if (!avail)
to_chat(user, span_danger("This account does not own any shares of [S.name]!"))
Expand All @@ -270,7 +280,7 @@ a.updated {
return
if (li != logged_in)
return
b = SSshuttle.points
b = credits
if (!isnum(b))
to_chat(user, span_danger("No active account on the console!"))
return
Expand Down
3 changes: 0 additions & 3 deletions code/modules/stock_market/events.dm
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@
current_title = "[company.name]: Complete crash"
current_desc = "The company had gone bankrupt, was not bailed out and could not recover. No further stock trade will take place. All shares in the company are effectively worthless."
company.bankrupt = 1
for (var/X in company.shareholders)
var/amt = company.shareholders[X]
SSstockmarket.balanceLog(X, -amt * company.current_value)
company.shareholders = list()
company.current_value = 0
company.borrow_brokers = list()
Expand Down
31 changes: 15 additions & 16 deletions code/modules/stock_market/stocks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,43 +172,42 @@
current_value *= 2
last_unification = world.time

/datum/stock/proc/modifyAccount(whose, by, force=0)
if (SSshuttle.points)
if (by < 0 && SSshuttle.points + by < 0 && !force)
/datum/stock/proc/modifyAccount(obj/machinery/computer/stockexchange/stonker, by, force=0)
if (stonker.credits)
if (by < 0 && stonker.credits + by < 0 && !force)
return 0
SSshuttle.points += by
SSstockmarket.balanceLog(whose, by)
stonker.credits += by
return 1
return 0

/datum/stock/proc/buyShares(who, howmany)
/datum/stock/proc/buyShares(obj/machinery/computer/stockexchange/stonker, howmany)
if (howmany <= 0)
return
howmany = round(howmany)
var/loss = howmany * current_value
if (available_shares < howmany)
return 0
if (modifyAccount(who, -loss))
if (modifyAccount(stonker, -loss))
supplyDrop(howmany)
if (!(who in shareholders))
shareholders[who] = howmany
if (!(stonker in shareholders))
shareholders[stonker] = howmany
else
shareholders[who] += howmany
shareholders[stonker] += howmany
return 1
return 0

/datum/stock/proc/sellShares(whose, howmany)
/datum/stock/proc/sellShares(obj/machinery/computer/stockexchange/stonker, howmany)
if (howmany < 0)
return
howmany = round(howmany)
var/gain = howmany * current_value
if (shareholders[whose] < howmany)
if (shareholders[stonker] < howmany)
return 0
if (modifyAccount(whose, gain))
if (modifyAccount(stonker, gain))
supplyGrowth(howmany)
shareholders[whose] -= howmany
if (shareholders[whose] <= 0)
shareholders -= whose
shareholders[stonker] -= howmany
if (shareholders[stonker] <= 0)
shareholders -= stonker
return 1
return 0

Expand Down

0 comments on commit c4a7c9e

Please sign in to comment.