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 50dde53 commit 156bc15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion wgo_view/wgo/basicplayer.commentbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ CommentBox.prototype.getCommentText = function(comment, formatNicks, formatMoves
if (analyze.score != null) {
comm += "score:"+(+analyze.score).toFixed(1)+"<br>";
}
if (analyze.moves) {
if (analyze.moves && analyze.moves.length > 0) {
comm += "<h2>pv</h2>";
var info = analyze.moves[0];
if (info.move != null) {
Expand Down
8 changes: 6 additions & 2 deletions wgo_view/wgo/basicplayer.infobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ var update = function(e) {
var winrate = null;
if (info.winrate != undefined) {
winrate = info.winrate;
} else if (info.moves != undefined && info.moves[0].winrate != undefined) {
} else if (info.moves != undefined
&& info.moves[0].length > 0
&& info.moves[0].winrate != undefined) {
winrate = info.moves[0].winrate;
}
if (winrate != null) {
Expand All @@ -162,7 +164,9 @@ var update = function(e) {
var score = null;
if (info.score != undefined) {
score = info.score;
} else if (info.moves != undefined && info.moves[0].score != undefined) {
} else if (info.moves != undefined
&& info.moves[0].length > 0
&& info.moves[0].score != undefined) {
score = info.moves[0].score;
}
if (score != null) {
Expand Down

0 comments on commit 156bc15

Please sign in to comment.