Skip to content

company_static_util

Source: base/tealdef/game_mechanics/company/company_static_util.d.tl

Notes

Rank names and permit-key definitions (company_permit_key resources).

CompanyStaticUtil

record global base/tealdef/game_mechanics/company/company_static_util.d.tl:3

global record CompanyStaticUtil

Load: local company_static_util = ug_require "/game_mechanics/company/company_static_util.tl"

Notes

Rank names and permit-key definitions.

Functions

getRole(companyLevel : integer) : string base/tealdef/game_mechanics/company/company_static_util.d.tl:31

Call as company_static_util.getRole

Notes

Returns the name of a rank (1 "Junior" to 15 "Tycoon").

Parameter Type Description
companyLevel integer Rank.

Returns string: Rank name, or "Rank n" outside 1..15.

Used in the base game: 8 times in 6 files

base/content/gui/gui/game_bar/game_bar.tl:420

role = company_static_util.getRole(state:old().rank)
base/content/gui/gui/menu/savegame_react_util.tl:588
rows[#rows + 1] = makeLeftRightTextView(_("Company Rank"), company_static_util.getRole(companyMetadata.level))
base/content/game_mechanics/game_mechanics/company/company_react_util.tl:87
rank.role = company_static_util.getRole(i)
base/content/game_mechanics/game_mechanics/company/company_util.tl:176
return lang_util.format(_("Unlocked at Rank: {rank}"), {rank = company_static_util.getRole(minRank)})
base/content/game_mechanics/game_mechanics/company/company_notification_rank_up.script.tl:16
description = lang_util.format(_("Hard work and endurance are paying off. You got promoted to {role} and great rewards have been unlocked."), { role = company_s
base/content/game_mechanics/game_mechanics/celebrations/celebration_react_util.tl:56
role = company_static_util.getRole(value)

getPermitKeyName(permitKey : ResName) : string base/tealdef/game_mechanics/company/company_static_util.d.tl:34

Call as company_static_util.getPermitKeyName

get name of the permitKey (if nil is returned, use construction as key)

Returns string

getPermitKeyDesc(permitKey : ResName) : PermitKeyDesc base/tealdef/game_mechanics/company/company_static_util.d.tl:37

Call as company_static_util.getPermitKeyDesc

get permit key definition as stored in the resource

Returns PermitKeyDesc

Used in the base game: 3 times in 3 files

base/content/gui/gui/construction/construction_desc_react_util.tl:592

local keyDesc = company_static_util.getPermitKeyDesc(companyMeta.permitKey)
base/content/game_mechanics/game_mechanics/company/company_react_util.tl:62
local keyDesc = company_static_util.getPermitKeyDesc(actualPermitKey)
base/content/game_mechanics/game_mechanics/company/company_util.tl:101
local permitDesc = company_static_util.getPermitKeyDesc(permitKey)

getExtraPermitsAggregatedPerRank() : {string : {{integer, integer}}} base/tealdef/game_mechanics/company/company_static_util.d.tl:40

Call as company_static_util.getExtraPermitsAggregatedPerRank

note: this is cached and thus cheap (for each key, returns list of {level, total permits up to and including level}

Returns {string : {{integer, integer}}}

Used in the base game: 2 times in 1 file

base/content/game_mechanics/game_mechanics/company/company_progression_util.tl:57

return getNumberOfExtraPermits(company_static_util.getExtraPermitsAggregatedPerRank(), companyData, permitKey)

getMinRankConsideringPermits(companyMeta : CompanyMetadata.ConstructionDesc) : integer base/tealdef/game_mechanics/company/company_static_util.d.tl:42

Call as company_static_util.getMinRankConsideringPermits

Notes

Returns the rank at which a construction unlocks, from companyRank, the first rankAndPermits entry or its permit key.

Parameter Type Description
companyMeta CompanyMetadata.ConstructionDesc Company metadata of the construction.

Returns integer: Rank, or nil.

Used in the base game: 3 times in 2 files

base/content/gui/gui/construction/construction_react_util.tl:707

local rankA = company_static_util.getMinRankConsideringPermits(companyMetaA) or -1
base/content/game_mechanics/game_mechanics/company/company_util.tl:173
local minRank = company_static_util.getMinRankConsideringPermits(company)

getAllRanksConsideringPermits(companyMeta : CompanyMetadata.ConstructionDesc) : {integer} base/tealdef/game_mechanics/company/company_static_util.d.tl:44

Call as company_static_util.getAllRanksConsideringPermits

Notes

Returns all ranks at which a construction unlocks or gains permits.

Parameter Type Description
companyMeta CompanyMetadata.ConstructionDesc Company metadata of the construction.

Returns {integer}: Ranks, or nil.

Used in the base game: 1 time in 1 file

base/content/game_mechanics/game_mechanics/company/company_react_util.tl:18

local affectedRanks : {integer} = company_static_util.getAllRanksConsideringPermits(companyMeta)

CompanyStaticUtil.PerkDescription

record base/tealdef/game_mechanics/company/company_static_util.d.tl:5

record PerkDescription

Notes

A perk as listed under a rank in the company window.

Used in the base game: 7 times in 2 files

base/content/game_mechanics/game_mechanics/company/company.tl:44

local getGroupedPerks = function(perks : {CompanyStaticUtil.PerkDescription}) : {{integer}}
base/content/game_mechanics/game_mechanics/company/company_react_util.tl:32
local findInsertIndex = function(rank : CompanyStaticUtil.RankDescription, newPerk : CompanyStaticUtil.PerkDescription) : integer

Fields

Name Type Description
name string Name of the perk.
description string Description of the perk.
icon IconWithAvailability Icon of the perk.
permitKey ResName Permit key of the perk.
permits integer how often can it be built? (nil means unlimited)
isNewUnlock boolean The perk unlocks at this rank; false means it only gains permits here.
cooldownInSeconds number Cooldown of a used permit, in game seconds.
recycle boolean re-gain permits after bulldozing
category CompanyMetadata.ConstructionDesc.PerkCategory Kind of perk.
numbers ConstructionDescReactUtil.Numbers Figures shown in the description.

CompanyStaticUtil.RankDescription

record base/tealdef/game_mechanics/company/company_static_util.d.tl:18

record RankDescription

Notes

A rank in the company window.

Used in the base game: 15 times in 2 files

base/content/game_mechanics/game_mechanics/company/company.tl:19

staticCompanyData : {CompanyStaticUtil.RankDescription}
base/content/game_mechanics/game_mechanics/company/company_react_util.tl:10
local distributePerkToRanks = function(perk : ConstructionDefinition, ranks : {CompanyStaticUtil.RankDescription})

Fields

Name Type Description
level integer Rank number.
role string Rank name (e.g. "Junior", "CEO").
requiredExp integer Experience needed.
perks {PerkDescription} Perks unlocked or extended at this rank.

CompanyStaticUtil.PermitKeyDesc

record base/tealdef/game_mechanics/company/company_static_util.d.tl:25

record PermitKeyDesc

Notes

Data of a company_permit_key resource.

Used in the base game: 5 times in 1 file

base/content/game_mechanics/game_mechanics/company/company_static_util.tl:34

local function GetPermitKeysFromResources() : {string : CompanyStaticUtil.PermitKeyDesc}

Fields

Name Type Description
name string Display name.
rankAndPermits {{integer, integer}} List of {rank, permits} gained at each rank.
cooldownInSeconds number Game seconds after which a consumed permit is available again.