Guard battle UI icon frame readability
This commit is contained in:
@@ -7,6 +7,8 @@ const server = await createServer({
|
||||
appType: 'custom'
|
||||
});
|
||||
|
||||
const minimumReadableIconFrameSize = 96;
|
||||
|
||||
try {
|
||||
const { battleUiIconManifest } = await server.ssrLoadModule('/src/game/data/battleUiIcons.ts');
|
||||
const { itemCatalog, equipmentSlots } = await server.ssrLoadModule('/src/game/data/battleItems.ts');
|
||||
@@ -38,6 +40,18 @@ function validateBattleUiIconAtlas(errors, manifest) {
|
||||
assertNonEmptyString(errors, manifest.textureKey, 'battleUiIconManifest.textureKey');
|
||||
assertPositiveInteger(errors, manifest.frameWidth, 'battleUiIconManifest.frameWidth');
|
||||
assertPositiveInteger(errors, manifest.frameHeight, 'battleUiIconManifest.frameHeight');
|
||||
assertIntegerAtLeast(
|
||||
errors,
|
||||
manifest.frameWidth,
|
||||
minimumReadableIconFrameSize,
|
||||
'battleUiIconManifest.frameWidth for desktop readability'
|
||||
);
|
||||
assertIntegerAtLeast(
|
||||
errors,
|
||||
manifest.frameHeight,
|
||||
minimumReadableIconFrameSize,
|
||||
'battleUiIconManifest.frameHeight for desktop readability'
|
||||
);
|
||||
assertPositiveInteger(errors, manifest.columns, 'battleUiIconManifest.columns');
|
||||
assertPositiveInteger(errors, manifest.rows, 'battleUiIconManifest.rows');
|
||||
|
||||
@@ -144,6 +158,12 @@ function assertPositiveInteger(errors, value, context) {
|
||||
}
|
||||
}
|
||||
|
||||
function assertIntegerAtLeast(errors, value, minimum, context) {
|
||||
if (!Number.isInteger(value) || value < minimum) {
|
||||
errors.push(`${context} must be at least ${minimum}`);
|
||||
}
|
||||
}
|
||||
|
||||
function assertNonEmptyString(errors, value, context) {
|
||||
if (typeof value !== 'string' || value.trim().length === 0) {
|
||||
errors.push(`${context} must be a non-empty string`);
|
||||
|
||||
Reference in New Issue
Block a user