function SingleGame() {
	this.TableM = new TableModel();

	/* Inisialisation du tableau des données */

	this.T = new Array(10, 4);
	this.values = null;

	// Tableau des données des cartes

	// Inisialisation Des scors
	this.HoldScor = 7.5;
	this.UserScors = 500;
	this.RobotScors = 500;
	this.UserRoundScor = 0;
	this.RobotRoundScor = 0;
	this.Round = 0;
	this.NumberCarteImage = 1;
	this.NumberCarteImageRobot = 1;

	// Fin Inisialisation Des scors

	this.Tour = 0;

	this.GameTour = 1;
	this.gameFinish = false;
	this.WriteDiv = 0;
	this.countLine = 0;
	this.RoundFinish = false;
	this.TableCarteTirer = new Array(50);
	this.CarteTirer = 0;
	this.CarteUser = 0;
	this.CarteRobot = 0;
	this.TirageRobot = 0;
	this.FirstCarteRobotImage = 0;
	this.FirstCarteUser = 0;
	this.FirstCarteRobot = 0;
	this.NumberCarte = Math.floor((Math.random() * 10) + 0);
	this.NumberColor = Math.floor((Math.random() * 4) + 0);
	this.Carte = 0;
	this.Couleur = 0;
	this.i = 0;
	this.kingScor = 0;
	this.TirageKingRobot = 0;
	this.TirageKing = 0;
	this.WriteDelai = false ;

	this.robot = document.getElementById('SpaceCardRobot');
	this.player = document.getElementById('SpaceCardPlayer');
};
// Test Game finished
SingleGame.prototype.GameIsFinish = function() {
	if (this.UserScors == 0) {
		this.Write("Robot Wins The Game",
				"#1D702D", 50,"Press exit to return to main menu !");
		this.gameFinish = true;
		return true;

	} else if (this.RobotScors == 0) {
		this.Write("You Win The Game",
				"#1D702D", 50,"Press exit to return to main menu !");
		this.gameFinish = true;
		return true;
	}
	return false;
}
// Machine a écrire
SingleGame.prototype.Write = function(text, color, delai, text2,delaisSecond) {
    	this.WriteDiv++;
		this.countLine++;
		if (this.countLine == 5) {
			document.getElementById('Journal').innerHTML = "";
			this.countLine = 0;
		}
		if (delaisSecond==null)
			delaisSecond="1000" ;
   if (this.WriteDelai == false)
	{   

		
		if (delai == null)
			delai = 0;
		if (text2 == null) {

			document.getElementById('Journal').innerHTML = '<div id="ecrire'
					+ this.WriteDiv + '" class="ecrire"> ' + text + '</div> <br />'+document.getElementById('Journal').innerHTML;
			$("#ecrire" + this.WriteDiv).css("color", color);
			$("#ecrire" + this.WriteDiv).machineEcrire({
				'delai' : delai
			});
		} else {
			document.getElementById('Journal').innerHTML = '<div id="ecrire'
					+ this.WriteDiv + '" class="ecrire"> ' + text + '<br/>' + text2
					+ '</div> <br />'+document.getElementById('Journal').innerHTML;;
			$("#ecrire" + this.WriteDiv).css("color", color);
			$("#ecrire" + this.WriteDiv).machineEcrire({
				'delai' : delai
			});
		}
	}
	else
	{
	    setTimeout(function(){
		
		if (delai == null)
			delai = 0;
		if (text2 == null) {

			document.getElementById('Journal').innerHTML = '<div id="ecrire'
					+ this.WriteDiv + '" class="ecrire"> ' + text + '</div> <br />'+document.getElementById('Journal').innerHTML;
			$("#ecrire" + this.WriteDiv).css("color", color);
			$("#ecrire" + this.WriteDiv).machineEcrire({
				'delai' : delai
			});
		} else {
			document.getElementById('Journal').innerHTML = '<div id="ecrire'
					+ this.WriteDiv + '" class="ecrire"> ' + text + '<br/>' + text2
					+ '</div> <br />'+document.getElementById('Journal').innerHTML;
			$("#ecrire" + this.WriteDiv).css("color", color);
			$("#ecrire" + this.WriteDiv).machineEcrire({
				'delai' : delai
			});
		}
		this.WriteDelai=false;
		
		},delaisSecond);
	}
}
// chercher si une carte a été tirrer déja

