Giter VIP home page Giter VIP logo

mastercloudapps-projects / chess Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 2.0 3.76 MB

๐Ÿ“” Software Design Patterns using JavaScript, on a NodeJS chess engine

Home Page: https://mastercloudapps-projects.github.io/chess/coverage/

License: Apache License 2.0

JavaScript 95.82% CSS 1.00% HTML 3.00% Dockerfile 0.18%
chess chess-game design-patterns javascript javascript-design-patterns nodejs

chess's People

Contributors

joseramosvalderrama avatar lmorente avatar luisboto avatar micaelgallego avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

luisboto

chess's Issues

Fix and improvements

Top priority

  • Different object implementations in JS (documentation and example project)
  • Define enums in JS

tfmCodeDoc

Tasks

  • 0 - Add moveRule template method pattern to documentation
    • 0.1 - Add decorator pattern to documentation
  • 1 - Fix rejected inheritance (pawn), maybe by using a correct decorator pattern
  • 2 - Rename CPUPlayer to randomCPU
  • 3 - Move CPU player to front end
  • 4 - Do Class diagram (let's do this later since project structure will probably still change)
  • 5 - Rename chess folder to backend, and proyect name to chess.
  • 6 & 7 - Improve project packages
  • 8 - Merge pieces factory by color
  • 9 - Define Enums in PieceType
  • 10 - Object-oriented front end
  • 11 - Update patterns in the readme
  • 12 - Create a single generic method for get piece (delete getRook, getHorse ...)
  • 13 - Rename movements to rules (Example MovementRules)
  • 14 - Refactor coordinate system & abstractMoveRule to make it simpler (ref https://github.com/x-USantaTecla-game-chess/java.swing.socket.sql/tree/master/src/usantatecla)
  • 15 - Make memento reuse board builder methods

More information in the task description

Fix

  • Fix Memento: save turn (now undo / redo each player movement)

Documentation & fixes

  • Explicitly indicate factory functions shouldn't make use of private functions or attributes (they turn into closures)

  • Expand info on closures using 'that' context

    • Reference to Douglas Crockford's book on this/that
  • Module pattern info / reference on singleton

  • Add UML diagrams on main documentation

  • Add testing & test case documentation

  • More tests

  • Remove decorator in favor of 'getNextStrategy' method on strategies (make a release previously)

Documentation & JS coding style patterns theoretical study

Technical documentation & style guide must be enhanced with detailed comparisons on decided coding style patterns (classes, clousures, constructor functions, factory functions), comparing their limitations, pros, inheritance compatibility and backing it up with bibliography.

  • Unify code examples for all styles
    • Classes
    • Closures
    • Constructor functions
    • Factory functions
  • Decide style guide document structure
  • Create full class UML diagram to place on both technical and main documentation
  • Add design pattern documentation to main document
  • Add coding styles to technical documentation (ONLY AFTER TUTOR VERIFICATION)
  • Find bibliography and sources
    • Add existing references on comments from /codingStyles to bibliography
    • Add existing references from README.md technical documentation

Minor final refactoring

  • Remove //TODO on frontend as responsibility is correctly distributed.
  • Add Singleton Pattern documentation. Mention differences between classical application and javascript's.
  • board.js -> getAllAttackPositionsByColor : use a Set from the get go instead of an array
  • Rework piece and pieceAbbreviation parameters to calculate them dynamically (color, full name, color abbreviation letter even)
  • Remove '_DIAGONAL' from last 4 element of DirectionEnum
  • Make kingMoveRule use a for loop to iterate all DirectionEnum values.
  • Rework kingMoveRule getMovement() to not return a single element array.

More lengthy refactors, to do only if we find ourselves with enough time:

  • Rename pieceAbbreviationEnum to pieceType
    • Remove color from this enum, dynamically receive it via parameter, so as not to mix color & type of pieces.
  • Refactor error message system so as not to make caller function check for errors.
  • Rework updateCheckStatus method & checkMate attribute on board.js:
    • Draw situation (where opposite color is not on check but cannot make any valid moves) is not checked nor handled.
    • Handle checkmate situation, as of now it just freezes the game.
    • Remove checkmate attribute.

Initial Implementation bucket list

This is a list of all tasks defined for the implementation of the initial version. Tasks may be added or removed as we see fit.

Development is carried on the initialImplementation branch.

Top priority

  • Fix pawn movement bug when using mementos
    Pawns will recalculate position and direction upon memento usage, so advanced ones will move in the wrong direction

Tasks

  • Definition of game module
  • Usage of an UUID generated on frontend to identify specific games
  • Creation of a board builder
  • Definition of a Board module with top level operations (piece movement etc)
  • Creation of piece factories
  • Creation of piece movement strategies modules
    • Pawn movement
      • Pawn becomes queen at the end of the board
    • Rook movement
    • Bishop movement
    • Horse movement
    • Queen movement as a composite of rook & bishop
    • King movement (missing diagonal movements as of now)
  • Creation of simple CPUplayer which makes a random movement
  • Improve error message handling
  • Adding logic to the rules of the game:
    • Evaluate check (could use getAllCoordinatesThreatenedByColor on board.js)
    • Force movement of the king in check player (player & cpu player)
    • Evaluate checkmate -> end of game

-- Extra:

  • Memento to undo/redo movements. (jmrv)
    • (Experimental) Flyweight to avoid using strings as mementos

-- (Potential next version)
Level CPU Player:

  • Level 0 - random movement
  • Level 1 - evaluate & choose kill movement if is possible
  • Level 2 - evaluate & choose check movement

Extra: Unitary testing

As an extra: Create a bunch of unitary tests for the domain classes, since it might be a good look and round up the whole project.

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.