Refactor TypeScript files for improved readability and consistency
Gitea Auto Deploy / Deploy-Container (push) Successful in 3m21s
Gitea Auto Deploy / Deploy-Container (push) Successful in 3m21s
- Cleaned up imports and formatting in localeStore.ts and socketSettingStore.ts. - Standardized interface definitions and formatting in attack.ts, avatar.ts, battle.ts, enemy.ts, entity.ts, error.ts, index.ts, lineup.ts, mics.ts, skill.ts, srtools.ts, team.ts, turn.ts, version.ts, and waveAndCycle.ts. - Ensured consistent use of semicolons and spacing across all modified files. - Updated tsconfig.json for consistency in formatting.
This commit is contained in:
@@ -1,48 +1,48 @@
|
||||
import useBattleDataStore from "@/stores/battleDataStore";
|
||||
import { BattleDataStateJson } from "@/types/mics";
|
||||
|
||||
export const exportBattleData = (
|
||||
filename = 'battle_data.json'
|
||||
) => {
|
||||
const { lineup,
|
||||
turnHistory,
|
||||
skillHistory,
|
||||
totalAV,
|
||||
totalDamage,
|
||||
damagePerAV,
|
||||
cycleIndex,
|
||||
waveIndex,
|
||||
dataAvatar,
|
||||
maxWave,
|
||||
maxCycle,
|
||||
version,
|
||||
avatarDetail,
|
||||
enemyDetail
|
||||
} = useBattleDataStore.getState();
|
||||
|
||||
const data: BattleDataStateJson = {
|
||||
lineup,
|
||||
turnHistory,
|
||||
skillHistory,
|
||||
dataAvatar,
|
||||
totalAV,
|
||||
totalDamage,
|
||||
damagePerAV,
|
||||
cycleIndex,
|
||||
waveIndex,
|
||||
maxWave,
|
||||
maxCycle,
|
||||
version,
|
||||
avatarDetail,
|
||||
enemyDetail
|
||||
}
|
||||
|
||||
const dataStr = JSON.stringify(data, null, 2);
|
||||
const blob = new Blob([dataStr], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
import useBattleDataStore from "@/stores/battleDataStore";
|
||||
import { BattleDataStateJson } from "@/types/mics";
|
||||
|
||||
export const exportBattleData = (
|
||||
filename = 'battle_data.json'
|
||||
) => {
|
||||
const { lineup,
|
||||
turnHistory,
|
||||
skillHistory,
|
||||
totalAV,
|
||||
totalDamage,
|
||||
damagePerAV,
|
||||
cycleIndex,
|
||||
waveIndex,
|
||||
dataAvatar,
|
||||
maxWave,
|
||||
maxCycle,
|
||||
version,
|
||||
avatarDetail,
|
||||
enemyDetail
|
||||
} = useBattleDataStore.getState();
|
||||
|
||||
const data: BattleDataStateJson = {
|
||||
lineup,
|
||||
turnHistory,
|
||||
skillHistory,
|
||||
dataAvatar,
|
||||
totalAV,
|
||||
totalDamage,
|
||||
damagePerAV,
|
||||
cycleIndex,
|
||||
waveIndex,
|
||||
maxWave,
|
||||
maxCycle,
|
||||
version,
|
||||
avatarDetail,
|
||||
enemyDetail
|
||||
}
|
||||
|
||||
const dataStr = JSON.stringify(data, null, 2);
|
||||
const blob = new Blob([dataStr], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
+62
-62
@@ -1,63 +1,63 @@
|
||||
import { listCurrentLanguage } from "@/lib/constant";
|
||||
import { CharacterBasic, MonsterBasic } from "@/types";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
|
||||
type TFunc = ReturnType<typeof useTranslations>
|
||||
|
||||
function cleanText(text: string): string {
|
||||
if (!text) return ""
|
||||
return text.replace(/<unbreak>(.*?)<\/unbreak>/g, "$1")
|
||||
}
|
||||
|
||||
export function getNameChar(
|
||||
locale: string,
|
||||
t: TFunc,
|
||||
data: CharacterBasic | undefined
|
||||
): string {
|
||||
if (!data) return "";
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(listCurrentLanguage, locale)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const langKey = listCurrentLanguage[locale as keyof typeof listCurrentLanguage].toLowerCase();
|
||||
|
||||
let text = data.lang[langKey] ?? "";
|
||||
|
||||
if (!text) {
|
||||
text = data.lang["en"] ?? "";
|
||||
}
|
||||
|
||||
if (Number(data.id) > 8000) {
|
||||
text = `${t("trailblazer")} • ${t(data?.baseType?.toLowerCase() ?? "")}`;
|
||||
}
|
||||
|
||||
return cleanText(text);
|
||||
}
|
||||
|
||||
export function getNameEnemy(locale: string, data: MonsterBasic | undefined): string {
|
||||
if (!data) {
|
||||
return ""
|
||||
}
|
||||
if (!Object.prototype.hasOwnProperty.call(listCurrentLanguage, locale)) {
|
||||
return ""
|
||||
}
|
||||
|
||||
const langKey = listCurrentLanguage[locale as keyof typeof listCurrentLanguage].toLowerCase();
|
||||
|
||||
|
||||
let text = data.lang[langKey] ?? "";
|
||||
|
||||
if (!text) {
|
||||
text = data.lang["en"] ?? "";
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
export function parseRuby(text: string): string {
|
||||
const rubyRegex = /\{RUBY_B#(.*?)\}(.*?)\{RUBY_E#\}/gs;
|
||||
return text.replace(rubyRegex, (_match, furigana, kanji) => {
|
||||
return `<ruby>${kanji}<rt>${furigana}</rt></ruby>`;
|
||||
});
|
||||
import { listCurrentLanguage } from "@/lib/constant";
|
||||
import { CharacterBasic, MonsterBasic } from "@/types";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
|
||||
type TFunc = ReturnType<typeof useTranslations>
|
||||
|
||||
function cleanText(text: string): string {
|
||||
if (!text) return ""
|
||||
return text.replace(/<unbreak>(.*?)<\/unbreak>/g, "$1")
|
||||
}
|
||||
|
||||
export function getNameChar(
|
||||
locale: string,
|
||||
t: TFunc,
|
||||
data: CharacterBasic | undefined
|
||||
): string {
|
||||
if (!data) return "";
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(listCurrentLanguage, locale)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const langKey = listCurrentLanguage[locale as keyof typeof listCurrentLanguage].toLowerCase();
|
||||
|
||||
let text = data.lang[langKey] ?? "";
|
||||
|
||||
if (!text) {
|
||||
text = data.lang["en"] ?? "";
|
||||
}
|
||||
|
||||
if (Number(data.id) > 8000) {
|
||||
text = `${t("trailblazer")} • ${t(data?.baseType?.toLowerCase() ?? "")}`;
|
||||
}
|
||||
|
||||
return cleanText(text);
|
||||
}
|
||||
|
||||
export function getNameEnemy(locale: string, data: MonsterBasic | undefined): string {
|
||||
if (!data) {
|
||||
return ""
|
||||
}
|
||||
if (!Object.prototype.hasOwnProperty.call(listCurrentLanguage, locale)) {
|
||||
return ""
|
||||
}
|
||||
|
||||
const langKey = listCurrentLanguage[locale as keyof typeof listCurrentLanguage].toLowerCase();
|
||||
|
||||
|
||||
let text = data.lang[langKey] ?? "";
|
||||
|
||||
if (!text) {
|
||||
text = data.lang["en"] ?? "";
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
export function parseRuby(text: string): string {
|
||||
const rubyRegex = /\{RUBY_B#(.*?)\}(.*?)\{RUBY_E#\}/gs;
|
||||
return text.replace(rubyRegex, (_match, furigana, kanji) => {
|
||||
return `<ruby>${kanji}<rt>${furigana}</rt></ruby>`;
|
||||
});
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
import { BattleDataStateJson } from "@/types/mics";
|
||||
|
||||
export const importBattleData = (file: File, loadBattleDataFromJSON: (data: BattleDataStateJson) => void) => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
try {
|
||||
const result = reader.result as string;
|
||||
const parsed = JSON.parse(result) as BattleDataStateJson;
|
||||
loadBattleDataFromJSON(parsed);
|
||||
resolve();
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
};
|
||||
reader.onerror = () => reject(reader.error);
|
||||
reader.readAsText(file);
|
||||
});
|
||||
};
|
||||
|
||||
import { BattleDataStateJson } from "@/types/mics";
|
||||
|
||||
export const importBattleData = (file: File, loadBattleDataFromJSON: (data: BattleDataStateJson) => void) => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
try {
|
||||
const result = reader.result as string;
|
||||
const parsed = JSON.parse(result) as BattleDataStateJson;
|
||||
loadBattleDataFromJSON(parsed);
|
||||
resolve();
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
};
|
||||
reader.onerror = () => reject(reader.error);
|
||||
reader.readAsText(file);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
export * from "./getNameChar"
|
||||
export * from "./exportDataBattle"
|
||||
export * from "./getNameChar"
|
||||
export * from "./exportDataBattle"
|
||||
export * from "./importDataBattle"
|
||||
Reference in New Issue
Block a user