fix analysis of games from position
This commit is contained in:
parent
44d3badcf7
commit
cab193c9fd
|
@ -5,6 +5,10 @@ module.exports = function(steps, analysis) {
|
|||
|
||||
this.tree = steps;
|
||||
|
||||
this.firstPly = function() {
|
||||
return this.tree[0].ply;
|
||||
}.bind(this);
|
||||
|
||||
this.getStep = function(path) {
|
||||
var tree = this.tree;
|
||||
for (var j in path) {
|
||||
|
|
|
@ -48,7 +48,7 @@ module.exports = {
|
|||
var p = ctrl.vm.path;
|
||||
var len = p.length;
|
||||
if (len === 1) {
|
||||
if (p[0].ply === 0) return;
|
||||
if (p[0].ply === ctrl.analyse.firstPly()) return;
|
||||
p[0].ply--;
|
||||
} else {
|
||||
if (p[len - 1].ply > p[len - 2].ply) p[len - 1].ply--;
|
||||
|
@ -70,7 +70,7 @@ module.exports = {
|
|||
|
||||
first: function(ctrl) {
|
||||
ctrl.userJump([{
|
||||
ply: 0,
|
||||
ply: ctrl.analyse.firstPly(),
|
||||
variation: null
|
||||
}]);
|
||||
},
|
||||
|
|
|
@ -22,7 +22,7 @@ module.exports = function(opts) {
|
|||
|
||||
this.userId = opts.userId;
|
||||
|
||||
var initialPath = opts.path ? treePath.read(opts.path) : treePath.default();
|
||||
var initialPath = opts.path ? treePath.read(opts.path) : treePath.default(this.analyse.firstPly());
|
||||
|
||||
this.vm = {
|
||||
path: initialPath,
|
||||
|
@ -53,7 +53,7 @@ module.exports = function(opts) {
|
|||
console.log(e);
|
||||
}
|
||||
if (!s) {
|
||||
this.vm.path = treePath.default();
|
||||
this.vm.path = treePath.default(this.analyse.firstPly());
|
||||
this.vm.pathStr = treePath.write(this.vm.path);
|
||||
s = this.analyse.getStep(this.vm.path);
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@ function copy(obj, newValues) {
|
|||
|
||||
module.exports = {
|
||||
|
||||
default: function() {
|
||||
default: function(ply) {
|
||||
return [{
|
||||
ply: 0,
|
||||
ply: ply || 0,
|
||||
variation: null
|
||||
}];
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue