Skip to content

Commit

Permalink
improve play_info_index()
Browse files Browse the repository at this point in the history
  • Loading branch information
rooklift committed Dec 15, 2021
1 parent a597f80 commit 495e731
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/95_hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -1411,33 +1411,21 @@ let hub_props = {

play_info_index: function(n) {

let info_list = SortedMoveInfo(this.tree.node);
let line_starts = this.info_handler.info_clickers.filter(o => o.is_start);

if (typeof n === "number" && n >= 0 && n < info_list.length) {
if (n < line_starts.length) {

if (info_list[n].__touched) {
let move = line_starts[n].move;

this.move(info_list[n].move);
/*
} else if (config.looker_api) {
let table_move = this.tree.node.table.moveinfo[move];

// In this case we'll check if there's an entry in the selected DB and
// use it's nth move, if it has enough moves.
// But this is completely unacceptable as it differs from the
// order drawn in the infobox.
let entry = this.looker.lookup(config.looker_api, this.tree.node.board);
if (entry) {
let moves_uci_list = Object.keys(entry.moves);
if (n < moves_uci_list.length) {
moves_uci_list.sort((a, b) => {
return entry.moves[b].sort_score() - entry.moves[a].sort_score();
});
}
this.move(moves_uci_list[n]);
if (table_move && table_move.__touched) { // Allow this to happen if the move is touched
this.move(move);
} else if (config.looker_api) { // Allow this to happen if the move is in the selected API database
let db_entry = this.looker.lookup(config.looker_api, this.tree.node.board);
if (db_entry && db_entry.moves[move]) {
this.move(move);
}
*/
}
}
},
Expand Down

0 comments on commit 495e731

Please sign in to comment.