Skip to content

Commit 453a35f

Browse files
committed
skins march
1 parent 32a02fe commit 453a35f

File tree

1 file changed

+25
-40
lines changed

1 file changed

+25
-40
lines changed

src/utils/skinSprites.ts

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,56 +14,41 @@ interface SkinId {
1414
Idx: number;
1515
}
1616

17-
/**
18-
* Maps a skin to a set-based visual group to ensure consistent ordering.
19-
*/
20-
export const getSkinGroupOrder = (idx: number): number => {
21-
switch (idx) {
22-
case 0: return 0; // Santa
23-
case 2: return 1; // Snowman
24-
case 1: return 2; // Ski
25-
case 100:
26-
case 101: return 3; // Unnamed Row 1
27-
case 5: return 4; // Druid
28-
case 3: return 5; // Leprechaun
29-
case 4: return 6; // Flower
30-
case 102:
31-
case 103: return 7; // Unnamed Row 2
32-
default: return 100 + idx;
33-
}
34-
};
35-
3617
/**
3718
* Returns the sort value for a skin based on the 8x8 sprite sheet layout.
3819
*/
3920
export const getSkinSortValue = (skin: { SkinId: SkinId }): number => {
4021
const { Type, Idx } = skin.SkinId;
41-
const group = getSkinGroupOrder(Idx);
42-
43-
// Type priority: Helmet(0) -> Armour(1) -> Weapon(2)
44-
const typePriority = Type === 'Helmet' ? 0 : (Type === 'Armour' ? 1 : 2);
4522

46-
// Row 3 logic: Weapons always come after Row 1/2
47-
if (typePriority === 2) {
48-
// Weapons start at index 16 (start of Row 3)
49-
// Group 4 (Druid) weapon -> 16
50-
// Group 5 (Leprechaun) weapon -> 17
51-
// Group 6 (Flower) weapon -> 18
52-
return 16 + (group - 4);
23+
// Row 3 logic: Weapons always come after Row 1/2 (starts at index 16)
24+
if (Type === 'Weapon') {
25+
switch (Idx) {
26+
case 5: return 16; // Druid Weapon
27+
case 3: return 17; // Leprechaun Weapon
28+
case 4: return 18; // Flower Weapon
29+
default: return 64 - Idx; // Fallback to end of sheet
30+
}
5331
}
5432

55-
// Row 1/2 logic: Pairs of (H,A) or single H
33+
// Rows 1/2 logic: Pairs of (H,A) or single H
5634
// Indices 0-15
57-
// group 0 (Santa): 0,1
58-
// group 1 (Snowman): 2,3
59-
// group 2 (Ski): 4,5
60-
// group 3 (Unnamed): 6,7
61-
// group 4 (Druid): 8,9
62-
// group 5 (Leprechaun): 10,11
63-
// group 6 (Flower): 12,13
64-
// group 7 (Unnamed): 14,15
35+
let baseIndex = 0;
36+
switch (Idx) {
37+
case 0: baseIndex = 0; break; // Santa (0, 1)
38+
case 2: baseIndex = 2; break; // Snowman (2, 3)
39+
case 1: baseIndex = 4; break; // Ski (4, 5)
40+
case 100: return 6; // Unnamed 100 (Row 1, Col 6)
41+
case 101: return 7; // Unnamed 101 (Row 1, Col 7)
42+
case 5: baseIndex = 8; break; // Druid (8, 9)
43+
case 3: baseIndex = 10; break; // Leprechaun (10, 11)
44+
case 4: baseIndex = 12; break; // Flower (12, 13)
45+
case 102: return 14; // Unnamed 102 (Row 2, Col 6)
46+
case 103: return 15; // Unnamed 103 (Row 2, Col 7)
47+
default: baseIndex = 32 + Idx * 2;
48+
}
6549

66-
return group * 2 + typePriority;
50+
const typeOffset = Type === 'Helmet' ? 0 : 1;
51+
return baseIndex + typeOffset;
6752
};
6853

6954
/**

0 commit comments

Comments
 (0)