UrbanMarginal/src/controleur/Controle.java

65 lines
1.3 KiB
Java
Raw Normal View History

2025-03-06 14:24:29 +00:00
package controleur;
2025-03-11 08:28:09 +00:00
import outils.connexion.AsyncResponse;
import outils.connexion.ClientSocket;
import outils.connexion.Connection;
import outils.connexion.ServeurSocket;
import vue.Arene;
import vue.ChoixJoueur;
2025-03-06 14:24:29 +00:00
import vue.EntreeJeu;
2025-03-11 08:28:09 +00:00
public class Controle implements AsyncResponse {
2025-03-06 14:24:29 +00:00
private EntreeJeu frmEntreeJeu ;
2025-03-11 08:28:09 +00:00
public String type;
2025-03-06 14:24:29 +00:00
/**
* Constructeur
*/
private Controle() {
2025-03-11 08:28:09 +00:00
this.frmEntreeJeu = new EntreeJeu(this) ;
2025-03-06 14:24:29 +00:00
this.frmEntreeJeu.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Controle();
}
2025-03-11 08:28:09 +00:00
public void evenementEntreeJeu(String info) {
//
if(info.contains("serveur")) {
System.out.println("srv");
type = "serveur";
//
new ServeurSocket(this, 6666);
Arene areneJeu = new Arene();
areneJeu.setVisible(true);
frmEntreeJeu.dispose();
}else {
System.out.println("ip");
type = "client";
//
new ClientSocket(this, info, 6666);
//frmEntreeJeu.dispose();
}
}
@Override
public void reception(Connection connection, String ordre, Object info) {
// TODO Auto-generated method stub
switch (ordre){
case "connexion":
if(type.equals("client")) {
frmEntreeJeu.dispose();
Arene frmArene = new Arene();
ChoixJoueur frmChoixJoueur = new ChoixJoueur();
frmChoixJoueur.setVisible(true);
}
break;
}
}
2025-03-06 14:24:29 +00:00
}