Skip to content

Commit 37234df

Browse files
committed
fix: include paintKit in gen code for sticker slab keychains
1 parent 9f79ba4 commit 37234df

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/GenCode.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ private static function serializeStickerPairs(array $stickers, ?int $padTo): arr
5959
foreach ($filtered as $s) {
6060
$result[] = (string) $s->stickerId;
6161
$result[] = self::formatFloat($s->wear ?? 0.0);
62+
if ($s->paintKit !== null) {
63+
$result[] = (string) $s->paintKit;
64+
}
6265
}
6366
}
6467

tests/GenCodeTest.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,57 @@ public function testRoundtripWithKeychain(): void
309309
$this->assertSame(36, $parsed->keychains[0]->stickerId);
310310
}
311311

312+
// -----------------------------------------------------------------------
313+
// toGenCode — keychain paintKit
314+
// -----------------------------------------------------------------------
315+
316+
public function testToGenCodeKeychainWithPaintKitAppendsPaintKit(): void
317+
{
318+
$item = new ItemPreviewData(
319+
defindex: 1355,
320+
paintindex: 0,
321+
paintseed: 0,
322+
paintwear: 0.0,
323+
keychains: [new Sticker(slot: 0, stickerId: 37, wear: 0.0, paintKit: 929)],
324+
);
325+
$code = GenCode::toGenCode($item, '');
326+
$tokens = explode(' ', $code);
327+
// last three tokens should be: 37 0 929
328+
$this->assertSame('37', $tokens[count($tokens) - 3]);
329+
$this->assertSame('0', $tokens[count($tokens) - 2]);
330+
$this->assertSame('929', $tokens[count($tokens) - 1]);
331+
}
332+
333+
public function testToGenCodeKeychainWithoutPaintKitNoExtraToken(): void
334+
{
335+
$item = new ItemPreviewData(
336+
defindex: 7,
337+
paintindex: 0,
338+
paintseed: 0,
339+
paintwear: 0.0,
340+
keychains: [new Sticker(slot: 0, stickerId: 36, wear: 0.0)],
341+
);
342+
$code = GenCode::toGenCode($item, '');
343+
$tokens = explode(' ', $code);
344+
// last two tokens should be: 36 0
345+
$this->assertSame('36', $tokens[count($tokens) - 2]);
346+
$this->assertSame('0', $tokens[count($tokens) - 1]);
347+
}
348+
349+
// -----------------------------------------------------------------------
350+
// genCodeFromLink — sticker slab
351+
// -----------------------------------------------------------------------
352+
353+
public function testGenCodeFromLinkSlabUrlEndsWithPaintKit(): void
354+
{
355+
$slabUrl = 'steam://run/730//+csgo_econ_action_preview%20819181994A8BA181A982B189E981F181238086898191A4E1208698F309C9';
356+
$code = GenCode::genCodeFromLink($slabUrl, '');
357+
$tokens = explode(' ', $code);
358+
$this->assertSame('37', $tokens[count($tokens) - 3]);
359+
$this->assertSame('0', $tokens[count($tokens) - 2]);
360+
$this->assertSame('929', $tokens[count($tokens) - 1]);
361+
}
362+
312363
// -----------------------------------------------------------------------
313364
// genCodeFromLink
314365
// -----------------------------------------------------------------------

0 commit comments

Comments
 (0)