Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
124 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# socketserver | ||
A test server for web sockets project | ||
# Real Chess | ||
Real-time chess game |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
var game, board; | ||
|
||
window.init = function () { | ||
game = new Chess(); | ||
board = new ChessBoard('board', cfg); | ||
|
||
var socket = io(); | ||
$('#go').click(function () { | ||
socket.emit('button', $('#name').val()); | ||
//socket.emit('button', "dude"); | ||
}); | ||
|
||
socket.on('button', function (msg) { | ||
$('#messages').append($('<li>').text(msg)); | ||
}); | ||
}; | ||
|
||
|
||
|
||
// do not pick up pieces if the game is over | ||
// only pick up pieces for the side to move | ||
var onDragStart = function(source, piece, position, orientation) { | ||
if (game.game_over() === true || | ||
(game.turn() === 'w' && piece.search(/^b/) !== -1) || | ||
(game.turn() === 'b' && piece.search(/^w/) !== -1)) { | ||
return false; | ||
} | ||
}; | ||
|
||
var onDrop = function(source, target) { | ||
// see if the move is legal | ||
var move = game.move({ | ||
from: source, | ||
to: target, | ||
promotion: 'q' // NOTE: always promote to a queen for example simplicity | ||
}); | ||
|
||
// illegal move | ||
if (move === null) return 'snapback'; | ||
|
||
}; | ||
|
||
// update the board position after the piece snap | ||
// for castling, en passant, pawn promotion | ||
var onSnapEnd = function() { | ||
board.position(game.fen()); | ||
}; | ||
|
||
var cfg = { | ||
draggable: true, | ||
position: 'start', | ||
onDragStart: onDragStart, | ||
onDrop: onDrop, | ||
onSnapEnd: onSnapEnd | ||
}; | ||
|
||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Real Chess</title> | ||
<link rel="stylesheet" href="/lib/chessboard-0.3.0.min.css"> | ||
</head> | ||
<body onload="window.init();"> | ||
<div id='board' style="width: 400px"></div> | ||
<ul id="messages"> | ||
<li>o hai there 1</li> | ||
</ul> | ||
<button id="go">Go!</button> | ||
<input id="name" value="david"/> | ||
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script> | ||
<script src="http://code.jquery.com/jquery-1.11.1.js"></script> | ||
<script src="/lib/chess.min.js"></script> | ||
<script src="/lib/chessboard-0.3.0.min.js"></script> | ||
<script src="/default.js"></script> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.