내무부, 금/쌀수입, 감찰부 구현
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
export type DiplomacyState = 0 | 1 | 2 | 7;
|
||||
|
||||
export type DiplomacyInfo = {
|
||||
name: string;
|
||||
color?: string;
|
||||
};
|
||||
|
||||
export const diplomacyStateInfo: Record<DiplomacyState, DiplomacyInfo> = {
|
||||
0: { name: '교전', color: 'red' },
|
||||
1: { name: '선포중', color: 'magenta' },
|
||||
2: { name: '통상' },
|
||||
7: { name: '불가침', color: 'green' },
|
||||
};
|
||||
|
||||
export const resolveDiplomacyInfo = (state: number): DiplomacyInfo => {
|
||||
return diplomacyStateInfo[state as DiplomacyState] ?? { name: '알 수 없음' };
|
||||
};
|
||||
@@ -0,0 +1,58 @@
|
||||
const logRegex = /<([RBGMCLSODYW]1?|1|\/)>/g;
|
||||
|
||||
const convertMap: Record<string, string> = {
|
||||
R: 'color: red;',
|
||||
B: 'color: blue;',
|
||||
G: 'color: green;',
|
||||
M: 'color: magenta;',
|
||||
C: 'color: cyan;',
|
||||
L: 'color: limegreen;',
|
||||
S: 'color: skyblue;',
|
||||
O: 'color: orangered;',
|
||||
D: 'color: orangered;',
|
||||
Y: 'color: yellow;',
|
||||
W: 'color: white;',
|
||||
1: 'font-size: 0.9em;',
|
||||
};
|
||||
|
||||
const convertMap2: Record<string, string> = {
|
||||
1: 'font-size: 0.9em;',
|
||||
};
|
||||
|
||||
export const formatLog = (text?: string): string => {
|
||||
if (!text) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let match: RegExpExecArray | null = null;
|
||||
let lastIndex = 0;
|
||||
const result: string[] = [];
|
||||
|
||||
while ((match = logRegex.exec(text)) !== null) {
|
||||
const partAll = match[0];
|
||||
const subPart = match[1];
|
||||
const index = match.index;
|
||||
|
||||
if (lastIndex !== index) {
|
||||
result.push(text.slice(lastIndex, index));
|
||||
}
|
||||
|
||||
if (subPart === '/') {
|
||||
result.push('</span>');
|
||||
} else if (subPart.length === 2) {
|
||||
result.push(
|
||||
`<span style="${convertMap[subPart[0]] ?? ''}${convertMap2[subPart[1]] ?? ''}">`
|
||||
);
|
||||
} else {
|
||||
result.push(`<span style="${convertMap[subPart] ?? ''}">`);
|
||||
}
|
||||
|
||||
lastIndex = index + partAll.length;
|
||||
}
|
||||
|
||||
if (lastIndex !== text.length) {
|
||||
result.push(text.slice(lastIndex));
|
||||
}
|
||||
|
||||
return result.join('');
|
||||
};
|
||||
Reference in New Issue
Block a user