Function sortActions

  • Parameters

    Returns ActionModel[]

    Sorted actions

    Description

    Sort actions by order of execution (STAY -> DESTROY -> BUILD -> MOVE)

    Example

    const actions = [
    {
    craftsman_id: '1',
    action: 'BUILD',
    action_param: 'BELOW',
    },
    {
    craftsman_id: '2',
    action: 'MOVE',
    action_param: 'UPPER_RIGHT',
    },
    {
    craftsman_id: '3',
    action: 'STAY',
    },
    ];

    sortActions(actions);
    // [
    // {
    // craftsman_id: '3',
    // action: 'STAY',
    // },
    // {
    // craftsman_id: '1',
    // action: 'BUILD',
    // action_param: 'BELOW',
    // },
    // {
    // craftsman_id: '2',
    // action: 'MOVE',
    // action_param: 'UPPER_RIGHT',
    // },
    // ]

Generated using TypeDoc