UrbanMarginal/src/controleur/Controle.java

69 lines
1.5 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-11 10:13:51 +00:00
private ChoixJoueur frmChoixJoueur;
private Arene frmArene;
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);
}
}
@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();
2025-03-11 10:13:51 +00:00
this.frmArene = new Arene();
this.frmChoixJoueur = new ChoixJoueur(this);
this.frmChoixJoueur.setVisible(true);
2025-03-11 08:28:09 +00:00
}
break;
}
}
2025-03-11 10:13:51 +00:00
public void evenementChoixJoueur(String pseudo, int numPerso) {
//
this.frmChoixJoueur.dispose();
this.frmArene.setVisible(true);
}
2025-03-06 14:24:29 +00:00
}