SingleGame.prototype.SearchNumber = function(number) {

	for (var i = 0; i < this.TableCarteTirer.Length; i++) {
		if (this.TableCarteTirer[i] == number) {
			return true;
		}
	}
	return false;
}

SingleGame.prototype.pull = function() {
	if (this.gameFinish == false) {
		if (this.RoundFinish == false) {
			if ((this.UserRoundScor == 7.5) && (this.GameTour % 2 != 0)
					&& (this.Tour == 0)) {
				this.Tour = 1;
				this.WriteDelai=true;
				//this.Write("Robot pulled a Card", "#853894", -2);
				this.GameRobot();
			}
			if ((this.RobotScors != 0) && (this.UserScors != 0)
					&& (this.Tour == 0)) {
				this.Tour = 0;
				this.WriteDelai=true;
				this.Write("Player pulled a Card", "#853894", -2,"","1000");
				this.GameUser();
			}
			if ((this.RobotRoundScor == 7.5) && (this.GameTour % 2 != 0)
					&& (this.Tour == 1)) {
				this.Tour = 0;
				this.WriteDelai=true;
				this.Write("Player pulled a Card", "#853894",-2,"","1000");
				this.GameUser();
			}
			if ((this.UserScors != 0) && (this.RobotScors != 0)
					&& (this.Tour == 1)) {
				this.Tour = 1;
				this.WriteDelai=true;
				//this.Write("Robot pulled a Card", "#853894", 0);
				this.GameRobot();
			}
		}
	}
}

SingleGame.prototype.pass = function() {

	if (this.gameFinish == false) {
		if (this.RoundFinish == false) {
			if ((this.UserRoundScor <= this.HoldScor) && (this.Tour == 0)
					&& (this.GameTour % 2 != 0) && (this.RobotScors != 0)
					&& (this.UserScors != 0)) {
				this.Tour = 1;
				this.Write("Player passed the Turn", "#C9001A", 0,"","1000");
				this.WriteDelai=true;
				//var sound = document.getElementById("passSon");
				//swfobject.embedSWF("pass.swf", sound, 1, 1, 10);
				
				this.GameRobot();
				
			} else if ((this.UserRoundScor <= this.HoldScor)
					&& (this.Tour == 0) && (this.GameTour % 2 == 0)
					&& (this.RobotScors != 0) && (this.UserScors != 0)) {
				document.getElementById('ScorRobot').innerHTML = "<p>Round's Score : "
						+ this.RobotRoundScor + "</p>";
				document.getElementById('FirstCardRobot').innerHTML = '<img class="FirstCard" src="app/images/cards/'
						+ this.FirstCarteRobotImage + '.png" />';
						
						if (this.RobotRoundScor > this.UserRoundScor) 
						{
								document.getElementById('ScorRobot').innerHTML = "<p>Round's Score : "
										+ this.RobotRoundScor + "</p>";
								this.RobotScors = this.RobotScors + 100;
								this.UserScors = this.UserScors - 100;

								document.getElementById('FirstCardRobot').innerHTML = '<img class="FirstCard" src="app/images/cards/'
										+ this.FirstCarteRobotImage + '.png" />';
								this.RoundFinish = true;
								if (!this.GameIsFinish()) {
									this.Write("Robot Wins The Round " + this.GameTour, "#1D702D",
											null, "Press enter for next round","2000");
									this.GameTour++;
								}
						}
						else if (this.RobotRoundScor < this.UserRoundScor) 
						{
								document.getElementById('ScorRobot').innerHTML = "<p>Round's Score : "
										+ this.RobotRoundScor + "</p>";
								this.RobotScors = this.RobotScors - 100;
								this.UserScors = this.UserScors + 100;

								document.getElementById('FirstCardRobot').innerHTML = '<img class="FirstCard" src="app/images/cards/'
										+ this.FirstCarteRobotImage + '.png" />';
								this.RoundFinish = true;
								if (!this.GameIsFinish()) {
									this.Write("You Win The Round " + this.GameTour, "#1D702D",
											null, "Press enter for next round","2000");
									this.GameTour++;
								}
						}
						else
						{
						    document.getElementById('ScorRobot').innerHTML = "<p>Round's Score : "
										+ this.RobotRoundScor + "</p>";
								

								document.getElementById('FirstCardRobot').innerHTML = '<img class="FirstCard" src="app/images/cards/'
										+ this.FirstCarteRobotImage + '.png" />';
								this.RoundFinish = true;
								if (!this.GameIsFinish()) {
									this.Write("Round "+this.GameTour+" ends with a Draw", "#1D702D",
											null, "Press enter for next round","2000");
									this.GameTour++;
								}
						}
				
						
				// a voire

			} else if ((this.RobotRoundScor > this.HoldScor)
					&& (this.Tour == 1) && (this.GameTour % 2 != 0)
					&& (this.RobotScors != 0) && (this.UserScors != 0)) {
				document.getElementById('ScorRobot').innerHTML = "<p>Round's Score : "
						+ this.RobotRoundScor + "</p>";
				document.getElementById('FirstCardRobot').innerHTML = '<img class="FirstCard" src="app/images/cards/'
						+ this.FirstCarteRobotImage + '.png" />';
				
				
			}
		}
	}
}

