E.W.O. Next / All files / src/client/Game/Infos Position.tsx

100% Statements 15/15
100% Branches 4/4
100% Functions 2/2
100% Lines 14/14

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 31 32 33 34 35 36 37 38 39            1x   1x 1x 1x           1x   13x 5x       8x 5x 5x 5x   3x     10x       1x      
/**
 * @module Client.Game.Infos
 * Position module
 */
 
import { IStateFrontend } from '@client/reducers';
import { getSelectedCharacter } from '@client/selector';
import { CharacterFrontend, Plan } from '@models';
import * as React from 'react';
import { connect } from 'react-redux';
import { Plans } from '@engine/resources';
 
export interface PositionProps {
  character: CharacterFrontend;
}
 
export const PositionComponent = (props: PositionProps) => {
 
  if (props.character === undefined) {
    return null;
  }
 
 
  if (props.character.coord) {
    const { plan, x, y } = props.character.coord;
    const planObj: Plan = Plans[plan];
    return <div className="Infos__Position">Sur <a href="gps">{planObj.name}</a> en X = {x} <b>| </b>Y = {y}</div>;
  }
  return <div className="Infos__Position">Nullepart</div>;
};
 
const mapStateToProps = (state: IStateFrontend) => ({
  character: getSelectedCharacter(state),
});
 
export const Position = connect(
  mapStateToProps,
)(PositionComponent);