<commit_before>package network;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.SocketException;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.lang3.tuple.Pair;

import core.Action;
import core.Config;
import core.Joueur;

public class Client extends Thread {
	private Socket client;
	private DispatcherServeur serveur;

	public Client(Socket client, DispatcherServeur serveur) {
		super();
		this.client = client;
		this.serveur = serveur;
		start();
	}

	public void run() {
		System.out.println("Client connecté");

		Partie current = null;
		Joueur joueur = null;
		int numero_partie = -1;
		boolean create = false;
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
			BufferedWriter out = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));

			String userInput;
			boolean join = false;

			while ((userInput = in.readLine()) != null) {
				System.out.println(userInput + "\n");
				String[] arguments = userInput.split(" ");
				boolean peut_jouer = (create || join) && current.getMarche().est_ouvert() && !current.getMarche().est_fini();

				// Utilisateur n'ayant ni crÃ©Ã© ni rejoint peut crÃ©er
				if (userInput.startsWith("CREATE ") && arguments.length == 2 && !create && !join) {
					String nom = arguments[1];
					numero_partie = (int) (Math.random() * 100000);
					envoyer(out, String.valueOf(numero_partie));
					current = new Partie();
					joueur = current.ajouter_client(client, nom);
					serveur.ajouterPartie(numero_partie, current);
					create = true;
				} else if (userInput.startsWith("JOIN ") && arguments.length == 3 && StringUtils.isNumeric(arguments[1]) && !create
						&& !join) {
					numero_partie = Integer.parseInt(arguments[1]);
					String nom = arguments[2];

					if (!serveur.partieExiste(numero_partie)) {
						envoyer(out, "-1");<commit_msg>Update Client.java<commit_after>package network;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.SocketException;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.lang3.tuple.Pair;

import core.Action;
import core.Config;
import core.Joueur;

public class Client extends Thread {
	private Socket client;
	private DispatcherServeur serveur;

	public Client(Socket client, DispatcherServeur serveur) {
		super();
		this.client = client;
		this.serveur = serveur;
		start();
	}

	public void run() {
		System.out.println("Client connecté");

		Partie current = null;
		Joueur joueur = null;
		int numero_partie = -1;
		boolean create = false;
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
			BufferedWriter out = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));

			String userInput;
			boolean join = false;

			while ((userInput = in.readLine()) != null) {
				System.out.println(userInput + "\n");
				String[] arguments = userInput.split(" ");
				boolean peut_jouer = (create || join) && current.getMarche().est_ouvert() && !current.getMarche().est_fini();

				// Utilisateur n'ayant ni créé ni rejoint peut créer
				if (userInput.startsWith("CREATE ") && arguments.length == 2 && !create && !join) {
					String nom = arguments[1];
					numero_partie = (int) (Math.random() * 100000);
					envoyer(out, String.valueOf(numero_partie));
					current = new Partie();
					joueur = current.ajouter_client(client, nom);
					serveur.ajouterPartie(numero_partie, current);
					create = true;
				} else if (userInput.startsWith("JOIN ") && arguments.length == 3 && StringUtils.isNumeric(arguments[1]) && !create
						&& !join) {
					numero_partie = Integer.parseInt(arguments[1]);
					String nom = arguments[2];

					if (!serveur.partieExiste(numero_partie)) {
						envoyer(out, "-1");
{'fraction_non_alphanumeric': 0.13173933427097984, 'fraction_numerical': 0.007969995311767463, 'mean_word_length': 4.3006211180124225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '114726', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1344, 'n_words': 304}