mwg API
    Preparing search index...

    Class Stealth

    Tracks one hidden unit's detection state. Detection is one-way and sticky: once found, a unit stays found until something explicitly re-hides it (reset), the same way a real ambush does not un-happen because the enemy that spotted you wandered off again.

    import { Stealth } from '@datamoc/mw_games/roguelike';

    const assassin = new Stealth({ radius: 2 });
    const guards = [{ x: 10, y: 10 }, { x: 5, y: 5 }];

    if (assassin.checkDetection({ x: 4, y: 5 }, guards)) {
    console.log('spotted! that guard spends its move noticing');
    }
    console.log(assassin.isDetected);
    Index
    • Checks observers against hidden's position, and returns true only on the call that first brings one within range - the discoverer's move should be spent on that call, and that call alone, never on every later check while the unit stays in range. Already-detected units always return false here; read isDetected for their ongoing state instead.

      Parameters

      • hidden: Step
      • observers: readonly Step[]

      Returns boolean

    • hides the unit again - a smoke bomb, breaking line of sight for long enough, a new floor

      Returns void