Skip to content

Commit

Permalink
add npc sprite validation
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Aug 15, 2024
1 parent b106e43 commit bf8528f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/helpers/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
checkMapNPCDialogs,
checkMapProperties,
checkMapSpawners,
checkNPCSprites,
checkNPCUsages,
checkQuests,
checkRecipes,
Expand All @@ -20,6 +21,7 @@ export function validationMessagesForMod(
checkItemUses(mod),
checkMapNPCDialogs(mod),
checkNPCUsages(mod),
checkNPCSprites(mod),
checkRecipes(mod),
checkSpawners(mod),
checkQuests(mod),
Expand Down
27 changes: 27 additions & 0 deletions src/app/helpers/validators/npc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,30 @@ export function checkNPCUsages(mod: IModKit) {

return npcValidations;
}

export function checkNPCSprites(mod: IModKit) {
const npcValidations: ValidationMessageGroup = {
header: `NPCs`,
messages: [],
};

mod.npcs.forEach((item) => {
item.sprite.forEach((sprite) => {
if (sprite % 5 === 0) return;

npcValidations.messages.push({
type: 'error',
message: `NPC ${item.npcId} has an invalid sprite: ${sprite} - it should be modulo 5.`,
});
});
});

if (npcValidations.messages.length === 0) {
npcValidations.messages.push({
type: 'good',
message: 'No abnormalities!',
});
}

return npcValidations;
}

0 comments on commit bf8528f

Please sign in to comment.