improve practice defend success message

pull/2661/head
Thibault Duplessis 2017-02-12 11:25:27 +01:00
parent 9ad5fb2910
commit 3dbfc8f398
2 changed files with 8 additions and 2 deletions

View File

@ -78,6 +78,9 @@ module.exports = function(root, studyData, data) {
root.userJump('');
root.practice.reset();
onLoad();
},
isWhite: function() {
return root.bottomColor() === 'white';
}
};
};

View File

@ -28,7 +28,8 @@ function selector(data) {
};
function renderGoal(practice, inMoves) {
switch (practice.goal().result) {
var goal = practice.goal();
switch (goal.result) {
case 'mate':
return 'Checkmate the opponent';
case 'mateIn':
@ -38,7 +39,9 @@ function renderGoal(practice, inMoves) {
case 'equalIn':
return 'Equalize in ' + plural('move', inMoves);
case 'evalIn':
return 'Get a winning position in ' + plural('move', inMoves);
if (practice.isWhite() === (goal.cp >= 0))
return 'Get a winning position in ' + plural('move', inMoves);
return 'Defend for ' + plural('move', inMoves);
case 'promotion':
return 'Safely promote your pawn';
}