Klasse Server
java.lang.Object
ServerPackage.Server
TicTacToe ServerCreator-Script
Script allows to send messages/responses to Players and has the game logic for Tic-Tac-Toe
- Version:
- 2.1.0
- Autor:
- Julian Lombardo, Diego Zwahlen, Lean Melone
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifikator und TypMethodeBeschreibungstatic StringboardToString(char[] board) Transforms the board to a Stringstatic booleancheckWin(char[] board, char player) Checks for a win on the boardstatic voidsendCurrentBoard(char[] board, InetAddress player1, InetAddress player2, DatagramSocket socket) Sends current Board to all Playersstatic voidsendMessageToPlayer(InetAddress Player, DatagramSocket socket, String msg) Sends Messages to certain PlayersvoidThis is the method, which is started by the thread in the MainGame, to start the servervoidwin(InetAddress activePlayer, int fullCounter) Handels the different kind of wins/draws
-
Konstruktordetails
-
Server
public Server(String player1IP, String player2IP, String serverID, int port, boolean botServer) throws SocketException Contructor for Server- Löst aus:
ExceptionSocketException
-
-
Methodendetails
-
startServer
This is the method, which is started by the thread in the MainGame, to start the server- Löst aus:
NumberFormatExceptionException
-
win
Handels the different kind of wins/draws- Parameter:
activePlayer-fullCounter-- Löst aus:
IOException
-
boardToString
Transforms the board to a String- Parameter:
board-- Gibt zurück:
- String
-
sendCurrentBoard
public static void sendCurrentBoard(char[] board, InetAddress player1, InetAddress player2, DatagramSocket socket) throws IOException Sends current Board to all Players- Parameter:
board-player1-player2-socket-- Löst aus:
IOException
-
checkWin
public static boolean checkWin(char[] board, char player) Checks for a win on the board- Parameter:
board-player-- Gibt zurück:
- boolean
-
sendMessageToPlayer
public static void sendMessageToPlayer(InetAddress Player, DatagramSocket socket, String msg) throws IOException Sends Messages to certain Players- Parameter:
Player-socket-msg-- Löst aus:
IOException
-