SingleGame.prototype.Next = function() {
	this.Inisialisation();
	if ((this.RobotScors > 0) && (this.UserScors > 0)) {
		// Next Round

		this.Inisialisation();

	} else {
		document.getElementById('RoundScorPlayer').innerHTML = "<p>Player's Score : "
				+ this.UserScors + "</p>";
		document.getElementById('RoundScorRobot').innerHTML = "<p>Robot's Score : "
				+ this.RobotScors + "</p>";

	}
}

// Calcule de la valeur Du joker ( Rois Carreau )
SingleGame.prototype.CalculeRoisCarreau = function() {
	if (this.Tour == 0) {
		if (this.UserRoundScor < this.HoldScor) {
			if (this.UserRoundScor == 0) {
				this.UserRoundScor = 7;
			} else if (this.UserRoundScor == 7) {
				this.UserRoundScor = this.UserRoundScor + 0.5;
			}

			else {
				this.kingScor = (this.HoldScor - this.UserRoundScor);
				this.UserRoundScor = this.UserRoundScor + this.kingScor;

			}
		} else {
			this.UserRoundScor = this.UserRoundScor + 0.5;
		}
	} else if (this.Tour == 1) {
		if (this.RobotRoundScor < this.HoldScor) {
			if (this.RobotRoundScor == 0) {
				this.RobotRoundScor = 7;
			} else if (this.RobotRoundScor == 7) {
				this.RobotRoundScor = this.UserRoundScor + 0.5;
			} else {
				this.kingScor = (this.HoldScor - this.RobotRoundScor);
				this.RobotRoundScor = this.RobotRoundScor + this.kingScor;
			}
		} else {
			this.RobotRoundScor = this.RobotRoundScor + 0.5;
		}
	}
}

// Calcule du Joker (Rois Carreau) aprés le Tirage
SingleGame.prototype.CalculeAfterKing = function() {
	if (this.Tour == 0) {
		this.UserRoundScor = (this.UserRoundScor - this.kingScor);
		if (this.UserRoundScor < this.HoldScor) {

			this.kingScor = (this.HoldScor - this.UserRoundScor);
			this.UserRoundScor = this.UserRoundScor + this.kingScor;
		} else {
			this.UserRoundScor = this.UserRoundScor + 0.5;
		}
	} else if (this.Tour == 1) {
		this.RobotRoundScor = (this.RobotRoundScor - this.kingScor);
		if (this.RobotRoundScor < this.HoldScor) {

			this.kingScor = (this.HoldScor - this.RobotRoundScor);
			this.FirstCarteRobot = this.kingScor;
			this.RobotRoundScor = this.RobotRoundScor + this.kingScor;
		} else {
			this.RobotRoundScor = this.RobotRoundScor + 0.5;
		}
	}

}

