Giter Club home page Giter Club logo

chessington-ts's Introduction

chessington-ts

Starter project for a chess-based TDD exercise

Install with npm install Run tests with npm test Start program with npm start. This will host a server on localhost:3000

Guide to the code

Board

When a board is created it initialises a 2-dimensional array of length 8. That is, an array of 8 arrays, where each array inside has a length of 8.

These represent rows and columns.

So, to select the first row you can do let row1 = board[0] And to get the second square of that row: let square = row1[1] Or, in shorthand: let square = board[0][1]

Board then has the following methods to use: setPiece(square, piece) places the given piece on a square returns nothing. getPiece(square) returns the piece on a given square, if one is there. findPiece(pieceToFind) will return the square that the piece is on, if it is on the board. movePiece(fromSquare, toSquare) will move the piece on the fromSquare to the toSquare.

Square

Squares have two properties: row and col.

Squares can be made one of two ways (I'm not really sure why...) let square1 = Square.at(0,1) OR let square2 = new Square(0,1) These are equal. You can check like this: square1.equals(square2). This will return a boolean (in this case, true.)

Pieces

pieces have one method: getAvailableMoves(board). This method must be given the current board (so that it can know which moves are available!) it returns an array, which is a list of Squares that are available to be moved to.

chessington-ts's People

Contributors

scl-softwire avatar biadars avatar samyou-softwire avatar joshadampowell avatar dwrendell avatar kenneth-siu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.