Skip to content

Commit

Permalink
small edits to fix up things and remove brokers.
Browse files Browse the repository at this point in the history
  • Loading branch information
InsightfulParasite committed Dec 22, 2024
1 parent 4d068f7 commit c51d1f3
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 175 deletions.
19 changes: 1 addition & 18 deletions code/controllers/subsystem/economy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ SUBSYSTEM_DEF(economy)
var/list/balances = list()
var/list/last_read = list()
var/list/stock_brokers = list()
var/list/logs
var/list/frozen_accounts = list()


/datum/controller/subsystem/economy/Initialize(timeofday)
var/budget_to_hand_out = round(budget_pool / department_accounts.len)
Expand Down Expand Up @@ -128,10 +125,6 @@ SUBSYSTEM_DEF(economy)
return inflation_value

//STOCK MARKET PROCS
/datum/controller/subsystem/economy/proc/list_frozen()
for(var/A in frozen_accounts)
to_chat(usr, "[A]: [length(frozen_accounts[A])] borrows")

/datum/controller/subsystem/economy/proc/balanceLog(whose, net)
if (!(whose in balances))
balances[whose] = net
Expand Down Expand Up @@ -190,7 +183,7 @@ SUBSYSTEM_DEF(economy)
switch (rand(1,6))
if(1)
if(sname == "" || sname == "FAG") // honestly it's a 0.6% chance per round this happens - or once in 166 rounds - so i'm accounting for it before someone yells at me
sname = "[CONSONANTS][VOWELS][CONSONANTS]"
sname = "[pick(CONSONANTS)][pick(VOWELS)]E"
if (2)
sname = "[pick(tech_prefix)][pick(tech_short)][prob(20) ? " " + pick(company) : null]"
if (3 to 4)
Expand Down Expand Up @@ -226,13 +219,3 @@ SUBSYSTEM_DEF(economy)
S.generateEvents()
stocks += S
last_read[S] = list()

/datum/controller/subsystem/economy/proc/add_log(log_type, user, company_name, stocks, shareprice, money)
var/datum/stock_log/L = new log_type
L.user_name = user
L.company_name = company_name
L.stocks = stocks
L.shareprice = shareprice
L.money = money
L.time = time2text(world.timeofday, "hh:mm")
logs += L
4 changes: 2 additions & 2 deletions code/modules/stock_market/articles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
/datum/article/proc/generateAuthorName()
switch(rand(1,3))
if (1)
return "[CONSONANTS]. [pick(GLOB.last_names)]"
return "[pick(CONSONANTS)]. [pick(GLOB.last_names)]"
if (2)
return "[prob(50) ? pick(GLOB.first_names_male) : pick(GLOB.first_names_female)] [CONSONANTS].[prob(50) ? "[CONSONANTS]. " : null] [pick(GLOB.last_names)]"
return "[prob(50) ? pick(GLOB.first_names_male) : pick(GLOB.first_names_female)] [pick(CONSONANTS)].[prob(50) ? "[pick(CONSONANTS)]. " : null] [pick(GLOB.last_names)]"
if (3)
return "[prob(50) ? pick(GLOB.first_names_male) : pick(GLOB.first_names_female)] \"[prob(50) ? pick(GLOB.first_names_male) : pick(GLOB.first_names_female)]\" [pick(GLOB.last_names)]"

Expand Down
33 changes: 10 additions & 23 deletions code/modules/stock_market/computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
interaction_flags_atom = INTERACT_ATOM_REQUIRES_DEXTERITY | INTERACT_ATOM_UI_INTERACT | INTERACT_ATOM_ATTACK_HAND | INTERACT_ATOM_REQUIRES_ANCHORED

light_color = LIGHT_COLOR_GREEN
var/list/logs = list()