// Choix du robot avec un comportement humain
SingleGame.prototype.RobbotChoice = function() {

	var choice = Math.floor((Math.random() * 100) + 0);
	var choix = Math.floor((Math.random() * 100) + 0);
	if ((this.RobotRoundScor >= 5)
			|| (this.RobotRoundScor <= (this.UserRoundScor - this.FirstCarteUser))
			|| (this.RobotRoundScor == 7.5)
			|| ((this.RobotRoundScor == 0) && (this.GameTour % 2 == 0))) {
		if (this.RobotRoundScor == 7.5) {
			return false;
		}

		else if (this.RobotRoundScor <= (this.UserRoundScor - this.CarteUser)
				&& (this.GameTour % 2 != 0)) {
			this.TirageRobot++;
			return true;
		} else if ((this.UserRoundScor - this.CarteUser) == 7
				&& (this.GameTour % 2 != 0)) {
			this.TirageRobot++;
			return true;
		} else if (this.NumberCarteImageRobot >= 3) {
			if (choix > 6 && choix < 4) {
				this.TirageRobot++;
				return true;
			} else {
				return false;
			}

		} else if (this.RobotRoundScor == 7 && (this.GameTour % 2 == 0)) {
			if (choix == 5) {
				this.TirageRobot++;
				return true;
			} else {
				return false;
			}
		}

		else if ((this.RobotRoundScor == 6 || this.RobotRoundScor == 6.5)
				&& (this.GameTour % 2 == 0)) {
			if ((choix == 5) || (choix == 7)) {
				this.TirageRobot++;
				return true;
			} else {
				return false;
			}
		} else if (this.RobotRoundScor > 5) {
			if (choice % 2 == 0) {
				this.TirageRobot++;
				return true;
			} else {
				if (this.RobotRoundScor < this.HoldScor) {
					this.Tour = 0;
					return false;
				}
				return false;
			}
		}
	} else {
		this.TirageRobot++;
		return true;
	}
	if (this.RobotRoundScor >= this.HoldScor)

		return false;
	this.TirageRobot++;
	return true;
}

