Add i18n and es/en locale
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _ansi = require('ansi');
|
||||
|
||||
var _ansi2 = _interopRequireDefault(_ansi);
|
||||
@ -14,28 +14,29 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var _process = process;
|
||||
var stdout = _process.stdout;
|
||||
var stdin = _process.stdin;
|
||||
var _process = process,
|
||||
stdout = _process.stdout,
|
||||
stdin = _process.stdin;
|
||||
|
||||
|
||||
var listeners = [];
|
||||
|
||||
var prefix = '\u001b';
|
||||
var prefix = '\x1B';
|
||||
var keys = {
|
||||
right: prefix + '[C',
|
||||
up: prefix + '[A',
|
||||
left: prefix + '[D',
|
||||
down: prefix + '[B',
|
||||
exit: '\u0003',
|
||||
exit: '\x03',
|
||||
space: ' '
|
||||
};
|
||||
|
||||
var Interface = (function () {
|
||||
var Interface = function () {
|
||||
function Interface() {
|
||||
var _this = this;
|
||||
|
||||
var output = arguments.length <= 0 || arguments[0] === undefined ? stdout : arguments[0];
|
||||
var input = arguments.length <= 1 || arguments[1] === undefined ? stdin : arguments[1];
|
||||
var output = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : stdout;
|
||||
var input = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : stdin;
|
||||
|
||||
_classCallCheck(this, Interface);
|
||||
|
||||
@ -61,7 +62,7 @@ var Interface = (function () {
|
||||
});
|
||||
|
||||
if (key === 'exit') {
|
||||
_this.output.write('\u001b[2J\u001b[0;0H');
|
||||
_this.output.write('\x1B[2J\x1B[0;0H');
|
||||
process.exit();
|
||||
}
|
||||
|
||||
@ -78,7 +79,7 @@ var Interface = (function () {
|
||||
_createClass(Interface, [{
|
||||
key: 'clear',
|
||||
value: function clear() {
|
||||
this.output.write('\u001b[2J\u001b[0;0H');
|
||||
this.output.write('\x1B[2J\x1B[0;0H');
|
||||
}
|
||||
}, {
|
||||
key: 'write',
|
||||
@ -110,6 +111,7 @@ var Interface = (function () {
|
||||
|
||||
var y = from.y;
|
||||
|
||||
|
||||
for (var x = from.x; x < to.x; x++) {
|
||||
this.cursor.goto(x, y);
|
||||
this.write('.');
|
||||
@ -145,6 +147,6 @@ var Interface = (function () {
|
||||
}]);
|
||||
|
||||
return Interface;
|
||||
})();
|
||||
}();
|
||||
|
||||
exports.default = Interface;
|
||||
|
@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.Bullet = undefined;
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _unit = require('./unit');
|
||||
|
||||
var _unit2 = _interopRequireDefault(_unit);
|
||||
@ -21,13 +21,13 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
||||
|
||||
var BULLET_SPEED = 10;
|
||||
|
||||
var Tank = (function (_Unit) {
|
||||
var Tank = function (_Unit) {
|
||||
_inherits(Tank, _Unit);
|
||||
|
||||
function Tank(ui) {
|
||||
_classCallCheck(this, Tank);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Tank).call(this, ui));
|
||||
var _this = _possibleConstructorReturn(this, (Tank.__proto__ || Object.getPrototypeOf(Tank)).call(this, ui));
|
||||
|
||||
_this._angle = 0;
|
||||
_this.bullets = [];
|
||||
@ -51,8 +51,8 @@ var Tank = (function (_Unit) {
|
||||
value: function draw() {
|
||||
if (this.dead) return;
|
||||
|
||||
var x = this.x;
|
||||
var y = this.y;
|
||||
var x = this.x,
|
||||
y = this.y;
|
||||
|
||||
if (this.color && this.color[0] === '#') {
|
||||
this.output.cursor.hex(this.color);
|
||||
@ -64,7 +64,7 @@ var Tank = (function (_Unit) {
|
||||
x = Math.round(x) + 2;
|
||||
y = Math.round(y) - 2;
|
||||
|
||||
var cannon = undefined;
|
||||
var cannon = void 0;
|
||||
if (this.angle < 35) cannon = '_';else if (this.angle < 70) cannon = '/';else if (this.angle < 115) cannon = '|';else if (this.angle < 160) cannon = '\\';else cannon = '_';
|
||||
|
||||
this.output.cursor.goto(x + 2, y - 2);
|
||||
@ -104,17 +104,17 @@ var Tank = (function (_Unit) {
|
||||
}]);
|
||||
|
||||
return Tank;
|
||||
})(_unit2.default);
|
||||
}(_unit2.default);
|
||||
|
||||
exports.default = Tank;
|
||||
|
||||
var Bullet = exports.Bullet = (function (_Unit2) {
|
||||
var Bullet = exports.Bullet = function (_Unit2) {
|
||||
_inherits(Bullet, _Unit2);
|
||||
|
||||
function Bullet(ui) {
|
||||
_classCallCheck(this, Bullet);
|
||||
|
||||
var _this2 = _possibleConstructorReturn(this, Object.getPrototypeOf(Bullet).call(this, ui));
|
||||
var _this2 = _possibleConstructorReturn(this, (Bullet.__proto__ || Object.getPrototypeOf(Bullet)).call(this, ui));
|
||||
|
||||
_this2.velocity = [0, 0];
|
||||
|
||||
@ -151,7 +151,7 @@ var Bullet = exports.Bullet = (function (_Unit2) {
|
||||
}]);
|
||||
|
||||
return Bullet;
|
||||
})(_unit2.default);
|
||||
}(_unit2.default);
|
||||
|
||||
function _radian(deg) {
|
||||
return deg * Math.PI / 180;
|
||||
|
@ -1,16 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Unit = (function () {
|
||||
var Unit = function () {
|
||||
function Unit(output) {
|
||||
_classCallCheck(this, Unit);
|
||||
|
||||
@ -33,9 +33,9 @@ var Unit = (function () {
|
||||
value: function draw() {
|
||||
if (this.dead) return;
|
||||
|
||||
var x = this.x;
|
||||
var y = this.y;
|
||||
var shape = this.shape;
|
||||
var x = this.x,
|
||||
y = this.y,
|
||||
shape = this.shape;
|
||||
|
||||
if (this.color && this.color[0] === '#') {
|
||||
this.output.cursor.hex(this.color);
|
||||
@ -123,6 +123,6 @@ var Unit = (function () {
|
||||
}]);
|
||||
|
||||
return Unit;
|
||||
})();
|
||||
}();
|
||||
|
||||
exports.default = Unit;
|
||||
|
Reference in New Issue
Block a user