|
1 | 1 | import { expect, test } from "vitest"; |
2 | 2 | import { neutralInput, type Input } from "@cs2go/protocol"; |
3 | | -import { configurePlayer, createMatch, createPlayer, joinMatch, STEP, stepMatch } from "./match"; |
| 3 | +import { |
| 4 | + configurePlayer, |
| 5 | + createMatch, |
| 6 | + createPlayer, |
| 7 | + joinMatch, |
| 8 | + STEP, |
| 9 | + stepMatch, |
| 10 | + respawn, |
| 11 | +} from "./match"; |
4 | 12 | import { testMap } from "./test-map"; |
5 | 13 | import { dust2BuyZones } from "./buy-zones"; |
6 | 14 | import { weapons } from "./physics"; |
@@ -369,3 +377,26 @@ test("airborne unducking cannot extend feet through the floor, and shallow overl |
369 | 377 | expect(ct.y).toBeCloseTo(0, 6); |
370 | 378 | expect(ct.grounded).toBe(true); |
371 | 379 | }); |
| 380 | + |
| 381 | +test("surviving captured weapons refill every magazine next round without changing identity", () => { |
| 382 | + const { match, ct } = fixture(); |
| 383 | + arm(ct, 30, 0); |
| 384 | + const captured = { |
| 385 | + serial: 987, |
| 386 | + creator: "t", |
| 387 | + weapon: 30, |
| 388 | + skin: { id: "", wear: 0, seed: 1 }, |
| 389 | + }; |
| 390 | + ct.appearances[30] = captured; |
| 391 | + ct.reserve = 0; |
| 392 | + ct.magazines[30] = { ammo: 0, reserve: 0 }; |
| 393 | + ct.magazines[ct.secondary] = { ammo: 0, reserve: 0 }; |
| 394 | + respawn(ct, match, true); |
| 395 | + expect(ct.ammo).toBe(weapons[30].mag); |
| 396 | + expect(ct.reserve).toBe(weapons[30].reserve); |
| 397 | + expect(ct.magazines[ct.secondary]).toEqual({ |
| 398 | + ammo: weapons[ct.secondary].mag, |
| 399 | + reserve: weapons[ct.secondary].reserve, |
| 400 | + }); |
| 401 | + expect(ct.appearances[30]).toBe(captured); |
| 402 | +}); |
0 commit comments