// Inisilisation des variables
SingleGame.prototype.Inisialisation = function() {
	if (this.gameFinish == false) {

		this.UserRoundScor = 0;
		this.values = null;
		this.RobotRoundScor = 0;
		this.Round = 0;
		this.NumberCarteImage = 1;
		this.NumberCarteImageRobot = 1;
		this.kingScor = 0;
		this.TirageKing = 0;
		this.TirageKingRobot = 0;
		this.i = 0;
		this.TableCarteTirer = new Array(50);
		this.CarteTirer = 0;
		this.CarteUser = 0;
		this.CarteRobot = 0;
		this.RoundFinish = false;
		var robot = document.getElementById('SpaceCardRobot');
		var player = document.getElementById('SpaceCardPlayer');

		robot.innerHTML = '';
		player.innerHTML = '';

		// fin Inisilisation pour chaque tour
		// Message Round

		document.getElementById('Journal').innerHTML = "";

		//this.Write(" Round " + this.GameTour, "#183152",0);
		document.getElementById('RoundNumber').innerHTML="<p>Round "+this.GameTour+"</p>";
		if(this.GameTour%2!=0)
		{
			this.Write(" Round " + this.GameTour , "#183152",0,"Your Turn");
		}
		else
			this.Write(" Round " + this.GameTour , "#183152",0,"Robot's Turn ");

		
		// fin Message Round
		// First Carte User
		this.Carte = Math.floor((Math.random() * 10) + 0);
		this.Couleur = Math.floor((Math.random() * 4) + 0);

		this.values = T[this.Carte];
		this.FirstCarteUser = this.values[this.Couleur];

		this.CarteUser = (this.Carte * 100) + this.Couleur;

		this.TableCarteTirer[this.i] = (this.Carte * 100) + this.Couleur;
		this.i++;

		if (this.CarteUser == 900) {
			this.UserRoundScor = 7;
			this.TirageKing = 1;
			this.kingScor = 7;

		} else {
			this.UserRoundScor = this.FirstCarteUser;

		}
		// Fin First Carte User

		// First Carte Robot
		this.Carte = Math.floor((Math.random() * 10) + 0);
		this.Couleur = Math.floor((Math.random() * 4) + 0);
		this.CarteRobot = (this.Carte * 100) + this.Couleur;

		while (this.SearchNumber(this.CarteRobot)) {
			this.Carte = Math.floor((Math.random() * 10) + 0);
			this.Couleur = Math.floor((Math.random() * 4) + 0);
			this.CarteRobot = (this.Carte * 100) + this.Couleur;
		}

		if (this.CarteRobot == 900) {

			this.FirstCarteRobot = 7;
			this.TirageKingRobot = 1;
			this.kingScor = 7;
		} else {
			this.values = T[this.Carte];
			this.FirstCarteRobot = this.values[this.Couleur];
			this.RobotRoundScor = this.FirstCarteRobot;
		}
		this.FirstCarteRobotImage = this.CarteRobot;
		this.values = T[this.Carte];
		this.FirstCarteRobot = this.values[this.Couleur];
		this.TableCarteTirer[this.i] = (this.Carte * 100) + this.Couleur;
		this.i++;

		// Fin First Carte Robot

		// fin Affectation des Cartes Face caché

		document.getElementById('RoundScorPlayer').innerHTML = "<p>Player's Score : "
				+ this.UserScors + "</p>";
		document.getElementById('RoundScorRobot').innerHTML = "<p>Robot's Score : "
				+ this.RobotScors + "</p>";
		document.getElementById('ScorPlayer').innerHTML = "<p>Round's Score : "
				+ this.UserRoundScor + "</p>";
		document.getElementById('FirstCardPlayer').innerHTML = '<img class="FirstCard" src="app/images/cards/'
				+ this.CarteUser + '.png" />';

		document.getElementById('ScorRobot').innerHTML = "<p>Round's Score : 0</p>";
		document.getElementById('FirstCardRobot').innerHTML = '<img class="FirstCard" src="app/images/Game/carte_cachee.png" />';
		if (this.GameTour % 2 == 0) {
			this.Tour = 1;
			// GameRobot();

		} else {
			this.Tour = 0;

		}
		if (this.Tour == 1) {
			this.GameRobot();
		}
		
	}
}
// methode qui calcule le scor si le rois carreau est tirrer
SingleGame.prototype.CalculeRoisCarreau = function() {

	if (this.Tour == 0) {
		if (this.UserRoundScor < this.HoldScor) {
			if (this.UserRoundScor == 0) {
				this.UserRoundScor = 7;
			} else if (this.UserRoundScor == 7) {
				this.UserRoundScor = this.UserRoundScor + 0.5;
			}

			else {
				this.kingScor = (this.HoldScor - this.UserRoundScor);
				this.UserRoundScor = this.UserRoundScor + this.kingScor;

			}
		} else {
			this.UserRoundScor = this.UserRoundScor + 0.5;
		}
	} else if (this.Tour == 1) {
		if (this.RobotRoundScor < this.HoldScor) {
			if (this.RobotRoundScor == 0) {
				this.RobotRoundScor = 7;
			} else if (this.RobotRoundScor == 7) {
				this.RobotRoundScor = this.UserRoundScor + 0.5;
			} else {
				this.kingScor = (this.HoldScor - this.RobotRoundScor);
				this.RobotRoundScor = this.RobotRoundScor + this.kingScor;
			}
		} else {
			this.RobotRoundScor = this.RobotRoundScor + 0.5;
		}
	}
}
// Tirer Carte By User
SingleGame.prototype.TirerCarteUser = function() {

	this.TableCarteTirer[this.i] = this.CarteUser;
	this.i++;
	if (this.CarteUser == 900) {
		this.TirageKing = 1;
		this.CalculeRoisCarreau();
	} else {
		if (this.TirageKing == 0) {
			this.values = T[this.Carte];
			this.UserRoundScor = this.UserRoundScor + this.values[this.Couleur];
		} else {
			this.values = T[this.Carte];
			this.UserRoundScor = this.UserRoundScor + this.values[this.Couleur];
			this.CalculeAfterKing();
		}

	}

	document.getElementById('ScorPlayer').innerHTML = "<p>Round's Score : "
			+ this.UserRoundScor + "</p>";
	this.player.innerHTML += '  <div id="CardPickedPlayer'
			+ (((this.NumberCarteImage - 1)))
			+ '"> <img class="Card" src="app/images/cards/' + this.CarteUser
			+ '.png" /></div>';
	this.NumberCarteImage++;

}

