ymir-js
Version:
This toolkit is created to make it easier for you to develop games like chess, checkers, go, match 3 puzzle and more. It is still under development.
51 lines (50 loc) • 1.94 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var item_1 = require("../../core/item");
var constant_1 = require("../constant");
var CheckersItem = /** @class */ (function (_super) {
__extends(CheckersItem, _super);
function CheckersItem(item) {
var _this = _super.call(this, item) || this;
_this.movement = {};
_this.color = item.color || constant_1.CHECKERS_BLACK;
_this.king = item.king || false;
_this.movement = item.movement || {};
if (item.king) {
_this.movement.linear = true;
_this.movement.stepCount = 7;
}
else {
var isBlack = _this.color === constant_1.CHECKERS_BLACK;
_this.movement[isBlack ? 'top' : 'bottom'] = true;
_this.movement.left = true;
_this.movement.right = true;
}
return _this;
}
// TODO: Write Test
CheckersItem.prototype.setKing = function () {
this.movement = {
linear: true,
stepCount: 7,
};
this.king = true;
};
return CheckersItem;
}(item_1.default));
exports.default = CheckersItem;