“Openings teach you openings.
Endgames teach you chess!”
Stephan Gerzadowicz, Chess Master
or
Sign InEndgame Chess is our version of the capstone project for The Firehose Project, an intensive 15 week programming bootcamp. We are Team Endgame, 5 junior developers with different backgrounds working remotely to build the best chess app we can. With the support of our mentor, Travis Johnston, we followed Agile Methodology with weekly stand-ups to plan our sprints, kept our code in check using Git, and made sure everything worked with an extensive test suite. Some highlights include:
# Check Detection
def check(users_id, opponent_id)
opponent_pieces = pieces.where(user_id: opponent_id, captured: false)
king = pieces.find_by(user_id: users_id, type: "King")
opponent_pieces.each do |piece|
return true if piece.valid_move?(king.row_position, king.col_position)
end
false
end
# Checkmate Detection
def checkmate(id)
current_pieces = pieces.where(user_id: id, captured: false)
status = true
current_pieces.each do |piece|
8.times do |row|
8.times do |col|
next unless piece.reload.valid_move?(row, col)
status = false unless checkmate_check(piece, row, col)
end
end
end
status
end
# Transaction for Checkmate Detection
def checkmate_check(piece, row, col)
status = true
Piece.transaction do
piece.move_to!(row, col)
status = false unless determine_check
fail ActiveRecord::Rollback
end
status
end
// Drag and drop using jQuery draggable and droppable
$('.move_mode').draggable({ containment: '.board'});
$( '.piece' ).droppable({
drop: function( event, ui ) {
$(ui.draggable).detach().css({top: 0,left: 0});
$(this).replaceWith(ui.draggable);
var draggableId = ui.draggable.attr("id");
var droppableId = $(this).attr("pos");
var updateUrl = "/pieces/" + draggableId
var row = droppableId[0];
var col = droppableId[1];
// Update piece via AJAX
$.ajax({
type: 'PUT',
url: updateUrl,
dataType: 'json',
data: { piece: {
row_position: row,
col_position: col
}},
complete: function(){
location.reload(true);
}
});
}
});
// Pusher for Real-Time Connection
var pusher = new Pusher(ENV['pusher_key'], {
encrypted: true
});
var gameId = $('.pusherInfo').data('pusherinfo');
var channel = pusher.subscribe(gameId);
channel.bind('update-piece', function(data) {
location.reload(true);
});
Endgame Chess is a proud member open source community. You can view all of our code on GitHub. Additionally, Endgame Chess is built using open source tools.
All of our business logic is written in Ruby
Rails is the foundation of Endgame Chess, bringing so many useful tools and conventions to make building it from scratch fast
Our team followed standard Agile and SCRUM methodologies, having a weekly virtual stand up to plan the week's sprints. We developed a solid test suite using Test Driven Design and used Rubocop to enforce best-practices in code style.
We used Trello as an Agile board to keep track of the progress of all of our tickets
Slack kept our team in constant communication
Rubocop analyzed our code for style and best-practices
Screenhero made it easy to pair program remotely
We were dedicated to finding the right tool for the job. Each of these services are best-in-class, allowing us to focus on developing Endgame Chess.
Heroku's Cloud Application Platform hosts the production version of Endgame Chess
GitHub was used extensively to display new work with pull requests, allow for comments during code review, and track issues as they came up
Travis CI runs our Continuous Integration and our Continuous Deployment
Pusher uses Websockets to allow us to have real-time updates for pieces for both players
Adam D (@addstar34)
Aziz Sharipov (@gagaception)
Jonathan Pike (@jonathanpike)
Ronny Almog (@ronny2205)
Takehiro Mouri (@takehiromouri)