﻿
var GameEngine = ( function () {
	function start(){
		var x,
        y,
        color,
        i,
        j,
        lengthBoard,
        lengthField;

    var players = [];
    players.push( Object.create( GameObjects.Player ).init( 'First', 'white' ) );
    players.push( Object.create( GameObjects.Player ).init( 'Second', 'black' ) );

    var board = GameObjects.Board.init( players );

    GameDraw.background();

    lengthBoard = board.length;

    for ( i = 0; i < lengthBoard; i += 1 ) {
        lengthField = board[i].length;

        for ( j = 0; j < lengthField; j += 1 ) {
            x = i;
            y = j;
            color = board[i][j].color;

            GameDraw.createCircle( x, y, color );
        }
    }

    GameDraw.playGround();
	}
	
	return{
		start: start,
	}
}() )
@@ -1,10 +1,9 @@
 %EF%BB%BF
-%0A
 var Game
@@ -27,17 +27,20 @@
 on () %7B%0A
-%09
+    
 function
@@ -47,20 +47,27 @@
  start()
+ 
 %7B%0A
-%09%09
+        
 var x,%0A 
@@ -77,11 +77,19 @@
     
+  
+  
 y,%0A
+    
     
@@ -111,11 +111,19 @@
     
+   
+ 
 i,%0A
+    
     
@@ -129,16 +129,20 @@
      j,%0A
+    
         
@@ -154,32 +154,36 @@
 hBoard,%0A        
+    
 lengthField;%0A%0A  
@@ -180,24 +180,28 @@
 Field;%0A%0A    
+ 
+   
 var players 
@@ -206,24 +206,28 @@
 s = %5B%5D;%0A    
+ 
+   
 players.push
@@ -219,33 +219,32 @@
    players.push(
- 
 Object.create( G
@@ -233,33 +233,32 @@
 h(Object.create(
- 
 GameObjects.Play
@@ -259,25 +259,23 @@
 s.Player
- 
 ).init(
- 
 'First',
@@ -282,22 +282,24 @@
  'white'
- ) 
+)
 );%0A
+    
     play
@@ -307,17 +307,16 @@
 rs.push(
- 
 Object.c
@@ -321,17 +321,16 @@
 .create(
- 
 GameObje
@@ -343,17 +343,15 @@
 ayer
- 
 ).init(
- 
 'Sec
@@ -367,15 +367,17 @@
 ack'
- ) 
+)
 );%0A%0A
+    
     
@@ -415,25 +415,23 @@
 nit(
- 
 players
- 
 );%0A%0A    
 Game
@@ -422,24 +422,28 @@
 yers);%0A%0A    
+ 
+   
 GameDraw.bac
@@ -450,24 +450,28 @@
 kground();%0A%0A
+    
     lengthBo
@@ -495,22 +495,25 @@
 h;%0A%0A    
+  
+  
 for (
- 
 i = 0; i
@@ -530,25 +530,24 @@
 oard; i += 1
- 
 ) %7B%0A        
@@ -538,32 +538,36 @@
 += 1) %7B%0A        
+ 
+   
 lengthField = bo
@@ -594,14 +594,17 @@
     
+ 
+   
 for (
- 
 j = 
@@ -633,13 +633,16 @@
 += 1
- 
 ) %7B%0A
+    
     
@@ -672,15 +672,23 @@
     
+    
 y = j;%0A
+    
     
@@ -727,32 +727,36 @@
 r;%0A%0A            
+ 
+   
 GameDraw.createC
@@ -761,17 +761,16 @@
 eCircle(
- 
 x, y, co
@@ -776,12 +776,15 @@
 olor
- 
 );%0A
+    
     
@@ -797,11 +797,19 @@
     
-%7D%0A%0A
+    %7D%0A%0A    
     
@@ -835,42 +835,1040 @@
 ();%0A
-%09%7D%0A%09%0A%09return%7B%0A%09%09start: start,%0A%09%7D%0A%7D() )
+    %7D%0A%0A    function update()%7B%0A        // currentPlayer = GetCurrentPlayer - depending on player.isOnTurn or isFirstPlayerOnTurn%0A%0A        // flag hasThrownDice -%3E if not - throw dice(allowedMoves = diceResult, currentPlayerMoves = 0); else - continue%0A%0A        // if (currentPlayer.hasHitPiece) -%3E Call function(s) to deal with this situation.%0A            // if can't put piece -%3E playerMoves = allowedMoves%0A%0A        // if ((currentPlayerMoves %3C allowedMoves) && hasMovedPiece (sets to true when called from onDrag event on piece)%0A%0A            // Subcases: move from position to position/ collect piece%0A            // Call function(s) to deal with this situation. -%3E hasMovedPiece = false, currentPlayerMoves++;%0A%0A        // Missed logic?%0A%0A        // if current player has no pieces on the board -%3E He wins.%0A%0A        // if (playerMoves === allowedMoves) -%3E change player, hasThrownDice = false%0A    %7D%0A%0A    return %7B%0A        start: start,%0A        update: update%0A    %7D;%0A%7D());%0A%0A// All events will call GameEngine.Update() and GameDraw.Update().

Add pseudo code for game update according to game state.