public class Game {
    // Instanzvariablen - ersetzen Sie das folgende Beispiel mit Ihren Variablen
    WordleServer wordleServer;
    User user;
    static DatabaseConnector databaseConnector = new DatabaseConnector("", 0, "wordle.db", "", "");;// Datenbankverbindung aufstellen
    
    private String ip;
    private int port;
    
    private String wordle;
    private String[] words;
    private int count;
    private int phase;
    
    public Game(WordleServer wordleServer, String pClientIP, int pClientPort) {
        
        this.wordleServer = wordleServer;
        this.ip = pClientIP;
        this.port = pClientPort;
        
        send("+OK Hello there");
    }
    
    public void processMessage(String msg) {
        
        msg = msg.toLowerCase().trim();
        
        if (msg.equals("quit")) {
            send("+OK bye");
            wordleServer.closeConnection(ip, port);
        }
        
        switch (phase) {
        case 0:
            loginPhase(msg);
            break;
        case 1:
            gamePhase(msg);
            break;
        case 2:
            endPhase(msg);
            break;
        }
    }
    
    private void loginPhase(String msg) {
        if (msg.startsWith("user")) {
            
        } else if (msg.startsWith("pass")) {
            
        } else if (msg.startsWith("wotd")) {
            
        } else if (msg.startsWith("play")) {
            
        }
    }
    
    private void gamePhase(String msg) {
        
        
        
        if (msg.startsWith("send")) {
            
            String args = msg.substring(5);
            //vergleichen von wotd mit
            //ja = spiel beendet und ausgabe word 11111
            //nein = ausgabe 01102 oder so und prüfen ob man noch ein wort eingebn kann
            // ja game continues nein = game lost
            
        } else if (msg.startsWith("info")) {
            
            
            
        } else if (msg.startsWith("exit")) {
            
            
            
        }
    }
    
    private void endPhase(String msg) {
        if (msg.startsWith("stat")) {
            
        } else if (msg.startsWith("play")) {
            
        }
    }
    
    private void spielstandAbrufen(String name)
    {
     
    }
    
    
    
    private void send(String msg) {
        wordleServer.send(ip, port, msg);
    }
    
    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }
}
