Skip to content

david-harkness/connect4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connect 4

###Instructions

  • Using left and right arrow for moving the token.
  • Use up / down arrow or spacebar to drop token

Game is turn based. Winning condition is checked after every move. Once there is a winner, the token stays either red or blue. For fun, the winning player can fill up the board if they wish.

Testing

see spec/models/game_spec.rb

rake db:test:prepare
rake spec

Internal Mechanics

Having two game players is handled internally by who is red and not red. red_turn in db.

Only table being used is Games Winning condition is checked everytime a valid move is played. A winner can continue adding tokens.

Javascript

Most of the Javascript logic is located in a coffeescript file app/javascripts/play.coffee

Backend API

Get state of a game

GET /api/v1/games/game_state/[ID].json

Add a token

POST /api/v1/games/add_token',  {id:[GAME ID], column: [COLUMN]}

TODO

  • Allow clicking on column header to select and drop token
  • Adjust show.json to use API route
  • Remove global refrences to window.game in class Game in coffeescript
  • Add login system so that games have players.
  • Add Testing
  • Add Security

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published