{"size": 676, "ext": "js", "max_stars_repo_path": "app/src/systems/pawnFacingTurningWhenMove.js", "max_stars_repo_name": "linonetwo/electron-react-game-dev-playground", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/src/systems/pawnFacingTurningWhenMove.js", "max_issues_repo_name": "linonetwo/electron-react-game-dev-playground", "max_issues_repo_issues_event_min_datetime": "2020-02-06T06:06:37.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-06T06:06:37.000Z", "max_forks_repo_path": "app/src/systems/pawnFacingTurningWhenMove.js", "max_forks_repo_name": "linonetwo/electron-react-game-dev-playground", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 28.1666666667, "max_line_length": 88, "alphanum_fraction": 0.5917159763}
// @flow
/* eslint-disable no-param-reassign */
import type { PawnProps } from 'components/pawn';
import type { SystemInput } from 'systems/typing';

export default function pawnFacingTurningWhenMove({ entities, keysDown }: SystemInput) {
  entities
    .filter(e => e['@type'] === 'protagonistPawn')
    .forEach((pawn: PawnProps) => {
      if (keysDown.includes('ArrowLeft')) {
        pawn.facing = 'west';
      }
      if (keysDown.includes('ArrowRight')) {
        pawn.facing = 'east';
      }
      if (keysDown.includes('ArrowUp')) {
        pawn.facing = 'north';
      }
      if (keysDown.includes('ArrowDown')) {
        pawn.facing = 'south';
      }
    });
}
