opening trainer: find at most 5 moves

This commit is contained in:
Thibault Duplessis 2015-01-07 15:15:12 +01:00
parent 99f9186ea9
commit fdb61eea2b
3 changed files with 15 additions and 14 deletions

View file

@ -1,6 +1,6 @@
#opening .meter {
width: 494px;
height: 40px;
height: 37px;
position: relative;
background: #ededed;
border-radius: 25px;
@ -9,7 +9,7 @@
margin-top: 20px;
}
#opening .meter ul {
margin-top: 4px;
margin-top: 13px;
padding: 0;
display: block;
height: 19px;
@ -28,19 +28,20 @@
position: relative;
border-radius: 10px;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.25) inset;
transition: 0.8s;
transition: 2s;
}
#opening .meter span {
right: -12px;
right: -9px;
display: block;
text-align: center;
}
#opening .meter .step {
top: -9px;
top: -18px;
border: 3px solid #ddd;
color: #ddd;
width: 33px;
line-height: 33px;
width: 50px;
line-height: 50px;
font-size: 1.1em;
position: absolute;
background: #fff;
border-radius: 50%;
@ -64,7 +65,7 @@
}
#opening .meter li.next span.step {
color: #759900;
box-shadow: 0 0 15px #759900;
box-shadow: 0 0 15px #888;
}
#opening .meter li.already span.step {
background: #759900;

View file

@ -8,9 +8,9 @@ module.exports = function(cfg, router, i18n) {
console.log(this.data);
this.vm = {
nbGood: this.data.opening.moves.filter(function(m) {
goal: Math.min(5, this.data.opening.moves.filter(function(m) {
return m.quality === 'good';
}).length,
}).length),
figuredOut: [],
messedUp: [],
flash: {},

View file

@ -60,7 +60,7 @@ function renderTrainingBox(ctrl) {
function renderResult(ctrl) {
return [
m('div.goal', m.trust(ctrl.trans('findNbGoodMoves', strong(ctrl.vm.nbGood)))),
m('div.goal', m.trust(ctrl.trans('findNbGoodMoves', strong(ctrl.vm.goal)))),
];
}
@ -76,14 +76,14 @@ function progress(ctrl) {
var nbFiguredOut = ctrl.vm.figuredOut.length;
var lastI = nbFiguredOut - 1;
var nextI = nbFiguredOut;
for (var i = 0; i < ctrl.vm.nbGood; i++) {
for (var i = 0; i < ctrl.vm.goal; i++) {
steps.push({
found: ctrl.vm.figuredOut[i],
last: lastI === i,
next: nextI === i
});
}
var liWidth = Math.round(100 / ctrl.vm.nbGood) + '%';
var liWidth = Math.round(100 / ctrl.vm.goal) + '%';
return m('div.meter', [
m('ul',
steps.map(function(step) {
@ -110,7 +110,7 @@ function progress(ctrl) {
}
module.exports = function(ctrl) {
var percent = Math.ceil(ctrl.vm.figuredOut.length * 100 / ctrl.vm.nbGood) + '%';
var percent = Math.ceil(ctrl.vm.figuredOut.length * 100 / ctrl.vm.goal) + '%';
return m('div#opening.training', [
renderSide(ctrl),
m('div.board_and_ground', [