Skip to content

Commit

Permalink
fix analysis of games from a position
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Jun 8, 2015
1 parent d9b9195 commit f6dca58
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
9 changes: 5 additions & 4 deletions modules/tournament/src/main/AutoPairing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ final class AutoPairing(
game1 = Game.make(
game = chess.Game(
variant = tour.variant.some,
fen = tour.position.fen.some
).copy(
clock = tour.clock.chessClock.some
),
fen = tour.position.fen.some) |> { g =>
g.copy(
clock = tour.clock.chessClock.some,
startedAtTurn = g.player.fold(0, 1))
},
whitePlayer = GamePlayer.white,
blackPlayer = GamePlayer.black,
mode = tour.mode,
Expand Down
24 changes: 19 additions & 5 deletions ui/analyse/src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,25 @@ function renderTurn(ctrl, turn, path) {
function renderTree(ctrl, tree) {
var turns = [];
var initPly = ctrl.analyse.firstPly();
for (i = 1, nb = tree.length; i < nb; i += 2) turns.push({
turn: Math.floor((initPly + i) / 2) + 1,
white: tree[i],
black: tree[i + 1]
});
if (initPly % 2 === 0)
for (i = 1, nb = tree.length; i < nb; i += 2) turns.push({
turn: Math.floor((initPly + i) / 2) + 1,
white: tree[i],
black: tree[i + 1]
});
else {
turns.push({
turn: Math.floor(initPly / 2) + 1,
white: null,
black: tree[1]
});
for (i = 2, nb = tree.length; i < nb; i += 2) turns.push({
turn: Math.floor((initPly + i) / 2) + 1,
white: tree[i],
black: tree[i + 1]
});
}

var path = treePath.default();
return turns.map(function(turn) {
return renderTurn(ctrl, turn, path);
Expand Down

0 comments on commit f6dca58

Please sign in to comment.