All files / libs/roguelike-engine/src/screens win.ts

100% Statements 30/30
100% Branches 4/4
100% Functions 3/3
100% Lines 30/30

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 311x 1x 1x 1x 1x 1x 6x 6x 1x 1x 1x 1x 1x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 1x 1x 1x 1x 2x 2x 1x  
import { random } from "@jga/algorithms";
 
import { Color, Screen, type DisplayInterface, type World } from "@jga/games";
 
export class WinScreen extends Screen {
    public constructor(engine: World, display: DisplayInterface) {
        super("Win", engine, display);
    }
 
    public render(): void {
        // Render our prompt to the screen
        // eslint-disable-next-line no-loops/no-loops
        for (let i = 0; i < 22; i++) {
            // Generate random background colors
            const r = random(0, 255);
            const g = random(0, 255);
            const b = random(0, 255);
 
            const color = new Color(r, g, b);
 
            const background = color.toRGB();
            this.display.drawText({ x: 2, y: i + 1 }, `%b{${background}}You win!`);
        }
    }
 
    // eslint-disable-next-line class-methods-use-this
    public handleInput(): string | null {
        return null;
    }
}