Skip to content

Commit

Permalink
Tg Stock Market Console Port
Browse files Browse the repository at this point in the history
## About The Pull Request
Requested by Kirie. Ported from TG.
Some parts of the code were changed to make it more lorefriendly to the Project Moon universe.
The defined list of all the districts is so i dont have to post that long list over and over and over.
## Why It's Good For The Game
Hypothetically can be used by Representative for ahn generation.
## Changelog
:cl:
add: Lore defines file
add: stockexchange computer
/:cl:
  • Loading branch information
InsightfulParasite committed Dec 21, 2024
1 parent 4eca1db commit 92000ec
Show file tree
Hide file tree
Showing 9 changed files with 1,409 additions and 1 deletion.
4 changes: 4 additions & 0 deletions code/__DEFINES/~lobotomy_defines/lore_and_theme.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
* I needed a place to put this list of districts.
*/
#define LC_DISTRICT_LIST list("District 4", "District 5", "District 6", "District 7", "District 8", "District 9", "District 10", "District 11", "District 12", "District 13", "District 14", "District 15", "District 16", "District 17", "District 18", "District 19", "District 20", "District 21", "District 22", "District 23", "District 24")
126 changes: 126 additions & 0 deletions code/modules/stock_market/articles.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@

/proc/consonant()
return pick("B","C","D","F","G","H","J","K","L","M","N","P","Q","R","S","T","V","W","X","Y","Z")

/proc/vowel()
return pick("A", "E", "I", "O", "U")

/proc/ucfirst(S)
return "[uppertext(ascii2text(text2ascii(S, 1)))][copytext(S, 2)]"

/proc/ucfirsts(S)
var/list/L = splittext(S, " ")
var/list/M = list()
for (var/P in L)
M += ucfirst(P)
return jointext(M, " ")

GLOBAL_LIST_EMPTY(FrozenAccounts)

/proc/list_frozen()
for (var/A in GLOB.FrozenAccounts)
to_chat(usr, "[A]: [length(GLOB.FrozenAccounts[A])] borrows")

/datum/article
var/headline = "Something big is happening"
var/subtitle = "Investors panic as stock market collapses"
var/article = "God, it's going to be fun to randomly generate this."
var/author = "P. Pubbie"
var/spacetime = ""
var/opinion = 0
var/ticks = 0
var/datum/stock/about = null
var/outlet = ""
var/static/list/outlets = list()
var/static/list/default_tokens = list( \
"buy" = list("buy!", "buy, buy, buy!", "get in now!", "ride the share value to the stars!"), \
"company" = list("company", "conglomerate", "enterprise", "venture"), \
"complete" = list("complete", "total", "absolute", "incredible"), \
"country" = LC_DISTRICT_LIST, \
"development" = list("development", "unfolding of events", "turn of events", "new shit"), \
"dip" = list("dip", "fall", "plunge", "decrease"), \
"excited" = list("excited", "euphoric", "exhilarated", "thrilled", "stimulated"), \
"expand_influence" = list("expands their influence over", "continues to dominate", "gains traction in", "rolls their new product line out in"), \
"failure" = list("failure", "meltdown", "breakdown", "crash", "defeat", "wreck"), \
"famous" = list("famous", "prominent", "leading", "renowned", "expert"), \
"hit_shelves" = list("hit the shelves", "appeared on the market", "came out", "was released"), \
"industry" = list("industry", "sector"), \
"industrial" = list("industrial"), \
"jobs" = list("workers", "clerks"), \
"negative_outcome" = list("it's not leaving the shelves", "nobody seems to care", "it's a huge money sink", "they have already pulled all advertising and marketing support"), \
"neutral_outcome" = list("it's not lifting off as expected", "it's not selling according to expectations", "it's only generating enough profit to cover the marketing and manufacturing costs", "it does not look like it will become a massive success", "it's experiencing modest sales"), \
"positive_outcome" = list("it's already sold out", "it has already sold over one billion units", "suppliers cannot keep up with the wild demand", "several companies using this new technology are already reporting a projected increase in profits"), \
"resounding" = list("resounding", "tremendous", "total", "massive", "terrific", "colossal"), \
"rise" = list("rise", "increase", "fly off the positive side of the charts", "skyrocket", "lift off"), \
"sell" = list("sell!", "sell, sell, sell!", "bail!", "abandon ship!", "get out before it's too late!", "evacuate!", "withdraw!"), \
"signifying" = list("signifying", "indicating", "implying", "displaying", "suggesting"), \
"sneak_peek" = list("review", "sneak peek", "preview", "exclusive look"), \
"stock_market" = list("stock market", "stock exchange"), \
"stockholder" = list("stockholder", "shareholder"), \
"success" = list("success", "triumph", "victory"), \
"this_time" = list("this week", "last week", "this month", "yesterday", "today", "a few days ago") \
)

/datum/article/New()
..()
if ((outlets.len && !prob(100 / (outlets.len + 1))) || !outlets.len)
var/ON = generateOutletName()
if (!(ON in outlets))
outlets[ON] = list()
outlet = ON
else
outlet = pick(outlets)

var/list/authors = outlets[outlet]
if ((authors.len && !prob(100 / (authors.len + 1))) || !authors.len)
var/AN = generateAuthorName()
outlets[outlet] += AN
author = AN
else
author = pick(authors)

ticks = world.time

/datum/article/proc/generateOutletName()
var/list/locations = LC_DISTRICT_LIST
var/list/nouns = list("Post", "Herald", "Sun", "Tribune", "Mail", "Times", "Journal", "Report")
var/list/timely = list("Daily", "Hourly", "Weekly", "Biweekly", "Monthly", "Yearly")

switch(rand(1,2))
if (1)
return "The [pick(locations)] [pick(nouns)]"
if (2)
return "The [pick(timely)] [pick(nouns)]"

/datum/article/proc/generateAuthorName()
switch(rand(1,3))
if (1)
return "[consonant()]. [pick(GLOB.last_names)]"
if (2)
return "[prob(50) ? pick(GLOB.first_names_male) : pick(GLOB.first_names_female)] [consonant()].[prob(50) ? "[consonant()]. " : 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)]"

/datum/article/proc/formatSpacetime()
var/ticksc = round(ticks/100)
ticksc = ticksc % 100000
var/ticksp = "[ticksc]"
while (length(ticksp) < 5)
ticksp = "0[ticksp]"
spacetime = "[ticksp][time2text(world.realtime, "MM")][time2text(world.realtime, "DD")][text2num(time2text(world.realtime, "YYYY"))+540]"

/datum/article/proc/formatArticle()
if (spacetime == "")
formatSpacetime()
var/output = "<div class='article'><div class='headline'>[headline]</div><div class='subtitle'>[subtitle]</div><div class='article-body'>[article]</div><div class='author'>[author]</div><div class='timestamp'>[spacetime]</div></div>"
return output

/datum/article/proc/detokenize(token_string, list/industry_tokens, list/product_tokens = list())
var/list/T_list = default_tokens.Copy()
for (var/I in industry_tokens)
T_list[I] = industry_tokens[I]
for (var/I in product_tokens)
T_list[I] = list(product_tokens[I])
for (var/I in T_list)
token_string = replacetext(token_string, "%[I]%", pick(T_list[I]))
return ucfirst(token_string)
Loading

0 comments on commit 92000ec

Please sign in to comment.