fix image generation when part position is omitted

This commit is contained in:
skeletor 2022-03-18 05:01:25 +00:00 committed by Bill
parent 4d3a13e2bd
commit b682448c95

View File

@ -168,7 +168,7 @@ export class BadgeImageManager implements IDisposable
private loadGroupBadge(badgeCode: string): void
{
const groupBadge = new GroupBadge(badgeCode);
const partMatches = [...badgeCode.matchAll(/[b|s][0-9]{5,6}/g)];
const partMatches = [...badgeCode.matchAll(/[b|s][0-9]{4,6}/g)];
for(const partMatch of partMatches)
{
@ -177,7 +177,7 @@ export class BadgeImageManager implements IDisposable
const partType = partCode[0];
const partId = parseInt(partCode.slice(1, shortMethod ? 3 : 4));
const partColor = parseInt(partCode.slice(shortMethod ? 3 : 4, shortMethod ? 5 : 6));
const partPosition = parseInt(partCode.slice(shortMethod ? 5 : 6, shortMethod ? 6 : 7));
const partPosition = partCode.length < 6 ? 0 : parseInt(partCode.slice(shortMethod ? 5 : 6, shortMethod ? 6 : 7)); // sometimes position is ommitted
const part = new GroupBadgePart(partType, partId, partColor, partPosition);
groupBadge.parts.push(part);