remind variant on correspondence games - resolves #256

pull/268/head
Thibault Duplessis 2015-01-17 15:51:54 +01:00
parent 886c575544
commit 339c499212
4 changed files with 48 additions and 2 deletions

View File

@ -14,6 +14,11 @@ data: @Html(play.api.libs.json.Json.stringify(data)),
routes: roundRoutes.controllers,
i18n: @jsI18n()
};
lichess.variantIcons = {
@lila.rating.PerfType.variants.map { variant =>
@variant.key: @Html(s""""${variant.iconChar.toString}""""),
}
};
}
}

View File

@ -96,4 +96,5 @@ object PerfType {
val nonPuzzle: List[PerfType] = List(Bullet, Blitz, Classical, Correspondence, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic)
val leaderboardable: List[PerfType] = List(Bullet, Blitz, Classical, Chess960, KingOfTheHill, ThreeCheck)
val variants: List[PerfType] = List(Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic)
}

View File

@ -981,6 +981,27 @@ div.dont_touch {
font-size: 1.2em;
padding: 1em 0;
}
.lichess_board_wrap .variant_reminder {
position: absolute;
top: 0;
left: 0;
z-index: 5;
transition: 0.6s;
text-shadow: 7px 10px 2px rgba(0,0,0,0.3);
width: 512px;
height: 512px;
line-height: 512px;
text-align: center;
}
.lichess_board_wrap .variant_reminder::before {
font-size: 290px;
opacity: 0.9;
color: #888;
}
.lichess_board_wrap .variant_reminder.gone {
opacity: 0;
transform: translateY(-100px);
}
#promotion_choice {
position: absolute;
top: 0;

View File

@ -34,6 +34,24 @@ function wheel(ctrl, e) {
return false;
}
function renderVariantReminder(ctrl) {
if (ctrl.data.game.speed !== 'correspondence') return;
var icon = lichess.variantIcons[ctrl.data.game.perf];
if (!icon) return;
return m('div', {
class: 'variant_reminder is',
'data-icon': icon,
config: function(el, isUpdate) {
if (!isUpdate) setTimeout(function() {
el.classList.add('gone');
setTimeout(function() {
el.remove();
}, 600);
}, 1000);
}
});
}
function visualBoard(ctrl) {
return m('div.lichess_board_wrap', [
m('div.lichess_board.' + ctrl.data.game.variant.key, {
@ -44,7 +62,8 @@ function visualBoard(ctrl) {
},
onclick: ctrl.data.player.spectator ? toggleDontTouch : null
}, chessground.view(ctrl.chessground)),
renderPromotion(ctrl)
renderPromotion(ctrl),
renderVariantReminder(ctrl)
]);
}
@ -70,7 +89,7 @@ module.exports = function(ctrl) {
return [
m('div.top', [
m('div.lichess_game', {
config: function(el, isUpdate, context) {
config: function(el, isUpdate) {
if (isUpdate) return;
$('body').trigger('lichess.content_loaded');
}