Skip to content

Commit

Permalink
codebook optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
realforest2001 committed Sep 11, 2023
1 parent bb17b58 commit 6a56aec
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions code/modules/cm_marines/codebook.dm
Original file line number Diff line number Diff line change
@@ -1,24 +1,56 @@
GLOBAL_LIST_EMPTY(codebook_data)

/obj/item/book/codebook
name = "Almayer Code Book"
unique = 1
dat = ""
/obj/item/book/codebook/proc/create_codebook(faction = FACTION_MARINE)
if(!GLOB.codebook_data[faction])
GLOB.codebook_data[faction] = generate_code()

/obj/item/book/codebook/Initialize()
. = ..()
dat = GLOB.codebook_data[faction]

/obj/item/book/codebook/proc/generate_code()
var/number
var/letter
dat = "<table><tr><th>Call</th><th>Response<th></tr>"
var/code_data = "<table><tr><th>Call</th><th>Response<th></tr>"
for(var/i in 1 to 10)
letter = pick(greek_letters)
number = rand(100,999)
dat += "<tr><td>[letter]-[number]</td>"
code_data += "<tr><td>[letter]-[number]</td>"
letter = pick(greek_letters)
number = rand(100,999)
dat += "<td>[letter]-[number]</td></tr>"
code_data += "<td>[letter]-[number]</td></tr>"
code_data += "</table>"
return code_data

/obj/item/book/codebook
name = "USS Almayer Code Book"
author = "United States Colonial Marines"
unique = 1
dat = ""
var/faction = FACTION_MARINE

/obj/item/book/codebook/Initialize()
. = ..()
title = name
create_codebook(faction)

/obj/item/book/codebook/clf
name = "Liberation Front Authenticators"
faction = FACTION_CLF
author = "\[Obscured Ink\]"

/obj/item/book/codebook/twe
name = "Imperial Authentication Codes"
faction = FACTION_TWE
author = "Royal Marines"

dat += "</table>"
/obj/item/book/codebook/upp
name = "Union Authentication Codes"
faction = FACTION_UPP
author = "People's Army"

/obj/item/book/codebook/wey_yu
name = "Corporate Authentication Codes"
faction = FACTION_WY
author = "Weyland-Yutani Communications Division"

/obj/item/book/codebook/attackby(obj/item/W, mob/living/user)
if(istype(W, /obj/item/tool/kitchen/knife) || HAS_TRAIT(W, TRAIT_TOOL_WIRECUTTERS))
Expand Down

0 comments on commit 6a56aec

Please sign in to comment.