première solution
This commit is contained in:
100
table.html
Normal file
100
table.html
Normal file
@@ -0,0 +1,100 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<script >
|
||||
|
||||
playerSet = [ "Pierre Moreau", "Thomas Gauthier", "Antoine Nicolas", "Axel Blanc",
|
||||
"Clément Garcia", "Maël Mercier", "Alexis Chevalier", "Paul Rousseau", "Théo Leroy", "Victor Robert",
|
||||
"Louis Richard", "Baptiste Roux", "Sacha Leroy", "Nolan Simon", "Martin Laurent", "Jules Guerin", "Tom Andre",
|
||||
"Raphaël David", "Romain Perrin", "Léo Blanc", "Valentin Vincent", "Alexandre Mercier", "Paul Gauthier", "Nicolas Roux", "Tom Guerin", "Lucas Thomas",
|
||||
"Clément Henry", "Clément Bernard", "Maël Morel", "Léo Morin", "Benjamin Perrin", "Clément Robert", "Raphaël Muller", "Simon David",
|
||||
"Romain Gauthier", "Adrien Mercier", "Clément Lambert", "Robin Clement", "Alexis Bertrand", "Quentin Girard", "Liam Masson", "Adam Robert",
|
||||
"Clément Gautier", "Samuel Fontaine", "Martin Simon", "Clément Masson", "Benjamin Roussel", "Alexis Boyer", "Alexis Girard", "Clément Fontaine",
|
||||
"Ethan Laurent", "Evan Vincent", "Enzo Moreau", "Samuel Roussel", "Benjamin Mercier", "Benjamin Roux", "Benjamin Muller", "Liam Durand",
|
||||
"Romain Gauthier", "Léo Bertrand", "Nolan Perrin", "Arthur David", "Nicolas Boyer", "Robin Roux", "Paul Roux", "Baptiste Perrin",
|
||||
"Mathis Lambert", "Axel Fontaine", "Simon Martin", "Yanis Perrin", "Benjamin Roussel", "Maxime Fontaine" ];
|
||||
|
||||
gameSet= [ "Splendor", "Azul", "King Domino", "7 wonders architect", "akkroplis"];
|
||||
|
||||
|
||||
function compute() {
|
||||
document.getElementById("results").innerHTML="";
|
||||
players = playerSet.slice(0,document.getElementById("players").value) ;
|
||||
games = gameSet.slice(0,document.getElementById("games").value) ;
|
||||
playerAtTable = document.getElementById("tables").value;
|
||||
|
||||
var finished = false;
|
||||
session=1;
|
||||
maxgameplayed = Math.floor(players.length / playerAtTable);
|
||||
show ("Maximum "+ maxgameplayed + " parties joués en même temps");
|
||||
played ={};
|
||||
for( const player of players ) {
|
||||
played[player]={};
|
||||
}
|
||||
|
||||
while(!finished) {
|
||||
show("<p><b>Session "+session +"<b><br/>");
|
||||
var tables=0;
|
||||
playerPlayInSession=[];
|
||||
for( const game of games ) {
|
||||
possibleplayers =[];
|
||||
for( const player of players ) {
|
||||
if ( typeof played[player][game] === "undefined" && !playerPlayInSession.includes(player) ) {
|
||||
possibleplayers.push(player);
|
||||
}
|
||||
if(possibleplayers.length == playerAtTable) break; //les premiers disponible n'ayant pas joué
|
||||
}
|
||||
|
||||
//youpi , une table faite
|
||||
if(possibleplayers.length == playerAtTable ) {
|
||||
for( const player of possibleplayers ) {
|
||||
played[player][game] = session;
|
||||
playerPlayInSession.push(player);
|
||||
}
|
||||
show( "table "+game+" : " + possibleplayers.join(" , ") +"<br/>");
|
||||
tables++;
|
||||
}
|
||||
|
||||
if(tables == maxgameplayed) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
show("</p>");
|
||||
session++;
|
||||
if (tables == 0) //ameliorer condition d'arret
|
||||
finished=true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//verification
|
||||
show("<p><b>Vérification<b><br/>");
|
||||
for( const player in played) {
|
||||
var allplayed = Object.keys(played[player]).length == games.length;
|
||||
if (allplayed) {
|
||||
show ("<span style='color:green' >"+ player + " a joué à tous les jeux<span>");
|
||||
}else {
|
||||
show ("<span style='color:red' >"+ player + " a joué à seulement" + JSON.stringify(played[player]) +"<span>");
|
||||
}
|
||||
show("<br/>");
|
||||
}
|
||||
}
|
||||
|
||||
function show(text) {
|
||||
elem = document.getElementById("results");
|
||||
elem.insertAdjacentHTML( 'beforeend', text);
|
||||
}
|
||||
</script>
|
||||
<div id="param" style="float:left;width:50%; text-align:center">
|
||||
Nombres de jouers (nom inventés) <input id="players" name="players" placeholder="nombre de joueurs" type ="text"/><br/>
|
||||
Nombres de joueurs par tables <input id="tables" name="tables" placeholder="nombre de joueurs par table" type ="text"/><br/>
|
||||
Nombres de jeux à jouer <input id="games" name="games" placeholder="nombre de jeux" type ="text"/><br>
|
||||
<button onclick="compute();" > Calculer</button>
|
||||
</div>
|
||||
<div id="results" style="float:left;width:50%;">
|
||||
les sessions de jeu : <br/>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user