// systeme de jeu du joueur
SingleGame.prototype.GameUser = function() {

	if ((this.Tour == 0) && (this.HoldScor > this.UserRoundScor)) {
		this.Carte = Math.floor((Math.random() * 10) + 0);
		this.Couleur = Math.floor((Math.random() * 4) + 0);
		this.CarteUser = (this.Carte * 100) + this.Couleur;

		while (this.SearchNumber(this.CarteUser) == true) {
			this.Carte = Math.floor((Math.random() * 10) + 0);
			this.Couleur = Math.floor((Math.random() * 4) + 0);
			this.CarteUser = (this.Carte * 100) + this.Couleur;
		}

		this.TirerCarteUser();

		if (this.UserRoundScor > this.HoldScor) {
			this.UserScors = this.UserScors - 100;
			this.RobotScors = this.RobotScors + 100;
			this.RoundFinish = true;

			if (!this.GameIsFinish()) {
				this.Write("Robot Wins The Round " + this.GameTour, "#1D702D",
						null, "Press enter for next round","2000");
				this.GameTour++;
			}

		}
	} else {
		if (this.UserRoundScor > this.HoldScor) {
			this.UserScors = this.UserScors - 100;
			this.RobotScors = this.RobotScors + 100;
			this.RoundFinish = true;

			if (!this.GameIsFinish()) {
				this.Write("Robot Wins The Round " + this.GameTour, "#1D702D",
						null, "Press enter for next round","2000");
				this.GameTour++;
			}
		} else {

			if ((this.RobotRoundScor > this.UserRoundScor)) {
				this.UserScors = this.UserScors - 100;
				this.RobotScors = this.RobotScors + 100;
				this.RoundFinish = true;
				if (!this.GameIsFinish()) {
					this.Write("Robot Wins The Round " + this.GameTour, "#1D702D",
							null, "Press enter for next round","2000");
					this.GameTour++;
				}
			} else if ((this.RobotRoundScor < this.UserRoundScor)) {
				this.RobotScors = this.RobotScors - 100;
				this.UserScors = this.UserScors + 100;
				this.RoundFinish = true;
				if (!this.GameIsFinish()) {
					this.Write("You Win The Round " + this.GameTour,
							"#1D702D", null, "Press enter for next round","2000");
					this.GameTour++;
				}
			} else {
				this.RoundFinish = true;
				if (!this.GameIsFinish()) {
					this.Write("Round "+this.GameTour+" ends with a Draw", "#641A02", null,
							"Press enter for next round","2000");
					this.GameTour++;
				}

			}

		}

	}

}
SingleGame.prototype.sleep = function(milliseconds) {
	var start = new Date().getTime();
	for (var i = 0; i < 1e7; i++) {
		if ((new Date().getTime() - start) > milliseconds) {
			break;
		}
	}
}

// Tirer Carte By robot
SingleGame.prototype.TirerCarteRobot = function() {
	
	this.ScorRobotAfficher = 0;
	this.TableCarteTirer[this.i] = this.CarteRobot;
	this.i++;
	if (this.CarteRobot == 900) {
		this.TirageKingRobot = 1;
		this.CalculeRoisCarreau();
	} else {
		if (this.TirageKingRobot == 0) {
			this.values = T[this.Carte];

			this.RobotRoundScor = this.RobotRoundScor
					+ this.values[this.Couleur];
		} else {
			this.values = T[this.Carte];
			this.RobotRoundScor = this.RobotRoundScor
					+ this.values[this.Couleur];
			this.CalculeAfterKing();
		}

	}
	if (this.TirageRobot == 0)
		this.ScorRobotAfficher = 0;
	else if (this.RobotRoundScor - this.FirstCarteRobot < 0)
		this.ScorRobotAfficher = this.FirstCarteRobot - this.RobotRoundScor;
	else
		this.ScorRobotAfficher = this.RobotRoundScor - this.FirstCarteRobot;

	document.getElementById('ScorRobot').innerHTML = "<p>Round's Score : "
			+ this.ScorRobotAfficher + "</p>";
	document.getElementById('SpaceCardRobot').innerHTML += '<div id="CardPickedRobot'
			+ (this.NumberCarteImageRobot - 1)
			+ '"><img class="Card" src="app/images/cards/'
			+ this.CarteRobot
			+ '.png" />';
	this.NumberCarteImageRobot++;
	
	
}

