Description

Craftsmen position

Implements

ICraftsmenPosition

Hierarchy

Implements

Constructors

Properties

id: string

Description

Craftsmen Id

side: EWallSide

Description

Craftsmen side

x: number

Description

X position

y: number

Description

Y position

Methods

  • Parameters

    • pos: Position

      Position to calculate distance

    • formular: "mahata" | "euclid" = 'mahata'

      Formular to calculate distance (mahata, euclid)

    Returns number

    Distance between two positions

    Description

    Get distance between two positions

    Example

    const pos1 = new Position(1, 1);
    const pos2 = new Position(1, 2);
    const distance = pos1.distance(pos2);
    console.log(distance); // | 1 - 1 | + | 2 - 1 | = 1

    Example

    const pos1 = new Position(1, 1);
    const pos2 = new Position(1, 2);
    const distance = pos1.distance(pos2, 'euclid');
    console.log(distance); // sqrt((1 - 1) ^ 2 + (2 - 1) ^ 2) = 1
  • Parameters

    Returns boolean

    Whether the position is near

    Description

    Check if the position is near

    Example

    const pos1 = new Position(1, 1);
    const pos2 = new Position(1, 2);
    const isNear = pos1.isNear(pos2)
    console.log(isNear) // true

    Example

    const pos1 = new Position(1, 1);
    const pos2 = new Position(1, 3);
    const isNear = pos1.isNear(pos2)
    console.log(isNear) // false
  • Parameters

    • width: number

      The width of the map

    • height: number

      The height of the map

    Returns boolean

    Whether the position is valid

    Description

    Check if the position is valid

    Example

    const pos = new Position(1, 1);
    const isValid = pos.isValid(10, 10);
    console.log(isValid); // true

    Example

    const pos = new Position(-1, 1);
    const isValid = pos.isValid(10, 10);
    console.log(isValid); // false

Generated using TypeDoc