Skip to content

Commit

Permalink
Converted the Knight to compose model
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreSteenveld committed Jun 10, 2014
1 parent 10fd603 commit cf71296
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions script/pieces/Knight.js
Expand Up @@ -3,24 +3,29 @@
* Licensed under the MIT public license for the full license see the LICENSE file
*
*/
define([ "..", ".", "lib", "./Piece" ], function( chess, pieces, lib, Piece ){
var Compose = require( "compose" ),
Piece = require( "./Piece" );

module.exports = Compose(

pieces.Knight = lib.declare( [ Piece ], {
Piece,

{
type: "Knight",

movement: function( ){
return this.inherited( arguments, [[
[ this.x + 2, this.y + 1 ],
[ this.x + 2, this.y - 1 ],
[ this.x - 2, this.y + 1 ],
[ this.x - 2, this.y - 1 ],
[ this.x + 1, this.y + 2 ],
[ this.x + 1, this.y - 2 ],
[ this.x - 1, this.y + 2 ],
[ this.x - 1, this.y - 2 ]
]]);
}
});

return pieces.Knight;
});
movement: Compose.around( function( base ){
return function( ){
base.call( this, [
[ this.x + 2, this.y + 1 ],
[ this.x + 2, this.y - 1 ],
[ this.x - 2, this.y + 1 ],
[ this.x - 2, this.y - 1 ],
[ this.x + 1, this.y + 2 ],
[ this.x + 1, this.y - 2 ],
[ this.x - 1, this.y + 2 ],
[ this.x - 1, this.y - 2 ]
]);
};
})
}
);

0 comments on commit cf71296

Please sign in to comment.