diff --git a/hwe/ts/utilGame/formatLog.ts b/hwe/ts/utilGame/formatLog.ts index 8491aead..3646b933 100644 --- a/hwe/ts/utilGame/formatLog.ts +++ b/hwe/ts/utilGame/formatLog.ts @@ -1,5 +1,7 @@ const regex = /<([RBGMCLSODYW]1?|1|\/)>/g; +//TODO: 에서 더 확장해서, , 형태로 뒤에 타입을 지정할 수 있도록 한다. + const convertMap: Record = { "R": 'color: red;', "B": 'color: blue;', diff --git a/hwe/ts/utilGame/techLevel.ts b/hwe/ts/utilGame/techLevel.ts new file mode 100644 index 00000000..95b58444 --- /dev/null +++ b/hwe/ts/utilGame/techLevel.ts @@ -0,0 +1,22 @@ + +import { clamp } from "lodash"; + +export const TECH_LEVEL_YEAR_GAP = 5; +export const TECH_LEVEL_STEP = 1000; + +export function isTechLimited(startYear: number, year: number, tech: number, maxTechLevel: number): boolean { + const relMaxTech = getMaxRelativeTechLevel(startYear, year, maxTechLevel); + const techLevel = convTechLevel(tech, maxTechLevel); + + return techLevel >= relMaxTech; +} + +export function convTechLevel(tech: number, maxTechLevel: number): number{ + return clamp(Math.floor(tech / TECH_LEVEL_STEP), 0, maxTechLevel); +} + + +export function getMaxRelativeTechLevel(startYear: number, year: number, maxTechLevel: number): number { + const relYear = year - startYear; + return clamp(Math.floor(relYear / TECH_LEVEL_YEAR_GAP) + 1, 1, maxTechLevel); +} \ No newline at end of file