5180 fichiers 38.5 Mo 0 téléchargements 234 vues mis à jour il y a 5 heures ui
nitro-v36-with-renderer-v36 / src / api / snowwar / SnowWarHud.test.ts
SnowWarHud.test.ts 1.6 Ko Télécharger le fichier
import { describe, expect, it } from 'vitest';
import { getCountdownFrame, getExplosionAssetName, getLoopFrame, getPingPongFrame, getScoreFlashFrame, SNOWWAR_EXPLOSION_OFFSETS } from './SnowWarHud';

describe('SnowWarHud (AIR SnowWarUI timings)', () =>
{
    it('flashes the score frames 1-4 at 50 ms, then hides', () =>
    {
        expect([ 0, 49, 50, 120, 199, 200, -1 ].map(getScoreFlashFrame)).toEqual([ 1, 1, 2, 3, 4, 0, 0 ]);
    });

    it('ping-pongs the empty-ammo flash 1,2,3,4,3,2', () =>
    {
        expect([ 0, 75, 150, 225, 300, 375, 450 ].map(now => getPingPongFrame(now, 4, 75))).toEqual([ 1, 2, 3, 4, 3, 2, 1 ]);
        expect(getPingPongFrame(500, 1, 75)).toBe(1);
    });

    it('loops the snowball loading icon', () =>
    {
        expect([ 0, 100, 700, 800 ].map(now => getLoopFrame(now, 8))).toEqual([ 1, 2, 8, 1 ]);
    });

    it('counts 5..1 in the last five preparing seconds, then bursts', () =>
    {
        const end = 100_000;

        expect(getCountdownFrame(end - 9_000, end)).toBe(0);
        expect(getCountdownFrame(end - 5_000, end)).toBe(1);
        expect(getCountdownFrame(end - 4_001, end)).toBe(1);
        expect(getCountdownFrame(end - 1, end)).toBe(5);
        expect(getCountdownFrame(end, end)).toBe(6);
        expect(getCountdownFrame(end + 450, end)).toBe(10);
        expect(getCountdownFrame(end + 500, end)).toBe(0);
        expect(getCountdownFrame(end, 0)).toBe(0);
    });

    it('names and offsets the explosion frames', () =>
    {
        expect(getExplosionAssetName(7)).toBe('explosion0007');
        expect(Object.keys(SNOWWAR_EXPLOSION_OFFSETS)).toHaveLength(10);
    });
});
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser