Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/development'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruppler committed Jun 21, 2016
2 parents 9ce4fb3 + e40a7a4 commit 2cb0992
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 45 deletions.
15 changes: 6 additions & 9 deletions css/board.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@
&.p2 { background-color: $primary-color-dark; }
}

&.immovable {
.stone { opacity: 0; }
.captive { opacity: 1; }
}

.stone {
width: 50%;
height: 50%;
Expand All @@ -140,11 +145,7 @@
transition: all $time-smooth $natural;

&.F {
&.h1 { box-shadow: $shadow1; }
&.h2 { box-shadow: $shadow2; }
&.h3 { box-shadow: $shadow3; }
&.h4 { box-shadow: $shadow4; }
&.h5 { box-shadow: $shadow5; }
box-shadow: $shadow1;
}

&.S {
Expand Down Expand Up @@ -185,10 +186,6 @@
border-radius: 0.25vmin;
box-shadow: $shadow1;
transition: all $time-smooth $natural;

&.visible {
opacity: 1;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion css/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/style.css.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ js/app.js
js/lib/i18n.js
js/app/nls/main.js
i18n!nls/main
js/lib/jquery.min.js
js/lib/lodash.min.js
js/app/config.js
js/lib/jquery.min.js
js/lib/domReady.js
domReady!
js/app/messages.js
Expand Down
2 changes: 1 addition & 1 deletion dist/css/style.css

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions dist/js/app.js

Large diffs are not rendered by default.

51 changes: 33 additions & 18 deletions js/app/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

define(['app/messages', 'i18n!nls/main', 'lodash'], function (Messages, t, _) {
define(['app/config', 'app/messages', 'i18n!nls/main', 'lodash'], function (config, Messages, t, _) {

var Board, Square, Piece;
var m = new Messages('board')
Expand Down Expand Up @@ -45,7 +45,7 @@ define(['app/messages', 'i18n!nls/main', 'lodash'], function (Messages, t, _) {
),

stone_class: _.template('stone p<%=player%> <%=stone%> <%=height_class%>'),
piece_location: _.template('translate(<%=x%>.0%, <%=y%>.0%)'),
piece_location: _.template('translate(<%=x%>%, <%=y%>%)'),
piece: _.template(
'<div class="piece">'+
'<div class="wrapper">'+
Expand Down Expand Up @@ -111,7 +111,7 @@ define(['app/messages', 'i18n!nls/main', 'lodash'], function (Messages, t, _) {

Piece.prototype.render = function () {
var that = this
, location;
, location, captive_offset = 6;

if (this.board.defer_render) {
this.needs_updated = true;
Expand Down Expand Up @@ -148,6 +148,18 @@ define(['app/messages', 'i18n!nls/main', 'lodash'], function (Messages, t, _) {
// Render or update view
this.x = 100*( this.col_i - this.board.size/2);
this.y = 100*(this.board.size/2 - 1 - this.row_i);

// Offset captives
if (!this.is_immovable) {
this.y += captive_offset*(
1 - this.height + 1*(this.stone == 'S' && !!this.captives.length)
);

if ((this.captor||this).height > this.board.size) {
this.y += captive_offset*((this.captor||this).height - this.board.size);
}
}

location = tpl.piece_location(this);

if (!this.$view) {
Expand Down Expand Up @@ -178,16 +190,13 @@ define(['app/messages', 'i18n!nls/main', 'lodash'], function (Messages, t, _) {
this.prev_height = this.height;
this.prev_location = location;

// Update captive indicator
if (this.captor || this.captives.length) {
this.$captive.addClass('visible');
if ((this.captor || this).captives.length >= this.board.size && !this.is_immovable) {
this.height += 1.5;
}
if (this.is_immovable) {
this.$view.addClass('immovable');
this.$captive.css('transform', 'translateY('+(-captive_offset*(this.height - 1)/0.075) + '%)');
} else {
this.$captive.removeClass('visible');
this.$view.removeClass('immovable');
this.$captive.css('transform', 'none');
}
this.$captive.css('transform', 'translateY('+(-65*(this.height - 1)) + '%)');

if (this.square && !this.$view.closest('html').length) {
this.board.$pieces.place(this.$view);
Expand Down Expand Up @@ -577,9 +586,7 @@ define(['app/messages', 'i18n!nls/main', 'lodash'], function (Messages, t, _) {
)
);

if (this.saved_ply) {
this.go_to_ply(this.saved_ply);
}
this.go_to_ply(this.saved_ply || 0);

return this.$view;
};
Expand Down Expand Up @@ -608,7 +615,7 @@ define(['app/messages', 'i18n!nls/main', 'lodash'], function (Messages, t, _) {
}

if (this.ply == 0) {
this.show_comments(this.game);
this.show_comments(0);
} else {
this.show_comments(ply);
}
Expand Down Expand Up @@ -646,7 +653,7 @@ define(['app/messages', 'i18n!nls/main', 'lodash'], function (Messages, t, _) {
}

if (this.ply == 0) {
this.show_comments(this.game);
this.show_comments(0);
this.set_active_squares(ply);
} else {
this.show_comments(this.game.plys[this.ply - 1]);
Expand Down Expand Up @@ -680,6 +687,14 @@ define(['app/messages', 'i18n!nls/main', 'lodash'], function (Messages, t, _) {
Board.prototype.show_comments = function (ply) {
m.clear(false, true);

if (ply === 0) {
if (this.game.comments) {
_.map(this.game.comments, comment);
}
m.player1(this.game.config.player1);
m.player2(this.game.config.player2);
}

if (!ply || this.defer_render) {
return;
}
Expand All @@ -706,7 +721,7 @@ define(['app/messages', 'i18n!nls/main', 'lodash'], function (Messages, t, _) {

Board.prototype.play = function () {
if (this.do_ply() && this.game.plys[this.ply]) {
this.play_timer = setInterval(_.bind(this.do_ply, this), 1500);
this.play_timer = setInterval(_.bind(this.do_ply, this), 6e4/config.play_speed);
this.is_playing = true;
$('body').addClass('playing');
}
Expand Down Expand Up @@ -803,7 +818,7 @@ define(['app/messages', 'i18n!nls/main', 'lodash'], function (Messages, t, _) {
this.defer_render = false;

if (ply <= 0) {
this.show_comments(this.game);
this.show_comments(0);
} else {
this.show_comments(this.game.plys[this.ply - 1]);
}
Expand Down
11 changes: 11 additions & 0 deletions js/app/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// PTN Ninja by Craig Laparo is licensed under a Creative Commons
// Attribution-NonCommercial-ShareAlike 4.0 International License.
// http://creativecommons.org/licenses/by-nc-sa/4.0/

'use strict';

define(['lodash'], function (_) {
return {
play_speed: 45
};
});
1 change: 1 addition & 0 deletions js/app/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ define(['app/grammar', 'app/messages', 'i18n!nls/main', 'lodash', 'lzstring'], f
}

if (this.plys.length) {
this.plys[0].is_first = true;
_.last(this.plys).is_last = true;
}
}
Expand Down
6 changes: 5 additions & 1 deletion js/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

requirejs({locale: navigator.language}, [
'i18n!nls/main',
'app/config',
'app/messages',
'app/game',
'app/board',
Expand All @@ -17,7 +18,7 @@ requirejs({locale: navigator.language}, [
'bililiteRange.undo',
'bililiteRange.fancytext',
'domReady!'
], function (t, Messages, Game, Board, saveAs, _, $) {
], function (t, config, Messages, Game, Board, saveAs, _, $) {

var $window = $(window)
, $body = $('body')
Expand All @@ -38,6 +39,9 @@ requirejs({locale: navigator.language}, [
, default_ptn = '[Date "'+today+'"]\n[Player1 "White"]\n[Player2 "Black"]\n[Result ""]\n[Size "5"]\n\n'
, sample_ptn = 'NoZQlgLgpgBARABQDYEMCeAVFBrAdAYwHsBbOAXQChgBRANygDsJ4B5BpMB2ZdcqgERTR4AJgAMARgBsuMQFZcEuX2A80UAE4T4Acw0BXAA6GkmlWs0jdGqI1O0wQgBYoGKgEpQAzvqTM4YgC0AGIq4ABesHDKlBQw8QmJiQDeMBiQpjAAvhQUErgwKHIwyQCCSADu6F4wFZBOMBBOsEQaXBpeuF1ZMFASFCIFACba+HIUAMzDVkPjACwFUHO9cgDkFAowEksA1FuzAHwUMjAgszAARuMA7AUSh9oAwrMUABwFz8sXIhQAnAX4CaXCZ5MQA5YSC4TA79CT5S7LFBzPKDLb4OY7bT3OQw1YAQjyU32GO0ULyCxgQzmq0pIKUdwuc0CEnxW2+mLyJxAKCB9wmHIktxg6JgIkBOx+EneorGgSsIipAB5Jf9aTS5uiYSDxHchvyWTAJprtfCQGMYHIoHJAuMRKjsczTnqBkTzoyBhSQFbLiyBpsJDyYZcfiITiIoXLCtqhfgrICBtLuVYUP0RKq5krqRalorxhMwVsrY6rZN4eGJsrgZNURqmVm+Y7kgAKfQMIaEACUOQmRLF0Lj-QmFIkgMVBuSLAa6hQTgANDAAJIwHSEZhNMBePE9ZLuMA6JwQAD8OUSUAmeIJiSCwRKMCbgHtSQAFMIBC0kfHfvgFY-mCAblJAICk3+yCggA';

window.game = game;
window.board = board;

(function () {
function _templatize(parent) {
for (var key in parent) {
Expand Down

0 comments on commit 2cb0992

Please sign in to comment.