//Game Robot
SingleGame.prototype.GameRobot = function() {
   	
	var ScorRobotAfficher = 0;
	this.values = null;
	var flag = true;
	if ((this.Tour == 1) && (this.HoldScor > this.RobotRoundScor)) {
		if (this.RobbotChoice() == false) {
			if (this.GameTour % 2 == 0)
				this.Tour = 0;

		} else if ((this.RobbotChoice() == true)
				&& (this.HoldScor > this.RobotRoundScor)) {
				
				var self = this;
				flag = false;
				
			while ((self.RobbotChoice() == true)
					&& (self.HoldScor > self.RobotRoundScor)) {

				self.Carte = Math.floor((Math.random() * 10) + 0);
				self.Couleur = Math.floor((Math.random() * 4) + 0);
				self.CarteRobot = (self.Carte * 100) + self.Couleur;
				while (self.SearchNumber(self.CarteRobot) == true) {
					self.Carte = Math.floor((Math.random() * 10) + 0);
					self.Couleur = Math.floor((Math.random() * 4) + 0);
					self.CarteRobot = (self.Carte * 100) + self.Couleur;
				}
				
				
				self.TirerCarteRobot();
				
				
			}
			flag = true;
			
		}
		
		
		
		if (this.RobotRoundScor > this.HoldScor) {
			document.getElementById('ScorRobot').innerHTML = "<p>Round's Score : "
					+ this.RobotRoundScor + "</p>";
			this.RobotScors = this.RobotScors - 100;
			this.UserScors = this.UserScors + 100;

			document.getElementById('FirstCardRobot').innerHTML = '<img class="FirstCard" src="app/images/cards/'
					+ this.FirstCarteRobotImage + '.png" />';
			this.RoundFinish = true;
			if (!this.GameIsFinish()) {
				this.Write("Player Wins The Round " + this.GameTour, "#1D702D",
						null, "Press enter for next round","2000");
				this.GameTour++;
			}

		} else {
			if (this.GameTour % 2 == 0) {
				this.Tour = 0;
				this.Write("Your Turn" , "#183152",0);
			} 
			
			
			else {

				if ((this.RobotRoundScor > this.UserRoundScor)) {
					document.getElementById('FirstCardRobot').innerHTML = '<img class="FirstCard" src="app/images/cards/'
							+ this.FirstCarteRobotImage + '.png" />';

					document.getElementById('ScorRobot').innerHTML = "<p>Round's Score : "
							+ this.RobotRoundScor + "</p>";
					this.UserScors = this.UserScors - 100;
					this.RobotScors = this.RobotScors + 100;
					this.RoundFinish = true;
					if (!this.GameIsFinish()) {
						this.Write("Robot Wins The Round " + this.GameTour,
								"#1D702D", null, "Press enter for next round","2000");
						this.GameTour++;
					}
				} else if ((this.RobotRoundScor < this.UserRoundScor)) {
					document.getElementById('FirstCardRobot').innerHTML = '<img class="FirstCard" src="app/images/cards/'
							+ this.FirstCarteRobotImage + '.png" />';
					document.getElementById('ScorRobot').innerHTML = "<p>Round's Score : "
							+ this.RobotRoundScor + "</p>";
					this.RobotScors = this.RobotScors - 100;
					this.UserScors = this.UserScors + 100;
					this.RoundFinish = true;
					if (!this.GameIsFinish()) {
						this.Write("You Win The Round " + this.GameTour,
								"#1D702D", null, "Press enter for next round","2000");
						this.GameTour++;
					}
				} else {
					document.getElementById('FirstCardRobot').innerHTML = '<img class="FirstCard" src="app/images/cards/'
							+ this.FirstCarteRobotImage + '.png" />';
					document.getElementById('ScorRobot').innerHTML = "<p>Round's Score : "
							+ this.RobotRoundScor + "</p>";
					this.RoundFinish = true;
					if (!this.GameIsFinish()) {
						this.Write("Round "+this.GameTour+" ends with a Draw", "#641A02", null,
								"Press enter for next round","2000");
						this.GameTour++;
					}
				}

			}

		}
	}
 
	
}

SingleGame.prototype.Game = function() {

	T = this.TableM.TableCartesFull();

	this.Inisialisation();

}