Skip to content

Commit

Permalink
Fix build.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcervelli committed Mar 12, 2018
1 parent 9a4639d commit 634da62
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 200 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ _book
.cache/
dist/
lerna-debug.log
yarn-error.log
*.sqlite3

projects/server/assets
Expand Down
4 changes: 1 addition & 3 deletions projects/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
"compile": "tsc -p .",
"start": "yarn run compile && node ./dist/index.js",
"lint": "tslint --fix 'src/**/*.ts*'",
"build": "yarn compile && yarn package",
"package": "pkg . -o bin/turbo-hearts-scores -t node8-macos-x64,node8-linux-x64",
"build": "yarn compile",
"dev": "nodemon -V -e ts,tsx,js --watch src --exec yarn run start"
},
"devDependencies": {
"@types/express": "^4.11.0",
"@types/knex": "^0.0.68",
"@types/ws": "^3.2.1",
"pkg": "^4.3.0-beta.5",
"tslint": "^5.8.0",
"typescript": "^2.6.2"
},
Expand Down
3 changes: 2 additions & 1 deletion projects/shared/src/analysis/HandSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export function scoresToDelta(scores: number[]): number[] {

export function getGameResult(game: IGame) {
const scores = [0, 0, 0, 0];
game.hands.forEach(hand => {
const hands = game.hands || [];
hands.forEach(hand => {
const result = getHandResult(hand);
if (result.valid) {
for (let i = 0; i < 4; i++) {
Expand Down
2 changes: 1 addition & 1 deletion projects/shared/src/analysis/Scoreboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Scoreboard implements IGameAnalysis<ScoreMap> {
if (!game.players || game.players.length === 0) {
return current;
}
if (game.players.some(p => p == null)) {
if (game.players.some(p => p == null) || game.hands == null || game.hands.length === 0) {
return current;
}
const handSummary = analyzeHands(game.hands, new HandSummary());
Expand Down
3 changes: 3 additions & 0 deletions projects/shared/src/analysis/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export function analyzeHands<R>(hands: IHand[], analysis: IHandAnalysis<R>): R {
export function analyzeGameHands<R>(games: IGame[], analysis: IHandAnalysis<R>): R {
let current = analysis.initialState();
for (const game of games) {
if (game.hands == null) {
continue;
}
for (const hand of game.hands) {
current = analysis.analyze(current, hand);
}
Expand Down
Loading

0 comments on commit 634da62

Please sign in to comment.