Skip to content

Commit

Permalink
Fix handling of zero length moves array
Browse files Browse the repository at this point in the history
  • Loading branch information
k-matsuzaki committed Nov 4, 2023
1 parent ead3761 commit 50dde53
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions wgo_view/wgo/player.cgos.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,9 @@
function winrate(analysis) {
if (analysis.winrate != undefined)
return analysis.winrate * 100;
if (analysis.moves != undefined && analysis.moves[0].winrate)
if (analysis.moves != undefined
&& analysis.moves.length > 0
&& analysis.moves[0].winrate)
return analysis.moves[0].winrate * 100;
return null;
}
Expand All @@ -521,7 +523,9 @@
var score;
if (analysis.score != undefined) {
score = analysis.score;
} else if (analysis.moves != undefined && analysis.moves[0].score) {
} else if (analysis.moves != undefined
&& analysis.moves.length > 0
&& analysis.moves[0].score) {
score = analysis.moves[0].score;
} else {
return null;
Expand Down

0 comments on commit 50dde53

Please sign in to comment.