Skip to content

Commit

Permalink
Merge 377ff0c into bdf3bbc
Browse files Browse the repository at this point in the history
  • Loading branch information
toystars committed Feb 24, 2020
2 parents bdf3bbc + 377ff0c commit 8d06503
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
13 changes: 13 additions & 0 deletions jest.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./tsconfig.json",
"lib": [
"dom",
"es2017",
"node"
],
"compilerOptions": {
"jsx": "react",
"module": "commonjs",
"target": "ES2019"
}
}
5 changes: 5 additions & 0 deletions jestconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"transform": {
"^.+\\.(t|j)sx?$": "ts-jest"
},
"globals": {
"ts-jest": {
"tsConfig": "jest.tsconfig.json"
}
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
Expand Down
1 change: 1 addition & 0 deletions src/sim/classes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './player.class';
5 changes: 5 additions & 0 deletions src/sim/classes/player.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

import { IMatchDayPlayer } from '../../types';

/** @internal */
export class CPlayer {
// matchday player data
data: IMatchDayPlayer;

constructor(playerData: IMatchDayPlayer) {
this.data = playerData;
}

// main method that decides player's next action
takeAction() {

Expand Down
1 change: 1 addition & 0 deletions src/sim/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './classes';
8 changes: 4 additions & 4 deletions src/utils/validators/player-validators.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function validatePlayerAttributes(player: IMatchDayPlayer): boolean {
// check player playing position
if (player.playingPosition.position === 'GK') {
// validate Goalkeeping attributes
const goalKeeping = get(player, 'attributes.goalKeeping');
const goalKeeping = player.attributes?.goalKeeping;
if (!goalKeeping) return false;

for (let x = 0; x < PLAYER_GOLAKEEPING_ATTRIBUTES_FIELDS.length; x++) {
Expand All @@ -107,7 +107,7 @@ function validatePlayerAttributes(player: IMatchDayPlayer): boolean {
}
} else {
// validate Technical attributes
const technical = get(player, 'attributes.technical');
const technical = player.attributes?.technical;
if (!technical) return false;

for (let x = 0; x < PLAYER_TECHNICAL_ATTRIBUTES_FIELDS.length; x++) {
Expand All @@ -120,7 +120,7 @@ function validatePlayerAttributes(player: IMatchDayPlayer): boolean {
}

// validate mental attributes
const mental = get(player, 'attributes.mental');
const mental = player.attributes?.mental;
if (!mental) return false;

for (let x = 0; x < PLAYER_MENTAL_ATTRIBUTES_FIELDS.length; x++) {
Expand All @@ -132,7 +132,7 @@ function validatePlayerAttributes(player: IMatchDayPlayer): boolean {
}

// validate physical attributes
const physical = get(player, 'attributes.physical');
const physical = player.attributes?.physical;
if (!physical) return false;

for (let x = 0; x < PLAYER_PHYSICAL_ATTRIBUTES_FIELDS.length; x++) {
Expand Down
13 changes: 10 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"resolveJsonModule": true,
Expand All @@ -17,7 +17,14 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"preserveConstEnums": true,
"experimentalDecorators": true
"experimentalDecorators": true,
"removeComments": true,
"allowUnusedLabels": false,
"pretty": true,
"allowJs": false,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"stripInternal": true
},
"exclude": [
"dist",
Expand Down

0 comments on commit 8d06503

Please sign in to comment.