/obj/machinery/computer/stockexchange/Initialize()
. = ..()
Expand Down Expand Up @@ -193,8 +194,9 @@ a.updated {
if (!S.sellShares(logged_in, amt))
to_chat(user, "<span class='danger'>Could not complete transaction.</span>")
return
to_chat(user, "<span class='notice'>Sold [amt] shares of [S.name] at [S.current_value] a share for [total] ahn.</span>")
SSeconomy.add_log(/datum/stock_log/sell, user.name, S.name, amt, S.current_value, total)
var/feedback = "<span class='notice'>Sold [amt] shares of [S.name] at [S.current_value] a share for [total] ahn.</span>"
to_chat(user, feedback)
logs += feedback

/obj/machinery/computer/stockexchange/proc/buy_some_shares(datum/stock/S, mob/user)
if (!user || !S)
Expand Down Expand Up @@ -228,15 +230,9 @@ a.updated {
return

var/total = amt * S.current_value
to_chat(user, "<span class='notice'>Bought [amt] shares of [S.name] at [S.current_value] a share for [total] ahn.</span>")
SSeconomy.add_log(/datum/stock_log/buy, user.name, S.name, amt, S.current_value, total)

/obj/machinery/computer/stockexchange/proc/do_borrowing_deal(datum/borrow/B, mob/user)
if (B.stock.borrow(B, logged_in))
to_chat(user, "<span class='notice'>You successfully borrowed [B.share_amount] shares. Deposit: [B.deposit].</span>")
SSeconomy.add_log(/datum/stock_log/borrow, user.name, B.stock.name, B.share_amount, B.deposit)
else
to_chat(user, "<span class='danger'>Could not complete transaction. Check your account balance.</span>")
var/feedback = "<span class='notice'>Bought [amt] shares of [S.name] at [S.current_value] a share for [total] ahn.</span>"
to_chat(user, feedback)
logs += feedback

/obj/machinery/computer/stockexchange/Topic(href, href_list)
if (..())
Expand Down Expand Up @@ -265,17 +261,8 @@ a.updated {

if (href_list["show_logs"])
var/dat = "<html><head><title>Stock Transaction Logs</title></head><body><h2>Stock Transaction Logs</h2><div><a href='?src=[REF(src)];show_logs=1'>Refresh</a></div><br>"
for(var/D in SSeconomy.logs)
var/datum/stock_log/L = D
if(istype(L, /datum/stock_log/buy))
dat += "[L.time] | <b>[L.user_name]</b> bought <b>[L.stocks]</b> stocks at [L.shareprice] a share for <b>[L.money]</b> total ahn in <b>[L.company_name]</b>.<br>"
continue
if(istype(L, /datum/stock_log/sell))
dat += "[L.time] | <b>[L.user_name]</b> sold <b>[L.stocks]</b> stocks at [L.shareprice] a share for <b>[L.money]</b> total ahn from <b>[L.company_name]</b>.<br>"
continue
if(istype(L, /datum/stock_log/borrow))
dat += "[L.time] | <b>[L.user_name]</b> borrowed <b>[L.stocks]</b> stocks with a deposit of <b>[L.money]</b> ahn in <b>[L.company_name]</b>.<br>"
continue
for(var/D in logs)
dat += "[D]<br>"
var/datum/browser/popup = new(usr, "stock_logs", "Stock Transaction Logs", 600, 400)
popup.set_content(dat)
popup.open()
Expand Down Expand Up @@ -308,7 +295,7 @@ a.updated {
popup.open()

if (href_list["cycleview"])
if(vmode = TRUE)
if(vmode == TRUE)
vmode = 0
else
vmode = 1
Expand Down
23 changes: 16 additions & 7 deletions code/modules/stock_market/events.dm
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@

/datum/stockEvent/bankruptcy/proc/generateBankruptcyArticle()
var/datum/article/A = new
var/list/bankrupt_reason = list("investor pessimism", "failure of product lines", "economic recession", "overblown inflation", "overblown deflation", "collapsed pyramid schemes", "a Ponzi scheme", "economic terrorism", "extreme hedonism", "unfavourable economic climate", "rampant government corruption", "divine conspiracy", "some total bullshit", "volatile plans")
var/list/bankrupt_reason = list("investor pessimism", "failure of product lines", "economic recession", "overblown inflation", "overblown deflation",
"collapsed pyramid schemes", "a Ponzi scheme", "economic terrorism", "extreme hedonism", "unfavourable economic climate", "rampant government corruption",
"divine conspiracy", "some total bullshit", "volatile plans"
)
A.about = company
A.headline = pick( "[company.name] filing for bankruptcy", \
"[company.name] unable to pay, investors run", \
Expand All @@ -129,7 +132,8 @@
A.subtitle = "Investors panic, bailout pending"
if (prob(15))
A.opinion = rand(-1, 1)
var/article = "Another one might bite the dust: [company.current_trend > 0 ? "despite their positive trend" : "in line with their failing model"], [company.name] files for bankruptcy citing [pick(bankrupt_reason)]. The director of District [rand(4,24)] has been asked to bail the company out, "
var/article = "Another one might bite the dust: [company.current_trend > 0 ? "despite their positive trend" : "in line with their failing model"], [company.name] \
files for bankruptcy citing [pick(bankrupt_reason)]. The director of District [rand(4,24)] has been asked to bail the company out, "
if (!A.opinion)
article += "but no answer has been given by the administration to date. Our tip to stay safe is: %sell%"
else if (A.opinion > 0)
Expand All @@ -156,17 +160,20 @@
current_desc = ""
female = prob(50)
if (prob(50))
position = "C[prob(20) ? VOWELS : CONSONANTS]O"
position = "C[prob(20) ? pick(VOWELS) : pick(CONSONANTS)]O"
else
position = ucfirsts(company.industry.detokenize("Lead %industrial% Engineer"))
offenses = ""
var/list/O = list("corruption", "murder", "grand theft", "assault", "battery", "drug possession", "burglary", "theft", "grand sabotage", "bribery",
"disorderly conduct", "treason", "sedition", "shoplifting", "tax evasion", "tax fraud", "insurance fraud", "perjury", "kidnapping", "manslaughter", "vandalism", "forgery", "extortion", "embezzlement",
"public indecency", "public intoxication", "trespassing", "loitering", "littering", "vigilantism", "squatting", "panhandling", "arson", "spacepodjacking", "shuttlejacking", "carjacking", "singularityjacking",
"dereliction of duty", "spacecraft piracy", "music piracy", "tabletop game piracy", "software piracy", "escaping from space prison", "seniornapping", "clownnapping", "corginapping", "catnapping",
"dereliction of duty", "spacecraft piracy", "music piracy", "tabletop game piracy", "software piracy", "seniornapping", "clownnapping", "corginapping", "catnapping",
"sleeping on the job", "terrorism", "counterterrorism", "drug distribution", "insubordination", "jaywalking", "owning a computer", "owning a cellphone", "owning a PDA", "owning a pAI", "adultery",
"committing an unnatural act with another person", "corrupting public morals", "skateboarding without a license", "shitcurity", "erotic roleplay", "accidentally strangling a prostitute")
if(prob(60) && O.len > 2)
"committing an unnatural act with another person", "corrupting public morals", "skateboarding without a license", "shitcurity", "erotic roleplay", "accidentally strangling a prostitute",
"gnome conspiracy", "Artificial Intelligence Ethics Amendment violation", "cloning", "full restoration necromancy", "owning a gun that can damage property",
"smuggling of sentient non-humans into the city", "erasure of a VIP", "imperfect erasure of a crime from reality", "deicide", "being an ass",
"conspiracy", "lycanthropy", "distortion cultivation", "cognitohazard breach", "soul stealing", "prosthetic ownership", "district taboo violation")
if(prob(60))
var/offense = pick(O)
O -= offense
offense = "[prob(20) ? "attempted " : (prob(20) ? "being accessory to " : null)][offense][prob(5) ? " of the [pick("first", "second", "third", "fourth", "fifth", "sixth")] degree" : null]"
Expand Down Expand Up @@ -217,7 +224,9 @@
A.subtitle = "[A.author] reporting directly from the courtroom"
if (prob(15))
A.opinion = rand(-1, 1)
var/article = "[pick("Security", "Law enforcement")] forces issued a statement that [tname], the [position] of [company.name], the %famous% %industrial% %company% was arrested %this_time%. The trial has been scheduled and the statement reports that the arrested individual is being charged with [offenses]. "
var/article = "[pick("Security", "Law enforcement")] forces issued a statement that [tname], the [position] of [company.name], \
the %famous% %industrial% %company% was arrested %this_time%. The trial has been scheduled and the statement reports that \
the arrested individual is being charged with [offenses]. "
if (!A.opinion)
article += "While we cannot predict the outcome of this trial, our tip to stay safe is: %sell%"
else if (A.opinion > 0)
Expand Down
7 changes: 4 additions & 3 deletions code/modules/stock_market/industries.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
/datum/industry/agriculture/generateProductName(company_name)
var/list/products = list("water tank", "cattle prod", "scythe", "plough", "sickle", "cultivator", "loy", "spade", "hoe", "daisy grubber", "cotton gin")
var/list/prefix = list("[company_name]'s ", "the [company_name] ", "the fully automatic ", "the full-duplex ", "the semi-automatic ", "the drone-mounted ", "the industry-leading ", "the world-class ")
var/list/suffix = list(" of farming", " multiplex", " +[rand(1,15)]", " [CONSONANTS][rand(1000, 9999)]", " hybrid", " maximus", " extreme")
var/list/suffix = list(" of farming", " multiplex", " +[rand(1,15)]", " [pick(CONSONANTS)][rand(1000, 9999)]", " hybrid", " maximus", " extreme")
return "[pick(prefix)][pick(products)][pick(suffix)]"


Expand Down Expand Up @@ -166,7 +166,8 @@
/datum/industry/it/generateProductName(company_name)
var/list/products = list("generator", "laptop", "keyboard", "memory card", "display", "operating system", "processor", "graphics card", "nanobots", "power supply", "pAI", "mech", "capacitor", "cell")
var/list/prefix = list("the [company_name] ", "the high performance ", "the mobile ", "the portable ", "the professional ", "the extreme ", "the incredible ", "the blazing fast ", "the bleeding edge ", "the bluespace-powered ", null)
var/L = pick(CONSONANTS, "Seed ", "Radiant ", "Robust ", "Pentathon ", "Athlete ", "Phantom ", "Semper Fi ")
var/list/l_list = CONSONANTS + list("Seed ", "Radiant ", "Robust ", "Pentathon ", "Athlete ", "Phantom ", "Semper Fi ")
var/L = l_list
var/N = rand(1, 99)
var/prefix2 = "[L][N][prob(5) ? " " + latin_number(N) : null]"
return "[pick(prefix)][prefix2] [pick(products)]"
Expand All @@ -182,7 +183,7 @@
/datum/industry/communications/generateProductName(company_name)
var/list/products = list("mobile phone", "PDA", "tablet computer", "newscaster", "social network")
var/list/prefix = list("the [company_name] ", "the high performance ", "the mobile ", "the portable ", "the professional ", "the extreme ", "the incredible ", "the blazing fast ", "the bleeding edge ", null)
var/L = pick("[lowertext(CONSONANTS)]Phone ", "Universe ", "Xperience ", "Next ", "Engin Y ", "Cyborg ", "[CONSONANTS]")
var/L = pick("Phone ", "Universe ", "Xperience ", "Next ", "Engin Y ", "Cyborg ")
var/N = rand(1,99)
var/prefix2 = "[L][N][prob(25) ? pick(" Tiny", " Mini", " Micro", " Slim", " Water", " Air", " Fire", " Earth", " Nano", " Pico", " Femto", " Planck") : null]"
return "[pick(prefix)][prefix2] [pick(products)]"
Expand Down
18 changes: 0 additions & 18 deletions code/modules/stock_market/logs.dm

This file was deleted.

114 changes: 11 additions & 103 deletions code/modules/stock_market/stocks.dm
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
/datum/borrow
var/broker = ""
var/borrower = ""
var/datum/stock/stock = null
var/lease_expires = 0
var/lease_time = 0
var/grace_time = 0
var/grace_expires = 0
var/share_amount = 0
var/share_debt = 0
var/deposit = 0
var/offer_expires = 0

/datum/stock
var/name = "Stock"
var/short_name = "STK"
Expand Down Expand Up @@ -46,6 +33,17 @@
var/fluctuation_counter = 0
var/datum/industry/industry = null

/datum/stock/process()
if (bankrupt)
return
fluctuation_counter++
if (fluctuation_counter >= fluctuation_rate)
for (var/E in events)
var/datum/stockEvent/EV = E
EV.process()
fluctuation_counter = 0
fluctuate()

/datum/stock/proc/addEvent(datum/stockEvent/E)
events |= E

Expand Down Expand Up @@ -169,76 +167,11 @@
shareholders[I] /= 2
if (!shareholders[I])
shareholders -= I
for (var/datum/borrow/B in borrow_brokers)
B.share_amount = round(B.share_amount / 2)
B.share_debt = round(B.share_debt / 2)
for (var/datum/borrow/B in borrows)
B.share_amount = round(B.share_amount / 2)
B.share_debt = round(B.share_debt / 2)
average_shares /= 2
available_shares /= 2
current_value *= 2
last_unification = world.time

/datum/stock/process()
for (var/B in borrows)
var/datum/borrow/borrow = B
if (world.time > borrow.grace_expires)
modifyAccount(borrow.borrower, -max(current_value * borrow.share_debt, 0), 1)
borrows -= borrow
if (borrow.borrower in SSeconomy.frozen_accounts)
SSeconomy.frozen_accounts[borrow.borrower] -= borrow
if (length(SSeconomy.frozen_accounts[borrow.borrower]) == 0)
SSeconomy.frozen_accounts -= borrow.borrower
qdel(borrow)
else if (world.time > borrow.lease_expires)
if (borrow.borrower in shareholders)
var/amt = shareholders[borrow.borrower]
if (amt > borrow.share_debt)
shareholders[borrow.borrower] -= borrow.share_debt
borrows -= borrow
if (borrow.borrower in SSeconomy.frozen_accounts)
SSeconomy.frozen_accounts[borrow.borrower] -= borrow
if (length(SSeconomy.frozen_accounts[borrow.borrower]) == 0)
SSeconomy.frozen_accounts -= borrow.borrower
qdel(borrow)
else
shareholders -= borrow.borrower
borrow.share_debt -= amt
if (bankrupt)
return
for (var/B in borrow_brokers)
var/datum/borrow/borrow = B
if (borrow.offer_expires < world.time)
borrow_brokers -= borrow
qdel(borrow)
if (prob(5))
generateBrokers()
fluctuation_counter++
if (fluctuation_counter >= fluctuation_rate)
for (var/E in events)
var/datum/stockEvent/EV = E
EV.process()
fluctuation_counter = 0
fluctuate()

/datum/stock/proc/generateBrokers()
if (borrow_brokers.len > 2)
return
if (!SSeconomy.stock_brokers.len)
SSeconomy.generateBrokers()
var/broker = pick(SSeconomy.stock_brokers)
var/datum/borrow/B = new
B.broker = broker
B.stock = src
B.lease_time = rand(4, 7) * 600
B.grace_time = rand(1, 3) * 600
B.share_amount = rand(1, 10) * 100
B.deposit = rand(20, 70) / 100
B.share_debt = B.share_amount
B.offer_expires = rand(5, 10) * 600 + world.time
borrow_brokers += B

/datum/stock/proc/modifyAccount(whose, by, force=0)
if (SSshuttle.points)
if (by < 0 && SSshuttle.points + by < 0 && !force)
Expand All @@ -248,31 +181,6 @@
return 1
return 0

/datum/stock/proc/borrow(datum/borrow/B, who)
if (B.lease_expires)
return 0
B.lease_expires = world.time + B.lease_time
var/old_d = B.deposit
var/d_amt = B.deposit * current_value * B.share_amount
if (!modifyAccount(who, -d_amt))
B.lease_expires = 0
B.deposit = old_d
return 0
B.deposit = d_amt
if (!(who in shareholders))
shareholders[who] = B.share_amount
else
shareholders[who] += B.share_amount
borrow_brokers -= B
borrows += B
B.borrower = who
B.grace_expires = B.lease_expires + B.grace_time
if (!(who in SSeconomy.frozen_accounts))
SSeconomy.frozen_accounts[who] = list(B)
else
SSeconomy.frozen_accounts[who] += B
return 1

/datum/stock/proc/buyShares(who, howmany)
if (howmany <= 0)
return
Expand Down
1 change: 0 additions & 1 deletion lobotomy-corp13.dme
Original file line number Diff line number Diff line change
Expand Up @@ -3707,7 +3707,6 @@
#include "code\modules\stock_market\computer.dm"
#include "code\modules\stock_market\events.dm"
#include "code\modules\stock_market\industries.dm"
#include "code\modules\stock_market\logs.dm"
#include "code\modules\stock_market\stocks.dm"
#include "code\modules\suppressions\_core_suppression.dm"
#include "code\modules\suppressions\command.dm"
Expand Down

0 comments on commit c51d1f3

Please sign in to comment.