feat: 로그를 변환하는 함수, 기술 변환하는 함수를 ts 이식
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
const regex = /<([RBGMCLSODYW]1?|1|\/)>/g;
|
||||
|
||||
//TODO: <R>에서 더 확장해서, <R|G>, <R|N> 형태로 뒤에 타입을 지정할 수 있도록 한다.
|
||||
|
||||
const convertMap: Record<string, string> = {
|
||||
"R": 'color: red;',
|
||||
"B": 'color: blue;',
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user